blob: 81aea8d178d5b9f66148975a1083798cea6d61a7 [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
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -060019import static android.content.ContentProvider.maybeAddUserId;
20
Tor Norbye7b9c9122013-05-30 16:48:33 -070021import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070022import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import android.annotation.SdkConstant;
25import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050026import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050028import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060029import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.content.pm.PackageManager;
31import android.content.pm.ResolveInfo;
32import android.content.res.Resources;
33import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080034import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070035import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060036import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.os.Bundle;
38import android.os.IBinder;
39import android.os.Parcel;
40import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000041import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050042import android.os.ResultReceiver;
43import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070044import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010045import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070046import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070047import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050048import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070049import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050050import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070051import android.util.AttributeSet;
52import android.util.Log;
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -060053
Dianne Hackborn2269d1572010-02-24 19:54:22 -080054import com.android.internal.util.XmlUtils;
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -060055
Jason Monk2f68e8a2016-02-23 17:57:28 -050056import org.xmlpull.v1.XmlPullParser;
57import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070058import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059
60import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080061import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070063import java.lang.annotation.Retention;
64import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065import java.net.URISyntaxException;
66import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080067import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070068import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080069import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070070import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070071import java.util.Set;
72
73/**
74 * An intent is an abstract description of an operation to be performed. It
75 * can be used with {@link Context#startActivity(Intent) startActivity} to
76 * launch an {@link android.app.Activity},
77 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
78 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
79 * and {@link android.content.Context#startService} or
80 * {@link android.content.Context#bindService} to communicate with a
81 * background {@link android.app.Service}.
82 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070083 * <p>An Intent provides a facility for performing late runtime binding between the code in
84 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070085 * can be thought of as the glue between activities. It is basically a passive data structure
86 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070087 *
88 * <div class="special reference">
89 * <h3>Developer Guides</h3>
90 * <p>For information about how to create and resolve intents, read the
91 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
92 * developer guide.</p>
93 * </div>
94 *
95 * <a name="IntentStructure"></a>
96 * <h3>Intent Structure</h3>
97 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 *
99 * <ul>
100 * <li> <p><b>action</b> -- The general action to be performed, such as
101 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
102 * etc.</p>
103 * </li>
104 * <li> <p><b>data</b> -- The data to operate on, such as a person record
105 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
106 * </li>
107 * </ul>
108 *
109 *
110 * <p>Some examples of action/data pairs are:</p>
111 *
112 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * information about the person whose identifier is "1".</p>
115 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700116 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700117 * the phone dialer with the person filled in.</p>
118 * </li>
119 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
120 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700121 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700122 * a particular URI.</p>
123 * </li>
124 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
125 * the phone dialer with the given number filled in.</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * information about the person whose identifier is "1".</p>
129 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700130 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700131 * a list of people, which the user can browse through. This example is a
132 * typical top-level entry into the Contacts application, showing you the
133 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700134 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700135 * being used to start an activity to display that person.</p>
136 * </li>
137 * </ul>
138 *
139 * <p>In addition to these primary attributes, there are a number of secondary
140 * attributes that you can also include with an intent:</p>
141 *
142 * <ul>
143 * <li> <p><b>category</b> -- Gives additional information about the action
144 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
145 * appear in the Launcher as a top-level application, while
146 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
147 * of alternative actions the user can perform on a piece of data.</p>
148 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
149 * intent data. Normally the type is inferred from the data itself.
150 * By setting this attribute, you disable that evaluation and force
151 * an explicit type.</p>
152 * <li> <p><b>component</b> -- Specifies an explicit name of a component
153 * class to use for the intent. Normally this is determined by looking
154 * at the other information in the intent (the action, data/type, and
155 * categories) and matching that with a component that can handle it.
156 * If this attribute is set then none of the evaluation is performed,
157 * and this component is used exactly as is. By specifying this attribute,
158 * all of the other Intent attributes become optional.</p>
159 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
160 * This can be used to provide extended information to the component.
161 * For example, if we have a action to send an e-mail message, we could
162 * also include extra pieces of data here to supply a subject, body,
163 * etc.</p>
164 * </ul>
165 *
166 * <p>Here are some examples of other operations you can specify as intents
167 * using these additional parameters:</p>
168 *
169 * <ul>
170 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
171 * Launch the home screen.</p>
172 * </li>
173 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
174 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
175 * vnd.android.cursor.item/phone}</i></b>
176 * -- Display the list of people's phone numbers, allowing the user to
177 * browse through them and pick one and return it to the parent activity.</p>
178 * </li>
179 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
180 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
181 * -- Display all pickers for data that can be opened with
182 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
183 * allowing the user to pick one of them and then some data inside of it
184 * and returning the resulting URI to the caller. This can be used,
185 * for example, in an e-mail application to allow the user to pick some
186 * data to include as an attachment.</p>
187 * </li>
188 * </ul>
189 *
190 * <p>There are a variety of standard Intent action and category constants
191 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700192 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700193 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700194 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700195 *
196 * <p>Put together, the set of actions, data types, categories, and extra data
197 * defines a language for the system allowing for the expression of phrases
198 * such as "call john smith's cell". As applications are added to the system,
199 * they can extend this language by adding new actions, types, and categories, or
200 * they can modify the behavior of existing phrases by supplying their own
201 * activities that handle them.</p>
202 *
203 * <a name="IntentResolution"></a>
204 * <h3>Intent Resolution</h3>
205 *
206 * <p>There are two primary forms of intents you will use.
207 *
208 * <ul>
209 * <li> <p><b>Explicit Intents</b> have specified a component (via
210 * {@link #setComponent} or {@link #setClass}), which provides the exact
211 * class to be run. Often these will not include any other information,
212 * simply being a way for an application to launch various internal
213 * activities it has as the user interacts with the application.
214 *
215 * <li> <p><b>Implicit Intents</b> have not specified a component;
216 * instead, they must include enough information for the system to
217 * determine which of the available components is best to run for that
218 * intent.
219 * </ul>
220 *
221 * <p>When using implicit intents, given such an arbitrary intent we need to
222 * know what to do with it. This is handled by the process of <em>Intent
223 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
224 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
225 * more activities/receivers) that can handle it.</p>
226 *
227 * <p>The intent resolution mechanism basically revolves around matching an
228 * Intent against all of the &lt;intent-filter&gt; descriptions in the
229 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
230 * objects explicitly registered with {@link Context#registerReceiver}.) More
231 * details on this can be found in the documentation on the {@link
232 * IntentFilter} class.</p>
233 *
234 * <p>There are three pieces of information in the Intent that are used for
235 * resolution: the action, type, and category. Using this information, a query
236 * is done on the {@link PackageManager} for a component that can handle the
237 * intent. The appropriate component is determined based on the intent
238 * information supplied in the <code>AndroidManifest.xml</code> file as
239 * follows:</p>
240 *
241 * <ul>
242 * <li> <p>The <b>action</b>, if given, must be listed by the component as
243 * one it handles.</p>
244 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
245 * already supplied in the Intent. Like the action, if a type is
246 * included in the intent (either explicitly or implicitly in its
247 * data), then this must be listed by the component as one it handles.</p>
248 * <li> For data that is not a <code>content:</code> URI and where no explicit
249 * type is included in the Intent, instead the <b>scheme</b> of the
250 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
251 * considered. Again like the action, if we are matching a scheme it
252 * must be listed by the component as one it can handle.
253 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
254 * by the activity as categories it handles. That is, if you include
255 * the categories {@link #CATEGORY_LAUNCHER} and
256 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
257 * with an intent that lists <em>both</em> of those categories.
258 * Activities will very often need to support the
259 * {@link #CATEGORY_DEFAULT} so that they can be found by
260 * {@link Context#startActivity Context.startActivity()}.</p>
261 * </ul>
262 *
263 * <p>For example, consider the Note Pad sample application that
264 * allows user to browse through a list of notes data and view details about
265 * individual items. Text in italics indicate places were you would replace a
266 * name with one specific to your own package.</p>
267 *
268 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
269 * package="<i>com.android.notepad</i>"&gt;
270 * &lt;application android:icon="@drawable/app_notes"
271 * android:label="@string/app_name"&gt;
272 *
273 * &lt;provider class=".NotePadProvider"
274 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
275 *
276 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
277 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700278 * &lt;action android:name="android.intent.action.MAIN" /&gt;
279 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700280 * &lt;/intent-filter&gt;
281 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700282 * &lt;action android:name="android.intent.action.VIEW" /&gt;
283 * &lt;action android:name="android.intent.action.EDIT" /&gt;
284 * &lt;action android:name="android.intent.action.PICK" /&gt;
285 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
286 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700289 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
290 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
291 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700292 * &lt;/intent-filter&gt;
293 * &lt;/activity&gt;
294 *
295 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
296 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700297 * &lt;action android:name="android.intent.action.VIEW" /&gt;
298 * &lt;action android:name="android.intent.action.EDIT" /&gt;
299 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
300 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;
302 *
303 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700304 * &lt;action android:name="android.intent.action.INSERT" /&gt;
305 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
306 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700307 * &lt;/intent-filter&gt;
308 *
309 * &lt;/activity&gt;
310 *
311 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
312 * android:theme="@android:style/Theme.Dialog"&gt;
313 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700314 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
315 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
317 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
318 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700319 * &lt;/intent-filter&gt;
320 * &lt;/activity&gt;
321 *
322 * &lt;/application&gt;
323 * &lt;/manifest&gt;</pre>
324 *
325 * <p>The first activity,
326 * <code>com.android.notepad.NotesList</code>, serves as our main
327 * entry into the app. It can do three things as described by its three intent
328 * templates:
329 * <ol>
330 * <li><pre>
331 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700332 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
333 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700334 * &lt;/intent-filter&gt;</pre>
335 * <p>This provides a top-level entry into the NotePad application: the standard
336 * MAIN action is a main entry point (not requiring any other information in
337 * the Intent), and the LAUNCHER category says that this entry point should be
338 * listed in the application launcher.</p>
339 * <li><pre>
340 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700341 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
342 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
343 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
344 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700345 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700346 * &lt;/intent-filter&gt;</pre>
347 * <p>This declares the things that the activity can do on a directory of
348 * notes. The type being supported is given with the &lt;type&gt; tag, where
349 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
350 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
351 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
352 * The activity allows the user to view or edit the directory of data (via
353 * the VIEW and EDIT actions), or to pick a particular note and return it
354 * to the caller (via the PICK action). Note also the DEFAULT category
355 * supplied here: this is <em>required</em> for the
356 * {@link Context#startActivity Context.startActivity} method to resolve your
357 * activity when its component name is not explicitly specified.</p>
358 * <li><pre>
359 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700360 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
361 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
362 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700363 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700364 * <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 -0700365 * the user without needing to know where it came from. The data type
366 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
367 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
368 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
369 * The GET_CONTENT action is similar to the PICK action, where the activity
370 * will return to its caller a piece of data selected by the user. Here,
371 * however, the caller specifies the type of data they desire instead of
372 * the type of data the user will be picking from.</p>
373 * </ol>
374 *
375 * <p>Given these capabilities, the following intents will resolve to the
376 * NotesList activity:</p>
377 *
378 * <ul>
379 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
380 * activities that can be used as top-level entry points into an
381 * application.</p>
382 * <li> <p><b>{ action=android.app.action.MAIN,
383 * category=android.app.category.LAUNCHER }</b> is the actual intent
384 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700385 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700386 * data=content://com.google.provider.NotePad/notes }</b>
387 * displays a list of all the notes under
388 * "content://com.google.provider.NotePad/notes", which
389 * the user can browse through and see the details on.</p>
390 * <li> <p><b>{ action=android.app.action.PICK
391 * data=content://com.google.provider.NotePad/notes }</b>
392 * provides a list of the notes under
393 * "content://com.google.provider.NotePad/notes", from which
394 * the user can pick a note whose data URL is returned back to the caller.</p>
395 * <li> <p><b>{ action=android.app.action.GET_CONTENT
396 * type=vnd.android.cursor.item/vnd.google.note }</b>
397 * is similar to the pick action, but allows the caller to specify the
398 * kind of data they want back so that the system can find the appropriate
399 * activity to pick something of that data type.</p>
400 * </ul>
401 *
402 * <p>The second activity,
403 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
404 * note entry and allows them to edit it. It can do two things as described
405 * by its two intent templates:
406 * <ol>
407 * <li><pre>
408 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700409 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
410 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
411 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
412 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700413 * &lt;/intent-filter&gt;</pre>
414 * <p>The first, primary, purpose of this activity is to let the user interact
415 * with a single note, as decribed by the MIME type
416 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
417 * either VIEW a note or allow the user to EDIT it. Again we support the
418 * DEFAULT category to allow the activity to be launched without explicitly
419 * specifying its component.</p>
420 * <li><pre>
421 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700422 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
423 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
424 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700425 * &lt;/intent-filter&gt;</pre>
426 * <p>The secondary use of this activity is to insert a new note entry into
427 * an existing directory of notes. This is used when the user creates a new
428 * note: the INSERT action is executed on the directory of notes, causing
429 * this activity to run and have the user create the new note data which
430 * it then adds to the content provider.</p>
431 * </ol>
432 *
433 * <p>Given these capabilities, the following intents will resolve to the
434 * NoteEditor activity:</p>
435 *
436 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700437 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * shows the user the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.EDIT
441 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
442 * allows the user to edit the content of note <var>{ID}</var>.</p>
443 * <li> <p><b>{ action=android.app.action.INSERT
444 * data=content://com.google.provider.NotePad/notes }</b>
445 * creates a new, empty note in the notes list at
446 * "content://com.google.provider.NotePad/notes"
447 * and allows the user to edit it. If they keep their changes, the URI
448 * of the newly created note is returned to the caller.</p>
449 * </ul>
450 *
451 * <p>The last activity,
452 * <code>com.android.notepad.TitleEditor</code>, allows the user to
453 * edit the title of a note. This could be implemented as a class that the
454 * application directly invokes (by explicitly setting its component in
455 * the Intent), but here we show a way you can publish alternative
456 * operations on existing data:</p>
457 *
458 * <pre>
459 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700460 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
463 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
464 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700465 * &lt;/intent-filter&gt;</pre>
466 *
467 * <p>In the single intent template here, we
468 * have created our own private action called
469 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
470 * edit the title of a note. It must be invoked on a specific note
471 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
472 * view and edit actions, but here displays and edits the title contained
473 * in the note data.
474 *
475 * <p>In addition to supporting the default category as usual, our title editor
476 * also supports two other standard categories: ALTERNATIVE and
477 * SELECTED_ALTERNATIVE. Implementing
478 * these categories allows others to find the special action it provides
479 * without directly knowing about it, through the
480 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
481 * more often to build dynamic menu items with
482 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
483 * template here was also supply an explicit name for the template
484 * (via <code>android:label="@string/resolve_title"</code>) to better control
485 * what the user sees when presented with this activity as an alternative
486 * action to the data they are viewing.
487 *
488 * <p>Given these capabilities, the following intent will resolve to the
489 * TitleEditor activity:</p>
490 *
491 * <ul>
492 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
493 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
494 * displays and allows the user to edit the title associated
495 * with note <var>{ID}</var>.</p>
496 * </ul>
497 *
498 * <h3>Standard Activity Actions</h3>
499 *
500 * <p>These are the current standard actions that Intent defines for launching
501 * activities (usually through {@link Context#startActivity}. The most
502 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
503 * {@link #ACTION_EDIT}.
504 *
505 * <ul>
506 * <li> {@link #ACTION_MAIN}
507 * <li> {@link #ACTION_VIEW}
508 * <li> {@link #ACTION_ATTACH_DATA}
509 * <li> {@link #ACTION_EDIT}
510 * <li> {@link #ACTION_PICK}
511 * <li> {@link #ACTION_CHOOSER}
512 * <li> {@link #ACTION_GET_CONTENT}
513 * <li> {@link #ACTION_DIAL}
514 * <li> {@link #ACTION_CALL}
515 * <li> {@link #ACTION_SEND}
516 * <li> {@link #ACTION_SENDTO}
517 * <li> {@link #ACTION_ANSWER}
518 * <li> {@link #ACTION_INSERT}
519 * <li> {@link #ACTION_DELETE}
520 * <li> {@link #ACTION_RUN}
521 * <li> {@link #ACTION_SYNC}
522 * <li> {@link #ACTION_PICK_ACTIVITY}
523 * <li> {@link #ACTION_SEARCH}
524 * <li> {@link #ACTION_WEB_SEARCH}
525 * <li> {@link #ACTION_FACTORY_TEST}
526 * </ul>
527 *
528 * <h3>Standard Broadcast Actions</h3>
529 *
530 * <p>These are the current standard actions that Intent defines for receiving
531 * broadcasts (usually through {@link Context#registerReceiver} or a
532 * &lt;receiver&gt; tag in a manifest).
533 *
534 * <ul>
535 * <li> {@link #ACTION_TIME_TICK}
536 * <li> {@link #ACTION_TIME_CHANGED}
537 * <li> {@link #ACTION_TIMEZONE_CHANGED}
538 * <li> {@link #ACTION_BOOT_COMPLETED}
539 * <li> {@link #ACTION_PACKAGE_ADDED}
540 * <li> {@link #ACTION_PACKAGE_CHANGED}
541 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800542 * <li> {@link #ACTION_PACKAGE_RESTARTED}
543 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000544 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
545 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * <li> {@link #ACTION_UID_REMOVED}
547 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700548 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700549 * <li> {@link #ACTION_POWER_DISCONNECTED}
550 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700551 * </ul>
552 *
553 * <h3>Standard Categories</h3>
554 *
555 * <p>These are the current standard categories that can be used to further
556 * clarify an Intent via {@link #addCategory}.
557 *
558 * <ul>
559 * <li> {@link #CATEGORY_DEFAULT}
560 * <li> {@link #CATEGORY_BROWSABLE}
561 * <li> {@link #CATEGORY_TAB}
562 * <li> {@link #CATEGORY_ALTERNATIVE}
563 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
564 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700566 * <li> {@link #CATEGORY_HOME}
567 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700568 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400569 * <li> {@link #CATEGORY_CAR_DOCK}
570 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500571 * <li> {@link #CATEGORY_LE_DESK_DOCK}
572 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200573 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700574 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800575 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700576 * </ul>
577 *
578 * <h3>Standard Extra Data</h3>
579 *
580 * <p>These are the current standard fields that can be used as extra data via
581 * {@link #putExtra}.
582 *
583 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800584 * <li> {@link #EXTRA_ALARM_COUNT}
585 * <li> {@link #EXTRA_BCC}
586 * <li> {@link #EXTRA_CC}
587 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
588 * <li> {@link #EXTRA_DATA_REMOVED}
589 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500590 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
591 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800592 * <li> {@link #EXTRA_DOCK_STATE_CAR}
593 * <li> {@link #EXTRA_DOCK_STATE_DESK}
594 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
595 * <li> {@link #EXTRA_DONT_KILL_APP}
596 * <li> {@link #EXTRA_EMAIL}
597 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700598 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700600 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800601 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700602 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
604 * <li> {@link #EXTRA_REPLACING}
605 * <li> {@link #EXTRA_SHORTCUT_ICON}
606 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
607 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_SHORTCUT_NAME}
610 * <li> {@link #EXTRA_SUBJECT}
611 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800613 * <li> {@link #EXTRA_TITLE}
614 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 * </ul>
616 *
617 * <h3>Flags</h3>
618 *
619 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800620 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
621 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700622 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800623public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700624 private static final String ATTR_ACTION = "action";
625 private static final String TAG_CATEGORIES = "categories";
626 private static final String ATTR_CATEGORY = "category";
627 private static final String TAG_EXTRA = "extra";
628 private static final String ATTR_TYPE = "type";
629 private static final String ATTR_COMPONENT = "component";
630 private static final String ATTR_DATA = "data";
631 private static final String ATTR_FLAGS = "flags";
632
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700633 // ---------------------------------------------------------------------
634 // ---------------------------------------------------------------------
635 // Standard intent activity actions (see action variable).
636
637 /**
638 * Activity Action: Start as a main entry point, does not expect to
639 * receive data.
640 * <p>Input: nothing
641 * <p>Output: nothing
642 */
643 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
644 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700646 /**
647 * Activity Action: Display the data to the user. This is the most common
648 * action performed on data -- it is the generic action you can use on
649 * a piece of data to get the most reasonable thing to occur. For example,
650 * when used on a contacts entry it will view the entry; when used on a
651 * mailto: URI it will bring up a compose window filled with the information
652 * supplied by the URI; when used with a tel: URI it will invoke the
653 * dialer.
654 * <p>Input: {@link #getData} is URI from which to retrieve data.
655 * <p>Output: nothing.
656 */
657 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
658 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 /**
661 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
662 * performed on a piece of data.
663 */
664 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800665
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700666 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900667 * Activity Action: Quick view the data. Launches a quick viewer for
668 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900669 * <p>Activities handling this intent action should handle the vast majority of
670 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700671 * <p>Quick viewers must render the quick view image locally, and must not send
672 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900673 * <p>Input: {@link #getData} is a mandatory content URI of the item to
674 * preview. {@link #getClipData} contains an optional list of content URIs
675 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
676 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700677 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
678 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700679 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900680 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700681 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700682 */
683 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
684 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
685
686 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700687 * Used to indicate that some piece of data should be attached to some other
688 * place. For example, image data could be attached to a contact. It is up
689 * to the recipient to decide where the data should be attached; the intent
690 * does not specify the ultimate destination.
691 * <p>Input: {@link #getData} is URI of data to be attached.
692 * <p>Output: nothing.
693 */
694 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
695 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800696
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700697 /**
698 * Activity Action: Provide explicit editable access to the given data.
699 * <p>Input: {@link #getData} is URI of data to be edited.
700 * <p>Output: nothing.
701 */
702 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
703 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800704
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700705 /**
706 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
707 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
708 * The extras can contain type specific data to pass through to the editing/creating
709 * activity.
710 * <p>Output: The URI of the item that was picked. This must be a content:
711 * URI so that any receiver can access it.
712 */
713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 /**
717 * Activity Action: Pick an item from the data, returning what was selected.
718 * <p>Input: {@link #getData} is URI containing a directory of data
719 * (vnd.android.cursor.dir/*) from which to pick an item.
720 * <p>Output: The URI of the item that was picked.
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800724
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 /**
726 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800727 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800728 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
729 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700730 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
731 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800732 * (value: ShortcutIconResource).</p>
733 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800734 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700735 * @see #EXTRA_SHORTCUT_INTENT
736 * @see #EXTRA_SHORTCUT_NAME
737 * @see #EXTRA_SHORTCUT_ICON
738 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
739 * @see android.content.Intent.ShortcutIconResource
740 */
741 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
742 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
743
744 /**
745 * The name of the extra used to define the Intent of a shortcut.
746 *
747 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800748 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700749 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800750 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700751 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
752 /**
753 * The name of the extra used to define the name of a shortcut.
754 *
755 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800756 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700757 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800758 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
760 /**
761 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
762 *
763 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800764 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700765 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800766 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
768 /**
769 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
770 *
771 * @see #ACTION_CREATE_SHORTCUT
772 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
777 "android.intent.extra.shortcut.ICON_RESOURCE";
778
779 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500780 * An activity that provides a user interface for adjusting application preferences.
781 * Optional but recommended settings for all applications which have settings.
782 */
783 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
784 public static final String ACTION_APPLICATION_PREFERENCES
785 = "android.intent.action.APPLICATION_PREFERENCES";
786
787 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700788 * Activity Action: Launch an activity showing the app information.
789 * For applications which install other applications (such as app stores), it is recommended
790 * to handle this action for providing the app information to the user.
791 *
792 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
793 * to be displayed.
794 * <p>Output: Nothing.
795 */
796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
797 public static final String ACTION_SHOW_APP_INFO
798 = "android.intent.action.SHOW_APP_INFO";
799
800 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800801 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700802 *
803 * @see Intent#ACTION_CREATE_SHORTCUT
804 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800805 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
806 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700807 */
808 public static class ShortcutIconResource implements Parcelable {
809 /**
810 * The package name of the application containing the icon.
811 */
812 public String packageName;
813
814 /**
815 * The resource name of the icon, including package, name and type.
816 */
817 public String resourceName;
818
819 /**
820 * Creates a new ShortcutIconResource for the specified context and resource
821 * identifier.
822 *
823 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700824 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700825 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700826 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700827 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700828 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700829 ShortcutIconResource icon = new ShortcutIconResource();
830 icon.packageName = context.getPackageName();
831 icon.resourceName = context.getResources().getResourceName(resourceId);
832 return icon;
833 }
834
835 /**
836 * Used to read a ShortcutIconResource from a Parcel.
837 */
838 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
839 new Parcelable.Creator<ShortcutIconResource>() {
840
841 public ShortcutIconResource createFromParcel(Parcel source) {
842 ShortcutIconResource icon = new ShortcutIconResource();
843 icon.packageName = source.readString();
844 icon.resourceName = source.readString();
845 return icon;
846 }
847
848 public ShortcutIconResource[] newArray(int size) {
849 return new ShortcutIconResource[size];
850 }
851 };
852
853 /**
854 * No special parcel contents.
855 */
856 public int describeContents() {
857 return 0;
858 }
859
860 public void writeToParcel(Parcel dest, int flags) {
861 dest.writeString(packageName);
862 dest.writeString(resourceName);
863 }
864
865 @Override
866 public String toString() {
867 return resourceName;
868 }
869 }
870
871 /**
872 * Activity Action: Display an activity chooser, allowing the user to pick
873 * what they want to before proceeding. This can be used as an alternative
874 * to the standard activity picker that is displayed by the system when
875 * you try to start an activity with multiple possible matches, with these
876 * differences in behavior:
877 * <ul>
878 * <li>You can specify the title that will appear in the activity chooser.
879 * <li>The user does not have the option to make one of the matching
880 * activities a preferred activity, and all possible activities will
881 * always be shown even if one of them is currently marked as the
882 * preferred activity.
883 * </ul>
884 * <p>
885 * This action should be used when the user will naturally expect to
886 * select an activity in order to proceed. An example if when not to use
887 * it is when the user clicks on a "mailto:" link. They would naturally
888 * expect to go directly to their mail app, so startActivity() should be
889 * called directly: it will
890 * either launch the current preferred app, or put up a dialog allowing the
891 * user to pick an app to use and optionally marking that as preferred.
892 * <p>
893 * In contrast, if the user is selecting a menu item to send a picture
894 * they are viewing to someone else, there are many different things they
895 * may want to do at this point: send it through e-mail, upload it to a
896 * web service, etc. In this case the CHOOSER action should be used, to
897 * always present to the user a list of the things they can do, with a
898 * nice title given by the caller such as "Send this photo with:".
899 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700900 * If you need to grant URI permissions through a chooser, you must specify
901 * the permissions to be granted on the ACTION_CHOOSER Intent
902 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
903 * {@link #setClipData} to specify the URIs to be granted as well as
904 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
905 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
906 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700907 * As a convenience, an Intent of this form can be created with the
908 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700909 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700910 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700911 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
912 * and can optionally have a {@link #EXTRA_TITLE} field containing the
913 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700914 * <p>
915 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700916 */
917 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
918 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
919
920 /**
921 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
922 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700923 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
924 * target intent, also optionally supplying a title. If the target
925 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
926 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
927 * set in the returned chooser intent, with its ClipData set appropriately:
928 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500929 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700930 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700931 * @param target The Intent that the user will be selecting an activity
932 * to perform.
933 * @param title Optional title that will be displayed in the chooser.
934 * @return Return a new Intent object that you can hand to
935 * {@link Context#startActivity(Intent) Context.startActivity()} and
936 * related methods.
937 */
938 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700939 return createChooser(target, title, null);
940 }
941
942 /**
943 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
944 *
945 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
946 * target intent, also optionally supplying a title. If the target
947 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
948 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
949 * set in the returned chooser intent, with its ClipData set appropriately:
950 * either a direct reflection of {@link #getClipData()} if that is non-null,
951 * or a new ClipData built from {@link #getData()}.</p>
952 *
953 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
954 * when the user makes a choice. This can be useful if the calling application wants
955 * to remember the last chosen target and surface it as a more prominent or one-touch
956 * affordance elsewhere in the UI for next time.</p>
957 *
958 * @param target The Intent that the user will be selecting an activity
959 * to perform.
960 * @param title Optional title that will be displayed in the chooser.
961 * @param sender Optional IntentSender to be called when a choice is made.
962 * @return Return a new Intent object that you can hand to
963 * {@link Context#startActivity(Intent) Context.startActivity()} and
964 * related methods.
965 */
966 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700967 Intent intent = new Intent(ACTION_CHOOSER);
968 intent.putExtra(EXTRA_INTENT, target);
969 if (title != null) {
970 intent.putExtra(EXTRA_TITLE, title);
971 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700972
Adam Powell0b3c1122014-10-09 12:50:14 -0700973 if (sender != null) {
974 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
975 }
976
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700977 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700978 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
979 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
980 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700981 if (permFlags != 0) {
982 ClipData targetClipData = target.getClipData();
983 if (targetClipData == null && target.getData() != null) {
984 ClipData.Item item = new ClipData.Item(target.getData());
985 String[] mimeTypes;
986 if (target.getType() != null) {
987 mimeTypes = new String[] { target.getType() };
988 } else {
989 mimeTypes = new String[] { };
990 }
991 targetClipData = new ClipData(null, mimeTypes, item);
992 }
993 if (targetClipData != null) {
994 intent.setClipData(targetClipData);
995 intent.addFlags(permFlags);
996 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700997 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700998
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700999 return intent;
1000 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001001
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001002 /**
1003 * Activity Action: Allow the user to select a particular kind of data and
1004 * return it. This is different than {@link #ACTION_PICK} in that here we
1005 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001006 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001007 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001008 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001009 * etc.
1010 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001011 * 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 -07001012 * of data, such as a person contact, you set the MIME type to the kind of
1013 * data you want and launch it with {@link Context#startActivity(Intent)}.
1014 * The system will then launch the best application to select that kind
1015 * of data for you.
1016 * <p>
1017 * You may also be interested in any of a set of types of content the user
1018 * can pick. For example, an e-mail application that wants to allow the
1019 * user to add an attachment to an e-mail message can use this action to
1020 * bring up a list of all of the types of content the user can attach.
1021 * <p>
1022 * In this case, you should wrap the GET_CONTENT intent with a chooser
1023 * (through {@link #createChooser}), which will give the proper interface
1024 * for the user to pick how to send your data and allow you to specify
1025 * a prompt indicating what they are doing. You will usually specify a
1026 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1027 * broad range of content types the user can select from.
1028 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001029 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001030 * only pick from data that can be represented as a stream. This is
1031 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1032 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001033 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001034 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001035 * is locally available on the device. For example, if this extra is set
1036 * to true then an image picker should not show any pictures that are available
1037 * from a remote server but not already on the local device (thus requiring
1038 * they be downloaded when opened).
1039 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001040 * If the caller can handle multiple returned items (the user performing
1041 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1042 * to indicate this.
1043 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001044 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1045 * that no URI is supplied in the intent, as there are no constraints on
1046 * where the returned data originally comes from. You may also include the
1047 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001048 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001049 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1050 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001051 * <p>
1052 * Output: The URI of the item that was picked. This must be a content:
1053 * URI so that any receiver can access it.
1054 */
1055 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1056 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1057 /**
1058 * Activity Action: Dial a number as specified by the data. This shows a
1059 * UI with the number being dialed, allowing the user to explicitly
1060 * initiate the call.
1061 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1062 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1063 * number.
1064 * <p>Output: nothing.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1068 /**
1069 * Activity Action: Perform a call to someone specified by the data.
1070 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1071 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1072 * number.
1073 * <p>Output: nothing.
1074 *
1075 * <p>Note: there will be restrictions on which applications can initiate a
1076 * call; most applications should use the {@link #ACTION_DIAL}.
1077 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1078 * numbers. Applications can <strong>dial</strong> emergency numbers using
1079 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001080 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001081 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001082 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001083 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001084 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001085 */
1086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1087 public static final String ACTION_CALL = "android.intent.action.CALL";
1088 /**
1089 * Activity Action: Perform a call to an emergency number specified by the
1090 * data.
1091 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1092 * tel: URI of an explicit phone number.
1093 * <p>Output: nothing.
1094 * @hide
1095 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001096 @SystemApi
1097 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001098 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1099 /**
1100 * Activity action: Perform a call to any number (emergency or not)
1101 * specified by the data.
1102 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1103 * tel: URI of an explicit phone number.
1104 * <p>Output: nothing.
1105 * @hide
1106 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001107 @SystemApi
1108 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001109 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001110
Santos Cordon15a13782015-03-31 18:32:31 -07001111 /**
fionaxuadfe7002017-02-17 17:20:46 -08001112 * Activity Action: Main entry point for carrier setup apps.
1113 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1114 * carrier service and typically require
1115 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1116 * fulfill their duties.
1117 */
1118 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1119 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1120 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001121 * Activity Action: Send a message to someone specified by the data.
1122 * <p>Input: {@link #getData} is URI describing the target.
1123 * <p>Output: nothing.
1124 */
1125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1126 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1127 /**
1128 * Activity Action: Deliver some data to someone else. Who the data is
1129 * being delivered to is not specified; it is up to the receiver of this
1130 * action to ask the user where the data should be sent.
1131 * <p>
1132 * When launching a SEND intent, you should usually wrap it in a chooser
1133 * (through {@link #createChooser}), which will give the proper interface
1134 * for the user to pick how to send your data and allow you to specify
1135 * a prompt indicating what they are doing.
1136 * <p>
1137 * Input: {@link #getType} is the MIME type of the data being sent.
1138 * get*Extra can have either a {@link #EXTRA_TEXT}
1139 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1140 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1141 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1142 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001143 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1144 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1145 * your text with HTML formatting.
1146 * <p>
1147 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1148 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1149 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1150 * content: URIs and other advanced features of {@link ClipData}. If
1151 * using this approach, you still must supply the same data through the
1152 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1153 * for compatibility with old applications. If you don't set a ClipData,
1154 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001155 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001156 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1157 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1158 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1159 * be openable only as asset typed files using
1160 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1161 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001162 * Optional standard extras, which may be interpreted by some recipients as
1163 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1164 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1165 * <p>
1166 * Output: nothing.
1167 */
1168 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1169 public static final String ACTION_SEND = "android.intent.action.SEND";
1170 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001171 * Activity Action: Deliver multiple data to someone else.
1172 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001173 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001174 * <p>
1175 * Input: {@link #getType} is the MIME type of the data being sent.
1176 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001177 * #EXTRA_STREAM} field, containing the data to be sent. If using
1178 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1179 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001180 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001181 * Multiple types are supported, and receivers should handle mixed types
1182 * whenever possible. The right way for the receiver to check them is to
1183 * use the content resolver on each URI. The intent sender should try to
1184 * put the most concrete mime type in the intent type, but it can fall
1185 * back to {@literal <type>/*} or {@literal *}/* as needed.
1186 * <p>
1187 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1188 * be image/jpg, but if you are sending image/jpg and image/png, then the
1189 * intent's type should be image/*.
1190 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001191 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1192 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1193 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1194 * content: URIs and other advanced features of {@link ClipData}. If
1195 * using this approach, you still must supply the same data through the
1196 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1197 * for compatibility with old applications. If you don't set a ClipData,
1198 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1199 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001200 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1201 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1202 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1203 * be openable only as asset typed files using
1204 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1205 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001206 * Optional standard extras, which may be interpreted by some recipients as
1207 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1208 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1209 * <p>
1210 * Output: nothing.
1211 */
1212 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1213 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1214 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001215 * Activity Action: Handle an incoming phone call.
1216 * <p>Input: nothing.
1217 * <p>Output: nothing.
1218 */
1219 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1220 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1221 /**
1222 * Activity Action: Insert an empty item into the given container.
1223 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1224 * in which to place the data.
1225 * <p>Output: URI of the new data that was created.
1226 */
1227 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1228 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1229 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001230 * Activity Action: Create a new item in the given container, initializing it
1231 * from the current contents of the clipboard.
1232 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1233 * in which to place the data.
1234 * <p>Output: URI of the new data that was created.
1235 */
1236 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1238 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001239 * Activity Action: Delete the given data from its container.
1240 * <p>Input: {@link #getData} is URI of data to be deleted.
1241 * <p>Output: nothing.
1242 */
1243 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1244 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1245 /**
1246 * Activity Action: Run the data, whatever that means.
1247 * <p>Input: ? (Note: this is currently specific to the test harness.)
1248 * <p>Output: nothing.
1249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_RUN = "android.intent.action.RUN";
1252 /**
1253 * Activity Action: Perform a data synchronization.
1254 * <p>Input: ?
1255 * <p>Output: ?
1256 */
1257 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1258 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1259 /**
1260 * Activity Action: Pick an activity given an intent, returning the class
1261 * selected.
1262 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1263 * used with {@link PackageManager#queryIntentActivities} to determine the
1264 * set of activities from which to pick.
1265 * <p>Output: Class name of the activity that was selected.
1266 */
1267 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1268 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1269 /**
1270 * Activity Action: Perform a search.
1271 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1272 * is the text to search for. If empty, simply
1273 * enter your search results Activity with the search UI activated.
1274 * <p>Output: nothing.
1275 */
1276 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1277 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1278 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001279 * Activity Action: Start the platform-defined tutorial
1280 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1281 * is the text to search for. If empty, simply
1282 * enter your search results Activity with the search UI activated.
1283 * <p>Output: nothing.
1284 */
1285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1286 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1287 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001288 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001289 * <p>
1290 * Input: {@link android.app.SearchManager#QUERY
1291 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1292 * a url starts with http or https, the site will be opened. If it is plain
1293 * text, Google search will be applied.
1294 * <p>
1295 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001296 */
1297 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1298 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001299
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001300 /**
Jim Miller07994402012-05-02 14:22:27 -07001301 * Activity Action: Perform assist action.
1302 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001303 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1304 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001305 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1306 * information.
Jim Miller07994402012-05-02 14:22:27 -07001307 * Output: nothing.
1308 */
1309 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1310 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001311
1312 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001313 * Activity Action: Perform voice assist action.
1314 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001315 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1316 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001317 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001318 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001319 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001320 */
Amith Yamasani16452032017-03-03 10:15:57 -08001321 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001322 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1323 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1324
1325 /**
Adam Skory7140a252013-09-11 12:04:58 +01001326 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1327 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001328 */
1329 public static final String EXTRA_ASSIST_PACKAGE
1330 = "android.intent.extra.ASSIST_PACKAGE";
1331
1332 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001333 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1334 * application package at the time the assist was invoked.
1335 */
1336 public static final String EXTRA_ASSIST_UID
1337 = "android.intent.extra.ASSIST_UID";
1338
1339 /**
Adam Skory7140a252013-09-11 12:04:58 +01001340 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1341 * information supplied by the current foreground app at the time of the assist request.
1342 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001343 */
1344 public static final String EXTRA_ASSIST_CONTEXT
1345 = "android.intent.extra.ASSIST_CONTEXT";
1346
Jim Miller07994402012-05-02 14:22:27 -07001347 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001348 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1349 * keyboard as the primary input device for assistance.
1350 */
1351 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1352 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1353
1354 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001355 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1356 * that was used to invoke the assist.
1357 */
1358 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1359 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1360
1361 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001362 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001363 * <p>Input: Nothing.
1364 * <p>Output: nothing.
1365 */
1366 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1367 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1368 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001369 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001370 * <p>Input: Nothing.
1371 * <p>Output: Nothing.
1372 */
1373 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1374 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1375
1376 /**
1377 * Activity Action: Show activity for reporting a bug.
1378 * <p>Input: Nothing.
1379 * <p>Output: Nothing.
1380 */
1381 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1382 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1383
1384 /**
1385 * Activity Action: Main entry point for factory tests. Only used when
1386 * the device is booting in factory test node. The implementing package
1387 * must be installed in the system image.
1388 * <p>Input: nothing
1389 * <p>Output: nothing
1390 */
1391 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1392
1393 /**
1394 * Activity Action: The user pressed the "call" button to go to the dialer
1395 * or other appropriate UI for placing a call.
1396 * <p>Input: Nothing.
1397 * <p>Output: Nothing.
1398 */
1399 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1400 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1401
1402 /**
1403 * Activity Action: Start Voice Command.
1404 * <p>Input: Nothing.
1405 * <p>Output: Nothing.
1406 */
1407 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1408 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001409
1410 /**
1411 * Activity Action: Start action associated with long pressing on the
1412 * search key.
1413 * <p>Input: Nothing.
1414 * <p>Output: Nothing.
1415 */
1416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1417 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001418
Jacek Surazski86b6c532009-05-13 14:38:28 +02001419 /**
1420 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1421 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001422 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001423 * <p>Input: No data is specified. The bug report is passed in using
1424 * an {@link #EXTRA_BUG_REPORT} field.
1425 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001426 *
1427 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001428 */
1429 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1430 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001431
1432 /**
1433 * Activity Action: Show power usage information to the user.
1434 * <p>Input: Nothing.
1435 * <p>Output: Nothing.
1436 */
1437 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1438 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001439
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001440 /**
1441 * Activity Action: Setup wizard to launch after a platform update. This
1442 * activity should have a string meta-data field associated with it,
1443 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1444 * the platform for setup. The activity will be launched only if
1445 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1446 * same value.
1447 * <p>Input: Nothing.
1448 * <p>Output: Nothing.
1449 * @hide
1450 */
1451 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1452 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001453
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001454 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001455 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1456 * <p>Input: Nothing.
1457 * <p>Output: Nothing.
1458 * @hide
1459 */
1460 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1461 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001462 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001463
1464 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001465 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1466 * <p>Input: Nothing.
1467 * <p>Output: Nothing.
1468 * @hide
1469 */
1470 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1471 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001472 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001473
1474 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001475 * Activity Action: Show settings for managing network data usage of a
1476 * specific application. Applications should define an activity that offers
1477 * options to control data usage.
1478 */
1479 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1480 public static final String ACTION_MANAGE_NETWORK_USAGE =
1481 "android.intent.action.MANAGE_NETWORK_USAGE";
1482
1483 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001484 * Activity Action: Launch application installer.
1485 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001486 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001487 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1488 * you can also use "package:<package-name>" to install an application for the
1489 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001490 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1491 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1492 * <p>
1493 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1494 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001495 * <p>
1496 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1497 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1498 * in order to launch the application installer.
1499 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001500 *
1501 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1502 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1503 * @see #EXTRA_RETURN_RESULT
1504 */
1505 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1506 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1507
1508 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001509 * Activity Action: Launch ephemeral installer.
1510 * <p>
1511 * Input: The data must be a http: URI that the ephemeral application is registered
1512 * to handle.
1513 * <p class="note">
1514 * This is a protected intent that can only be sent by the system.
1515 * </p>
1516 *
1517 * @hide
1518 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001519 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1520 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1521 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1522
1523 /**
1524 * Service Action: Resolve ephemeral application.
1525 * <p>
1526 * The system will have a persistent connection to this service.
1527 * This is a protected intent that can only be sent by the system.
1528 * </p>
1529 *
1530 * @hide
1531 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001532 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1533 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1534 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1535
1536 /**
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001537 * Activity Action: Launch ephemeral settings.
1538 *
1539 * <p class="note">
1540 * This is a protected intent that can only be sent by the system.
1541 * </p>
1542 *
1543 * @hide
1544 */
1545 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1546 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1547 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1548
1549 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001550 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1551 * package. Specifies the installer package name; this package will receive the
1552 * {@link #ACTION_APP_ERROR} intent.
1553 */
1554 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1555 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1556
1557 /**
1558 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1559 * package. Specifies that the application being installed should not be
1560 * treated as coming from an unknown source, but as coming from the app
1561 * invoking the Intent. For this to work you must start the installer with
1562 * startActivityForResult().
1563 */
1564 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1565 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1566
1567 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001568 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1569 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001570 * data field originated from.
1571 */
rich cannings706e8ba2012-08-20 13:20:14 -07001572 public static final String EXTRA_ORIGINATING_URI
1573 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001574
1575 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001576 * This extra can be used with any Intent used to launch an activity, supplying information
1577 * about who is launching that activity. This field contains a {@link android.net.Uri}
1578 * object, typically an http: or https: URI of the web site that the referral came from;
1579 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1580 * a native application that it came from.
1581 *
1582 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1583 * instead of directly retrieving the extra. It is also valid for applications to
1584 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1585 * a string, not a Uri; the field here, if supplied, will always take precedence,
1586 * however.</p>
1587 *
1588 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001589 */
1590 public static final String EXTRA_REFERRER
1591 = "android.intent.extra.REFERRER";
1592
1593 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001594 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1595 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1596 * not be created, in particular when Intent extras are supplied through the
1597 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1598 * schemes.
1599 *
1600 * @see #EXTRA_REFERRER
1601 */
1602 public static final String EXTRA_REFERRER_NAME
1603 = "android.intent.extra.REFERRER_NAME";
1604
1605 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001606 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001607 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001608 * @hide
1609 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001610 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001611 public static final String EXTRA_ORIGINATING_UID
1612 = "android.intent.extra.ORIGINATING_UID";
1613
1614 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001615 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1616 * package. Tells the installer UI to skip the confirmation with the user
1617 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001618 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1619 * will no longer show an interstitial message about updating existing
1620 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001621 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001622 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001623 public static final String EXTRA_ALLOW_REPLACE
1624 = "android.intent.extra.ALLOW_REPLACE";
1625
1626 /**
1627 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1628 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1629 * return to the application the result code of the install/uninstall. The returned result
1630 * code will be {@link android.app.Activity#RESULT_OK} on success or
1631 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1632 */
1633 public static final String EXTRA_RETURN_RESULT
1634 = "android.intent.extra.RETURN_RESULT";
1635
1636 /**
1637 * Package manager install result code. @hide because result codes are not
1638 * yet ready to be exposed.
1639 */
1640 public static final String EXTRA_INSTALL_RESULT
1641 = "android.intent.extra.INSTALL_RESULT";
1642
1643 /**
1644 * Activity Action: Launch application uninstaller.
1645 * <p>
1646 * Input: The data must be a package: URI whose scheme specific part is
1647 * the package name of the current installed package to be uninstalled.
1648 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1649 * <p>
1650 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1651 * succeeded.
1652 */
1653 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1654 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1655
1656 /**
msnider3c191b82017-01-23 14:23:16 -08001657 * Activity Action: Launch application uninstaller.
1658 * <p>
1659 * Input: The data must be a package: URI whose scheme specific part is
1660 * the package name of the current installed package to be uninstalled.
1661 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1662 * <p>
1663 * Output: Nothing.
1664 * </p>
1665 */
1666 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1667 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1668
1669 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001670 * Specify whether the package should be uninstalled for all users.
1671 * @hide because these should not be part of normal application flow.
1672 */
1673 public static final String EXTRA_UNINSTALL_ALL_USERS
1674 = "android.intent.extra.UNINSTALL_ALL_USERS";
1675
1676 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001677 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1678 * describing the last run version of the platform that was setup.
1679 * @hide
1680 */
1681 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1682
Svet Ganov3695b8a2015-03-24 16:30:25 -07001683 /**
1684 * Activity action: Launch UI to manage the permissions of an app.
1685 * <p>
1686 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1687 * will be managed by the launched UI.
1688 * </p>
1689 * <p>
1690 * Output: Nothing.
1691 * </p>
1692 *
1693 * @see #EXTRA_PACKAGE_NAME
1694 *
1695 * @hide
1696 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001697 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001698 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1699 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1700 "android.intent.action.MANAGE_APP_PERMISSIONS";
1701
1702 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001703 * Activity action: Launch UI to manage permissions.
1704 * <p>
1705 * Input: Nothing.
1706 * </p>
1707 * <p>
1708 * Output: Nothing.
1709 * </p>
1710 *
1711 * @hide
1712 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001713 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001714 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1715 public static final String ACTION_MANAGE_PERMISSIONS =
1716 "android.intent.action.MANAGE_PERMISSIONS";
1717
1718 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001719 * Activity action: Launch UI to review permissions for an app.
1720 * The system uses this intent if permission review for apps not
1721 * supporting the new runtime permissions model is enabled. In
1722 * this mode a permission review is required before any of the
1723 * app components can run.
1724 * <p>
1725 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1726 * permissions will be reviewed (mandatory).
1727 * </p>
1728 * <p>
1729 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1730 * be fired after the permission review (optional).
1731 * </p>
1732 * <p>
1733 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1734 * be invoked after the permission review (optional).
1735 * </p>
1736 * <p>
1737 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1738 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1739 * </p>
1740 * <p>
1741 * Output: Nothing.
1742 * </p>
1743 *
1744 * @see #EXTRA_PACKAGE_NAME
1745 * @see #EXTRA_INTENT
1746 * @see #EXTRA_REMOTE_CALLBACK
1747 * @see #EXTRA_RESULT_NEEDED
1748 *
1749 * @hide
1750 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001751 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001752 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1753 public static final String ACTION_REVIEW_PERMISSIONS =
1754 "android.intent.action.REVIEW_PERMISSIONS";
1755
1756 /**
1757 * Intent extra: A callback for reporting remote result as a bundle.
1758 * <p>
1759 * Type: IRemoteCallback
1760 * </p>
1761 *
1762 * @hide
1763 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001764 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001765 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1766
1767 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001768 * Intent extra: An app package name.
1769 * <p>
1770 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001771 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001772 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001773 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001774 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1775
1776 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001777 * Intent extra: An app split name.
1778 * <p>
1779 * Type: String
1780 * </p>
1781 * @hide
1782 */
1783 @SystemApi
1784 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1785
1786 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001787 * Intent extra: An extra for specifying whether a result is needed.
1788 * <p>
1789 * Type: boolean
1790 * </p>
1791 *
1792 * @hide
1793 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001794 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001795 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1796
1797 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001798 * Activity action: Launch UI to manage which apps have a given permission.
1799 * <p>
1800 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1801 * to which will be managed by the launched UI.
1802 * </p>
1803 * <p>
1804 * Output: Nothing.
1805 * </p>
1806 *
1807 * @see #EXTRA_PERMISSION_NAME
1808 *
1809 * @hide
1810 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001811 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001812 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1813 public static final String ACTION_MANAGE_PERMISSION_APPS =
1814 "android.intent.action.MANAGE_PERMISSION_APPS";
1815
1816 /**
1817 * Intent extra: The name of a permission.
1818 * <p>
1819 * Type: String
1820 * </p>
1821 *
1822 * @hide
1823 */
1824 @SystemApi
1825 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1826
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001827 // ---------------------------------------------------------------------
1828 // ---------------------------------------------------------------------
1829 // Standard intent broadcast actions (see action variable).
1830
1831 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001832 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1833 * <p>
1834 * For historical reasons, the name of this broadcast action refers to the power
1835 * state of the screen but it is actually sent in response to changes in the
1836 * overall interactive state of the device.
1837 * </p><p>
1838 * This broadcast is sent when the device becomes non-interactive which may have
1839 * nothing to do with the screen turning off. To determine the
1840 * actual state of the screen, use {@link android.view.Display#getState}.
1841 * </p><p>
1842 * See {@link android.os.PowerManager#isInteractive} for details.
1843 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001844 * You <em>cannot</em> receive this through components declared in
1845 * manifests, only by explicitly registering for it with
1846 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1847 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001848 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001849 * <p class="note">This is a protected intent that can only be sent
1850 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001851 */
1852 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1853 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001854
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001855 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001856 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1857 * <p>
1858 * For historical reasons, the name of this broadcast action refers to the power
1859 * state of the screen but it is actually sent in response to changes in the
1860 * overall interactive state of the device.
1861 * </p><p>
1862 * This broadcast is sent when the device becomes interactive which may have
1863 * nothing to do with the screen turning on. To determine the
1864 * actual state of the screen, use {@link android.view.Display#getState}.
1865 * </p><p>
1866 * See {@link android.os.PowerManager#isInteractive} for details.
1867 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001868 * You <em>cannot</em> receive this through components declared in
1869 * manifests, only by explicitly registering for it with
1870 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1871 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001872 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001873 * <p class="note">This is a protected intent that can only be sent
1874 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001875 */
1876 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1877 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001878
1879 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001880 * Broadcast Action: Sent after the system stops dreaming.
1881 *
1882 * <p class="note">This is a protected intent that can only be sent by the system.
1883 * It is only sent to registered receivers.</p>
1884 */
1885 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1886 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1887
1888 /**
1889 * Broadcast Action: Sent after the system starts dreaming.
1890 *
1891 * <p class="note">This is a protected intent that can only be sent by the system.
1892 * It is only sent to registered receivers.</p>
1893 */
1894 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1895 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1896
1897 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001898 * 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 -07001899 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001900 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001901 * <p class="note">This is a protected intent that can only be sent
1902 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001903 */
1904 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001905 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001906
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001907 /**
1908 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001909 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001910 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001911 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1912 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001913 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001914 * <p class="note">This is a protected intent that can only be sent
1915 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001916 */
1917 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1918 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1919 /**
1920 * Broadcast Action: The time was set.
1921 */
1922 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1923 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1924 /**
1925 * Broadcast Action: The date has changed.
1926 */
1927 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1928 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1929 /**
1930 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1931 * <ul>
1932 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1933 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001934 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001935 * <p class="note">This is a protected intent that can only be sent
1936 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001937 */
1938 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1939 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1940 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001941 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1942 * DNS entries should be tossed.
1943 * @hide
1944 */
1945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1946 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1947 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001948 * Alarm Changed Action: This is broadcast when the AlarmClock
1949 * application's alarm is set or unset. It is used by the
1950 * AlarmClock application and the StatusBar service.
1951 * @hide
1952 */
1953 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1954 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001955
1956 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001957 * Broadcast Action: This is broadcast once, after the user has finished
1958 * booting, but while still in the "locked" state. It can be used to perform
1959 * application-specific initialization, such as installing alarms. You must
1960 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1961 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001962 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001963 * This broadcast is sent immediately at boot by all devices (regardless of
1964 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1965 * higher. Upon receipt of this broadcast, the user is still locked and only
1966 * device-protected storage can be accessed safely. If you want to access
1967 * credential-protected storage, you need to wait for the user to be
1968 * unlocked (typically by entering their lock pattern or PIN for the first
1969 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1970 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1971 * <p>
1972 * To receive this broadcast, your receiver component must be marked as
1973 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001974 * <p class="note">
1975 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001976 *
1977 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001978 */
1979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1980 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1981
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001982 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001983 * Broadcast Action: This is broadcast once, after the user has finished
1984 * booting. It can be used to perform application-specific initialization,
1985 * such as installing alarms. You must hold the
1986 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1987 * order to receive this broadcast.
1988 * <p>
1989 * This broadcast is sent at boot by all devices (both with and without
1990 * direct boot support). Upon receipt of this broadcast, the user is
1991 * unlocked and both device-protected and credential-protected storage can
1992 * accessed safely.
1993 * <p>
1994 * If you need to run while the user is still locked (before they've entered
1995 * their lock pattern or PIN for the first time), you can listen for the
1996 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1997 * <p class="note">
1998 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001999 */
2000 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002001 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002002 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002003
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002004 /**
2005 * Broadcast Action: This is broadcast when a user action should request a
2006 * temporary system dialog to dismiss. Some examples of temporary system
2007 * dialogs are the notification window-shade and the recent tasks dialog.
2008 */
2009 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2010 /**
2011 * Broadcast Action: Trigger the download and eventual installation
2012 * of a package.
2013 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002014 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002015 * <p class="note">This is a protected intent that can only be sent
2016 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002017 *
2018 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002019 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002020 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2022 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2023 /**
2024 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002025 * device. The data contains the name of the package. Note that the
2026 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002027 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002028 * <ul>
2029 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2030 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2031 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2032 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002033 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002034 * <p class="note">This is a protected intent that can only be sent
2035 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002036 */
2037 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2038 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2039 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002040 * Broadcast Action: A new version of an application package has been
2041 * installed, replacing an existing version that was previously installed.
2042 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002043 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002044 * <ul>
2045 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2046 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002047 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002048 * <p class="note">This is a protected intent that can only be sent
2049 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002050 */
2051 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2052 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2053 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002054 * Broadcast Action: A new version of your application has been installed
2055 * over an existing one. This is only sent to the application that was
2056 * replaced. It does not contain any additional data; to receive it, just
2057 * use an intent filter for this action.
2058 *
2059 * <p class="note">This is a protected intent that can only be sent
2060 * by the system.
2061 */
2062 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2063 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2064 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002065 * Broadcast Action: An existing application package has been removed from
2066 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002067 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002068 * <ul>
2069 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2070 * to the package.
2071 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2072 * application -- data and code -- is being removed.
2073 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2074 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2075 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002076 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002077 * <p class="note">This is a protected intent that can only be sent
2078 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002079 */
2080 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2081 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2082 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002083 * Broadcast Action: An existing application package has been completely
2084 * removed from the device. The data contains the name of the package.
2085 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2086 * {@link #EXTRA_DATA_REMOVED} is true and
2087 * {@link #EXTRA_REPLACING} is false of that broadcast.
2088 *
2089 * <ul>
2090 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2091 * to the package.
2092 * </ul>
2093 *
2094 * <p class="note">This is a protected intent that can only be sent
2095 * by the system.
2096 */
2097 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2098 public static final String ACTION_PACKAGE_FULLY_REMOVED
2099 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2100 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002101 * Broadcast Action: An existing application package has been changed (for
2102 * example, a component has been enabled or disabled). The data contains
2103 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002104 * <ul>
2105 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002106 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002107 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002108 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2109 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002110 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002111 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002112 * <p class="note">This is a protected intent that can only be sent
2113 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002114 */
2115 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2116 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2117 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002118 * @hide
2119 * Broadcast Action: Ask system services if there is any reason to
2120 * restart the given package. The data contains the name of the
2121 * package.
2122 * <ul>
2123 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2124 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2125 * </ul>
2126 *
2127 * <p class="note">This is a protected intent that can only be sent
2128 * by the system.
2129 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002130 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002131 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2132 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2133 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002134 * Broadcast Action: The user has restarted a package, and all of its
2135 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002136 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002137 * be removed. Note that the restarted package does <em>not</em>
2138 * receive this broadcast.
2139 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002140 * <ul>
2141 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2142 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002143 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002144 * <p class="note">This is a protected intent that can only be sent
2145 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002146 */
2147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2148 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2149 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002150 * Broadcast Action: The user has cleared the data of a package. This should
2151 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002152 * its persistent data is erased and this broadcast sent.
2153 * Note that the cleared package does <em>not</em>
2154 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002155 * <ul>
2156 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2157 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002158 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002159 * <p class="note">This is a protected intent that can only be sent
2160 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002161 */
2162 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2163 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2164 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002165 * Broadcast Action: Packages have been suspended.
2166 * <p>Includes the following extras:
2167 * <ul>
2168 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2169 * </ul>
2170 *
2171 * <p class="note">This is a protected intent that can only be sent
2172 * by the system. It is only sent to registered receivers.
2173 */
2174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2175 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2176 /**
2177 * Broadcast Action: Packages have been unsuspended.
2178 * <p>Includes the following extras:
2179 * <ul>
2180 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2181 * </ul>
2182 *
2183 * <p class="note">This is a protected intent that can only be sent
2184 * by the system. It is only sent to registered receivers.
2185 */
2186 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2187 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2188 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002189 * Broadcast Action: A user ID has been removed from the system. The user
2190 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002191 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002192 * <p class="note">This is a protected intent that can only be sent
2193 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002194 */
2195 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2196 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002197
2198 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002199 * Broadcast Action: Sent to the installer package of an application when
2200 * that application is first launched (that is the first time it is moved
2201 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002202 *
2203 * <p class="note">This is a protected intent that can only be sent
2204 * by the system.
2205 */
2206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2207 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2208
2209 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002210 * Broadcast Action: Sent to the system package verifier when a package
2211 * needs to be verified. The data contains the package URI.
2212 * <p class="note">
2213 * This is a protected intent that can only be sent by the system.
2214 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002215 */
2216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2217 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2218
2219 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002220 * Broadcast Action: Sent to the system package verifier when a package is
2221 * verified. The data contains the package URI.
2222 * <p class="note">
2223 * This is a protected intent that can only be sent by the system.
2224 */
2225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2227
2228 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002229 * Broadcast Action: Sent to the system intent filter verifier when an
2230 * intent filter needs to be verified. The data contains the filter data
2231 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002232 * <p class="note">
2233 * This is a protected intent that can only be sent by the system.
2234 * </p>
2235 *
2236 * @hide
2237 */
2238 @SystemApi
2239 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2240 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2241
2242 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002243 * Broadcast Action: Resources for a set of packages (which were
2244 * previously unavailable) are currently
2245 * available since the media on which they exist is available.
2246 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2247 * list of packages whose availability changed.
2248 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2249 * list of uids of packages whose availability changed.
2250 * Note that the
2251 * packages in this list do <em>not</em> receive this broadcast.
2252 * The specified set of packages are now available on the system.
2253 * <p>Includes the following extras:
2254 * <ul>
2255 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2256 * whose resources(were previously unavailable) are currently available.
2257 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2258 * packages whose resources(were previously unavailable)
2259 * are currently available.
2260 * </ul>
2261 *
2262 * <p class="note">This is a protected intent that can only be sent
2263 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002264 */
2265 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002266 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2267 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002268
2269 /**
2270 * Broadcast Action: Resources for a set of packages are currently
2271 * unavailable since the media on which they exist is unavailable.
2272 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2273 * list of packages whose availability changed.
2274 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2275 * list of uids of packages whose availability changed.
2276 * The specified set of packages can no longer be
2277 * launched and are practically unavailable on the system.
2278 * <p>Inclues the following extras:
2279 * <ul>
2280 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2281 * whose resources are no longer available.
2282 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2283 * whose resources are no longer available.
2284 * </ul>
2285 *
2286 * <p class="note">This is a protected intent that can only be sent
2287 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002288 */
2289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002290 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002291 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002292
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002293 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002294 * Broadcast Action: preferred activities have changed *explicitly*.
2295 *
2296 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2297 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2298 * be sent.
2299 *
2300 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2301 *
2302 * @hide
2303 */
2304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2305 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2306 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2307
2308
2309 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002310 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002311 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002312 * This should <em>only</em> be used to determine when the wallpaper
2313 * has changed to show the new wallpaper to the user. You should certainly
2314 * never, in response to this, change the wallpaper or other attributes of
2315 * it such as the suggested size. That would be crazy, right? You'd cause
2316 * all kinds of loops, especially if other apps are doing similar things,
2317 * right? Of course. So please don't do this.
2318 *
2319 * @deprecated Modern applications should use
2320 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2321 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2322 * shown behind their UI, rather than watching for this broadcast and
2323 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002324 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002325 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002326 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2327 /**
2328 * Broadcast Action: The current device {@link android.content.res.Configuration}
2329 * (orientation, locale, etc) has changed. When such a change happens, the
2330 * UIs (view hierarchy) will need to be rebuilt based on this new
2331 * information; for the most part, applications don't need to worry about
2332 * this, because the system will take care of stopping and restarting the
2333 * application to make sure it sees the new changes. Some system code that
2334 * can not be restarted will need to watch for this action and handle it
2335 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002336 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002337 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002338 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002339 * in manifests, only by explicitly registering for it with
2340 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2341 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002342 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002343 * <p class="note">This is a protected intent that can only be sent
2344 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002345 *
2346 * @see android.content.res.Configuration
2347 */
2348 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2349 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2350 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002351 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002352 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002353 * <p class="note">This is a protected intent that can only be sent
2354 * by the system.
2355 */
2356 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2357 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2358 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002359 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2360 * charging state, level, and other information about the battery.
2361 * See {@link android.os.BatteryManager} for documentation on the
2362 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002363 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002364 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002365 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002366 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002367 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002368 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2369 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2370 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2371 * broadcasts that are sent and can be received through manifest
2372 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002373 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002374 * <p class="note">This is a protected intent that can only be sent
2375 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002376 */
2377 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2378 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2379 /**
2380 * Broadcast Action: Indicates low battery condition on the device.
2381 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002382 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002383 * <p class="note">This is a protected intent that can only be sent
2384 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002385 */
2386 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2387 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2388 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002389 * Broadcast Action: Indicates the battery is now okay after being low.
2390 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2391 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002392 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002393 * <p class="note">This is a protected intent that can only be sent
2394 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002395 */
2396 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2397 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2398 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002399 * Broadcast Action: External power has been connected to the device.
2400 * This is intended for applications that wish to register specifically to this notification.
2401 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2402 * stay active to receive this notification. This action can be used to implement actions
2403 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002404 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002405 * <p class="note">This is a protected intent that can only be sent
2406 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002407 */
2408 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002409 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002410 /**
2411 * Broadcast Action: External power has been removed from the device.
2412 * This is intended for applications that wish to register specifically to this notification.
2413 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2414 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002415 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002416 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002417 * <p class="note">This is a protected intent that can only be sent
2418 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002419 */
2420 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002421 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002422 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002423 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002424 * Broadcast Action: Device is shutting down.
2425 * This is broadcast when the device is being shut down (completely turned
2426 * off, not sleeping). Once the broadcast is complete, the final shutdown
2427 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002428 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002429 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002430 * <p class="note">This is a protected intent that can only be sent
2431 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002432 * <p>May include the following extras:
2433 * <ul>
2434 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2435 * shutdown is only for userspace processes. If not set, assumed to be false.
2436 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002437 */
2438 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002439 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002440 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002441 * Activity Action: Start this activity to request system shutdown.
2442 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002443 * to request confirmation from the user before shutting down. The optional boolean
2444 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2445 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002446 *
2447 * <p class="note">This is a protected intent that can only be sent
2448 * by the system.
2449 *
2450 * {@hide}
2451 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002452 public static final String ACTION_REQUEST_SHUTDOWN
2453 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002454 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002455 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002456 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002457 * <p class="note">
2458 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002459 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002460 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2461 * or above, this broadcast will no longer be delivered to any
2462 * {@link BroadcastReceiver} defined in your manifest. Instead,
2463 * apps are strongly encouraged to use the improved
2464 * {@link Context#getCacheDir()} behavior so the system can
2465 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 */
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002468 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002469 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2470 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002471 * Broadcast Action: Indicates low storage space condition on the device no
2472 * longer exists
2473 * <p class="note">
2474 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002475 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002476 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2477 * or above, this broadcast will no longer be delivered to any
2478 * {@link BroadcastReceiver} defined in your manifest. Instead,
2479 * apps are strongly encouraged to use the improved
2480 * {@link Context#getCacheDir()} behavior so the system can
2481 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002482 */
2483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002484 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002485 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2486 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002487 * Broadcast Action: A sticky broadcast that indicates a storage space full
2488 * condition on the device. This is intended for activities that want to be
2489 * able to fill the data partition completely, leaving only enough free
2490 * space to prevent system-wide SQLite failures.
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_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2505 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002506 * Broadcast Action: Indicates storage space full condition on the device no
2507 * longer exists.
2508 * <p class="note">
2509 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002510 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002511 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2512 * or above, this broadcast will no longer be delivered to any
2513 * {@link BroadcastReceiver} defined in your manifest. Instead,
2514 * apps are strongly encouraged to use the improved
2515 * {@link Context#getCacheDir()} behavior so the system can
2516 * automatically free up storage when needed.
2517 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002518 */
2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002520 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002521 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2522 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002523 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2524 * and package management should be started.
2525 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2526 * notification.
2527 */
2528 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2529 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2530 /**
2531 * Broadcast Action: The device has entered USB Mass Storage mode.
2532 * This is used mainly for the USB Settings panel.
2533 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2534 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002535 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002536 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002537 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002538 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2539
2540 /**
2541 * Broadcast Action: The device has exited USB Mass Storage mode.
2542 * This is used mainly for the USB Settings panel.
2543 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2544 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002545 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002546 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002547 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002548 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2549
2550 /**
2551 * Broadcast Action: External media has been removed.
2552 * The path to the mount point for the removed media is contained in the Intent.mData field.
2553 */
2554 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2555 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2556
2557 /**
2558 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002559 * 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 -07002560 */
2561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2562 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2563
2564 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002565 * Broadcast Action: External media is present, and being disk-checked
2566 * 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 -08002567 */
2568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2569 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2570
2571 /**
2572 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2573 * 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 -08002574 */
2575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2576 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2577
2578 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002579 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002580 * 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 -07002581 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2582 * media was mounted read only.
2583 */
2584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2585 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2586
2587 /**
2588 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002589 * 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 -07002590 */
2591 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2592 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2593
2594 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002595 * Broadcast Action: External media is no longer being shared via USB mass storage.
2596 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2597 *
2598 * @hide
2599 */
2600 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2601
2602 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002603 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2604 * The path to the mount point for the removed media is contained in the Intent.mData field.
2605 */
2606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2607 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2608
2609 /**
2610 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002611 * 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 -07002612 */
2613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2614 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2615
2616 /**
2617 * Broadcast Action: User has expressed the desire to remove the external storage media.
2618 * Applications should close all files they have open within the mount point when they receive this intent.
2619 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2623
2624 /**
2625 * Broadcast Action: The media scanner has started scanning a directory.
2626 * The path to the directory being scanned is contained in the Intent.mData field.
2627 */
2628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2629 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2630
2631 /**
2632 * Broadcast Action: The media scanner has finished scanning a directory.
2633 * The path to the scanned directory is contained in the Intent.mData field.
2634 */
2635 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2636 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2637
2638 /**
2639 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2640 * The path to the file is contained in the Intent.mData field.
2641 */
2642 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2643 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2644
2645 /**
2646 * Broadcast Action: The "Media Button" was pressed. Includes a single
2647 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2648 * caused the broadcast.
2649 */
2650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2651 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2652
2653 /**
2654 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2655 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2656 * caused the broadcast.
2657 */
2658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2659 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2660
2661 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2662 // location; they are not general-purpose actions.
2663
2664 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002665 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002666 */
2667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2668 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2669 "android.intent.action.GTALK_CONNECTED";
2670
2671 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002672 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002673 */
2674 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2675 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2676 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002677
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002678 /**
2679 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002680 */
2681 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2682 public static final String ACTION_INPUT_METHOD_CHANGED =
2683 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002684
2685 /**
2686 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2687 * more radios have been turned off or on. The intent will have the following extra value:</p>
2688 * <ul>
2689 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2690 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2691 * turned off</li>
2692 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002693 *
Peng Xua35b5532016-01-20 00:05:45 -08002694 * <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 -07002695 */
2696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2697 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2698
2699 /**
2700 * Broadcast Action: Some content providers have parts of their namespace
2701 * where they publish new events or items that the user may be especially
2702 * interested in. For these things, they may broadcast this action when the
2703 * set of interesting items change.
2704 *
2705 * For example, GmailProvider sends this notification when the set of unread
2706 * mail in the inbox changes.
2707 *
2708 * <p>The data of the intent identifies which part of which provider
2709 * changed. When queried through the content resolver, the data URI will
2710 * return the data set in question.
2711 *
2712 * <p>The intent will have the following extra values:
2713 * <ul>
2714 * <li><em>count</em> - The number of items in the data set. This is the
2715 * same as the number of items in the cursor returned by querying the
2716 * data URI. </li>
2717 * </ul>
2718 *
2719 * This intent will be sent at boot (if the count is non-zero) and when the
2720 * data set changes. It is possible for the data set to change without the
2721 * count changing (for example, if a new unread message arrives in the same
2722 * sync operation in which a message is archived). The phone should still
2723 * ring/vibrate/etc as normal in this case.
2724 */
2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2726 public static final String ACTION_PROVIDER_CHANGED =
2727 "android.intent.action.PROVIDER_CHANGED";
2728
2729 /**
2730 * Broadcast Action: Wired Headset plugged in or unplugged.
2731 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002732 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2733 * and documentation.
2734 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002735 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002736 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002737 */
2738 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002739 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002740
2741 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002742 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2743 * <ul>
2744 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2745 * </ul>
2746 *
2747 * <p class="note">This is a protected intent that can only be sent
2748 * by the system.
2749 *
2750 * @hide
2751 */
2752 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2753 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2754 = "android.intent.action.ADVANCED_SETTINGS";
2755
2756 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002757 * Broadcast Action: Sent after application restrictions are changed.
2758 *
2759 * <p class="note">This is a protected intent that can only be sent
2760 * by the system.</p>
2761 */
2762 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2763 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2764 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2765
2766 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767 * Broadcast Action: An outgoing call is about to be placed.
2768 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002769 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002770 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002771 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002772 * the phone number originally intended to be dialed.</li>
2773 * </ul>
2774 * <p>Once the broadcast is finished, the resultData is used as the actual
2775 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002776 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002777 * outgoing call in turn: for example, a parental control application
2778 * might verify that the user is authorized to place the call at that
2779 * time, then a number-rewriting application might add an area code if
2780 * one was not specified.</p>
2781 * <p>For consistency, any receiver whose purpose is to prohibit phone
2782 * calls should have a priority of 0, to ensure it will see the final
2783 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002784 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002785 * should have a positive priority.
2786 * Negative priorities are reserved for the system for this broadcast;
2787 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002788 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2789 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002790 * <p>Emergency calls cannot be intercepted using this mechanism, and
2791 * other calls cannot be modified to call emergency numbers using this
2792 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002793 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2794 * call to use their own service instead. Those apps should first prevent
2795 * the call from being placed by setting resultData to <code>null</code>
2796 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002797 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002798 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2799 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002800 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002801 * <p class="note">This is a protected intent that can only be sent
2802 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002803 */
2804 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2805 public static final String ACTION_NEW_OUTGOING_CALL =
2806 "android.intent.action.NEW_OUTGOING_CALL";
2807
2808 /**
2809 * Broadcast Action: Have the device reboot. This is only for use by
2810 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002811 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002812 * <p class="note">This is a protected intent that can only be sent
2813 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002814 */
2815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2816 public static final String ACTION_REBOOT =
2817 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002818
Wei Huang97ecc9c2009-05-11 17:44:20 -07002819 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002820 * Broadcast Action: A sticky broadcast for changes in the physical
2821 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002822 *
2823 * <p>The intent will have the following extra values:
2824 * <ul>
2825 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002826 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002827 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002828 * <p>This is intended for monitoring the current physical dock state.
2829 * See {@link android.app.UiModeManager} for the normal API dealing with
2830 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002831 */
2832 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2833 public static final String ACTION_DOCK_EVENT =
2834 "android.intent.action.DOCK_EVENT";
2835
2836 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002837 * Broadcast Action: A broadcast when idle maintenance can be started.
2838 * This means that the user is not interacting with the device and is
2839 * not expected to do so soon. Typical use of the idle maintenance is
2840 * to perform somehow expensive tasks that can be postponed at a moment
2841 * when they will not degrade user experience.
2842 * <p>
2843 * <p class="note">In order to keep the device responsive in case of an
2844 * unexpected user interaction, implementations of a maintenance task
2845 * should be interruptible. In such a scenario a broadcast with action
2846 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2847 * should not do the maintenance work in
2848 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2849 * maintenance service by {@link Context#startService(Intent)}. Also
2850 * you should hold a wake lock while your maintenance service is running
2851 * to prevent the device going to sleep.
2852 * </p>
2853 * <p>
2854 * <p class="note">This is a protected intent that can only be sent by
2855 * the system.
2856 * </p>
2857 *
2858 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002859 *
2860 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002861 */
2862 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2863 public static final String ACTION_IDLE_MAINTENANCE_START =
2864 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2865
2866 /**
2867 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2868 * This means that the user was not interacting with the device as a result
2869 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2870 * was sent and now the user started interacting with the device. Typical
2871 * use of the idle maintenance is to perform somehow expensive tasks that
2872 * can be postponed at a moment when they will not degrade user experience.
2873 * <p>
2874 * <p class="note">In order to keep the device responsive in case of an
2875 * unexpected user interaction, implementations of a maintenance task
2876 * should be interruptible. Hence, on receiving a broadcast with this
2877 * action, the maintenance task should be interrupted as soon as possible.
2878 * In other words, you should not do the maintenance work in
2879 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2880 * maintenance service that was started on receiving of
2881 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2882 * lock you acquired when your maintenance service started.
2883 * </p>
2884 * <p class="note">This is a protected intent that can only be sent
2885 * by the system.
2886 *
2887 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002888 *
2889 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002890 */
2891 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2892 public static final String ACTION_IDLE_MAINTENANCE_END =
2893 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2894
2895 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002896 * Broadcast Action: a remote intent is to be broadcasted.
2897 *
2898 * A remote intent is used for remote RPC between devices. The remote intent
2899 * is serialized and sent from one device to another device. The receiving
2900 * device parses the remote intent and broadcasts it. Note that anyone can
2901 * broadcast a remote intent. However, if the intent receiver of the remote intent
2902 * does not trust intent broadcasts from arbitrary intent senders, it should require
2903 * the sender to hold certain permissions so only trusted sender's broadcast will be
2904 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002905 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002906 */
2907 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002908 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002909
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002910 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002911 * Broadcast Action: This is broadcast once when the user is booting after a
2912 * system update. It can be used to perform cleanup or upgrades after a
2913 * system update.
2914 * <p>
2915 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2916 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2917 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2918 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002919 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002920 * @hide
2921 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002922 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002923 public static final String ACTION_PRE_BOOT_COMPLETED =
2924 "android.intent.action.PRE_BOOT_COMPLETED";
2925
Amith Yamasani13593602012-03-22 16:16:17 -07002926 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002927 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002928 * on restricted users. The broadcast intent contains an extra
2929 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2930 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2931 * String[] depending on the restriction type.<p/>
2932 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002933 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2934 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2935 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002936 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2937 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002938 * @see RestrictionEntry
2939 */
2940 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2941 "android.intent.action.GET_RESTRICTION_ENTRIES";
2942
2943 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002944 * Sent the first time a user is starting, to allow system apps to
2945 * perform one time initialization. (This will not be seen by third
2946 * party applications because a newly initialized user does not have any
2947 * third party applications installed for it.) This is sent early in
2948 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002949 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2950 * broadcast, since it is part of a visible user interaction; be as quick
2951 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002952 */
2953 public static final String ACTION_USER_INITIALIZE =
2954 "android.intent.action.USER_INITIALIZE";
2955
2956 /**
2957 * Sent when a user switch is happening, causing the process's user to be
2958 * brought to the foreground. This is only sent to receivers registered
2959 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2960 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002961 * foreground. This is sent as a foreground
2962 * broadcast, since it is part of a visible user interaction; be as quick
2963 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002964 */
2965 public static final String ACTION_USER_FOREGROUND =
2966 "android.intent.action.USER_FOREGROUND";
2967
2968 /**
2969 * Sent when a user switch is happening, causing the process's user to be
2970 * sent to the background. This is only sent to receivers registered
2971 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2972 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002973 * background. This is sent as a foreground
2974 * broadcast, since it is part of a visible user interaction; be as quick
2975 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002976 */
2977 public static final String ACTION_USER_BACKGROUND =
2978 "android.intent.action.USER_BACKGROUND";
2979
2980 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002981 * Broadcast sent to the system when a user is added. Carries an extra
2982 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2983 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002984 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002985 * @hide
2986 */
2987 public static final String ACTION_USER_ADDED =
2988 "android.intent.action.USER_ADDED";
2989
2990 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002991 * Broadcast sent by the system when a user is started. Carries an extra
2992 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002993 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002994 * that has been started. This is sent as a foreground
2995 * broadcast, since it is part of a visible user interaction; be as quick
2996 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002997 * @hide
2998 */
2999 public static final String ACTION_USER_STARTED =
3000 "android.intent.action.USER_STARTED";
3001
3002 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003003 * Broadcast sent when a user is in the process of starting. 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 started). You must hold
3007 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3008 * this broadcast. This is sent as a background broadcast, since
3009 * its result is not part of the primary UX flow; to safely keep track of
3010 * started/stopped state of a user you can use this in conjunction with
3011 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3012 * other user state broadcasts since those are foreground broadcasts so can
3013 * execute in a different order.
3014 * @hide
3015 */
3016 public static final String ACTION_USER_STARTING =
3017 "android.intent.action.USER_STARTING";
3018
3019 /**
3020 * Broadcast sent when a user is going to be stopped. Carries an extra
3021 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3022 * sent to registered receivers, not manifest receivers. It is sent to all
3023 * users (including the one that is being stopped). You must hold
3024 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3025 * this broadcast. The user will not stop until all receivers have
3026 * handled the broadcast. This is sent as a background broadcast, since
3027 * its result is not part of the primary UX flow; to safely keep track of
3028 * started/stopped state of a user you can use this in conjunction with
3029 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3030 * other user state broadcasts since those are foreground broadcasts so can
3031 * execute in a different order.
3032 * @hide
3033 */
3034 public static final String ACTION_USER_STOPPING =
3035 "android.intent.action.USER_STOPPING";
3036
3037 /**
3038 * Broadcast sent to the system when a user is stopped. Carries an extra
3039 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3040 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3041 * specific package. This is only sent to registered receivers, not manifest
3042 * receivers. It is sent to all running users <em>except</em> the one that
3043 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003044 * @hide
3045 */
3046 public static final String ACTION_USER_STOPPED =
3047 "android.intent.action.USER_STOPPED";
3048
3049 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003050 * 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 -07003051 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003052 * one that has been removed. The user will not be completely removed until all receivers have
3053 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003054 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003055 * @hide
3056 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003057 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003058 public static final String ACTION_USER_REMOVED =
3059 "android.intent.action.USER_REMOVED";
3060
3061 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003062 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003063 * the userHandle of the user to become the current one. This is only sent to
3064 * registered receivers, not manifest receivers. It is sent to all running users.
3065 * You must hold
3066 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003067 * @hide
3068 */
3069 public static final String ACTION_USER_SWITCHED =
3070 "android.intent.action.USER_SWITCHED";
3071
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003072 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003073 * Broadcast Action: Sent when the credential-encrypted private storage has
3074 * become unlocked for the target user. This is only sent to registered
3075 * receivers, not manifest receivers.
3076 */
3077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3078 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3079
3080 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003081 * Broadcast sent to the system when a user's information changes. Carries an extra
3082 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003083 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003084 * @hide
3085 */
3086 public static final String ACTION_USER_INFO_CHANGED =
3087 "android.intent.action.USER_INFO_CHANGED";
3088
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003089 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003090 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3091 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003092 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3093 * that need to display merged content across both primary and managed profiles need to
3094 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003095 * not manifest receivers.
3096 */
3097 public static final String ACTION_MANAGED_PROFILE_ADDED =
3098 "android.intent.action.MANAGED_PROFILE_ADDED";
3099
3100 /**
3101 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003102 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3103 * Only applications (for example Launchers) that need to display merged content across both
3104 * primary and managed profiles need to worry about this broadcast. This is only sent to
3105 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003106 */
3107 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3108 "android.intent.action.MANAGED_PROFILE_REMOVED";
3109
3110 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003111 * Broadcast sent to the primary user when the credential-encrypted private storage for
3112 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3113 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3114 * Launchers) that need to display merged content across both primary and managed profiles
3115 * need to worry about this broadcast. This is only sent to registered receivers,
3116 * not manifest receivers.
3117 */
3118 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3119 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3120
3121 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003122 * Broadcast sent to the primary user when an associated managed profile has become available.
3123 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003124 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3125 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3126 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003127 */
Rubin Xue95057a2016-04-01 16:49:25 +01003128 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3129 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3130
3131 /**
3132 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3133 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3134 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3135 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3136 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3137 */
3138 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3139 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003140
3141 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003142 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3143 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3144 * the device was locked or unlocked.
3145 *
3146 * This is only sent to registered receivers.
3147 *
3148 * @hide
3149 */
3150 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3151 "android.intent.action.DEVICE_LOCKED_CHANGED";
3152
3153 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003154 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3155 */
3156 public static final String ACTION_QUICK_CLOCK =
3157 "android.intent.action.QUICK_CLOCK";
3158
Michael Wright0087a142013-02-05 16:29:39 -08003159 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003160 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003161 * @hide
3162 */
3163 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003164 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003165
Justin Kohd378ad72013-04-01 12:18:26 -07003166 /**
3167 * Broadcast Action: A global button was pressed. Includes a single
3168 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3169 * caused the broadcast.
3170 * @hide
3171 */
3172 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3173
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003174 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003175 * Broadcast Action: Sent when media resource is granted.
3176 * <p>
3177 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3178 * granted.
3179 * </p>
3180 * <p class="note">
3181 * This is a protected intent that can only be sent by the system.
3182 * </p>
3183 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003184 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003185 * </p>
3186 *
3187 * @hide
3188 */
3189 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3190 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3191
3192 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003193 * Broadcast Action: An overlay package has been installed. The data
3194 * contains the name of the added overlay package.
3195 * @hide
3196 */
3197 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3198
3199 /**
3200 * Broadcast Action: An overlay package has changed. The data contains the
3201 * name of the overlay package which has changed. This is broadcast on all
3202 * changes to the OverlayInfo returned by {@link
3203 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3204 * most common change is a state change that will change whether the
3205 * overlay is enabled or not.
3206 * @hide
3207 */
3208 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3209
3210 /**
3211 * Broadcast Action: An overlay package has been removed. The data contains
3212 * the name of the overlay package which has been removed.
3213 * @hide
3214 */
3215 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3216
3217 /**
3218 * Broadcast Action: The order of a package's list of overlay packages has
3219 * changed. The data contains the package name of the overlay package that
3220 * had its position in the list adjusted.
3221 * @hide
3222 */
3223 public static final String
3224 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3225
3226 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003227 * Activity Action: Allow the user to select and return one or more existing
3228 * documents. When invoked, the system will display the various
3229 * {@link DocumentsProvider} instances installed on the device, letting the
3230 * user interactively navigate through them. These documents include local
3231 * media, such as photos and video, and documents provided by installed
3232 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003233 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003234 * Each document is represented as a {@code content://} URI backed by a
3235 * {@link DocumentsProvider}, which can be opened as a stream with
3236 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3237 * {@link android.provider.DocumentsContract.Document} metadata.
3238 * <p>
3239 * All selected documents are returned to the calling application with
3240 * persistable read and write permission grants. If you want to maintain
3241 * access to the documents across device reboots, you need to explicitly
3242 * take the persistable permissions using
3243 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3244 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003245 * Callers must indicate the acceptable document MIME types through
3246 * {@link #setType(String)}. For example, to select photos, use
3247 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3248 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3249 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003250 * <p>
3251 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003252 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3253 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003254 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003255 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3256 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003257 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003258 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003259 * Callers can set a document URI through
3260 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3261 * location of documents navigator. System will do its best to launch the
3262 * navigator in the specified document if it's a folder, or the folder that
3263 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003264 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003265 * Output: The URI of the item that was picked, returned in
3266 * {@link #getData()}. This must be a {@code content://} URI so that any
3267 * receiver can access it. If multiple documents were selected, they are
3268 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003269 *
3270 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003271 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003272 * @see #ACTION_CREATE_DOCUMENT
3273 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003274 */
3275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3276 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3277
3278 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003279 * Activity Action: Allow the user to create a new document. When invoked,
3280 * the system will display the various {@link DocumentsProvider} instances
3281 * installed on the device, letting the user navigate through them. The
3282 * returned document may be a newly created document with no content, or it
3283 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003284 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003285 * Each document is represented as a {@code content://} URI backed by a
3286 * {@link DocumentsProvider}, which can be opened as a stream with
3287 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3288 * {@link android.provider.DocumentsContract.Document} metadata.
3289 * <p>
3290 * Callers must indicate the concrete MIME type of the document being
3291 * created by setting {@link #setType(String)}. This MIME type cannot be
3292 * changed after the document is created.
3293 * <p>
3294 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3295 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003296 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003297 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3298 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003299 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003300 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003301 * Callers can set a document URI through
3302 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3303 * location of documents navigator. System will do its best to launch the
3304 * navigator in the specified document if it's a folder, or the folder that
3305 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003306 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003307 * Output: The URI of the item that was created. This must be a
3308 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003309 *
3310 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003311 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003312 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003313 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003314 */
3315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3316 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3317
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003318 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003319 * Activity Action: Allow the user to pick a directory subtree. When
3320 * invoked, the system will display the various {@link DocumentsProvider}
3321 * instances installed on the device, letting the user navigate through
3322 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003323 * <p>
3324 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003325 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3326 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3327 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003328 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003329 * Callers can set a document URI through
3330 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3331 * location of documents navigator. System will do its best to launch the
3332 * navigator in the specified document if it's a folder, or the folder that
3333 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003334 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003335 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003336 *
3337 * @see DocumentsContract
3338 */
3339 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003340 public static final String
3341 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003342
Felipe Lemec7b1f892016-01-15 15:02:31 -08003343 /**
Peng Xua35b5532016-01-20 00:05:45 -08003344 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3345 * exisiting sensor being disconnected.
3346 *
3347 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3348 *
3349 * {@hide}
3350 */
3351 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3352 public static final String
3353 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3354
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003355 /**
3356 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3357 *
3358 * {@hide}
3359 */
3360 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003361 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3362
Christopher Tate6597e342015-02-17 12:15:25 -08003363 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003364 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3365 * is about to be performed.
3366 * @hide
3367 */
3368 @SystemApi
3369 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3370 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3371 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3372
3373 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003374 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3375 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3376 *
3377 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3378 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003379 * @hide
3380 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003381 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003382 public static final String EXTRA_FORCE_MASTER_CLEAR =
3383 "android.intent.extra.FORCE_MASTER_CLEAR";
3384
3385 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003386 * A broadcast action to trigger a factory reset.
3387 *
3388 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3389 *
3390 * <p>Not for use by third-party applications.
3391 *
3392 * @see #EXTRA_FORCE_MASTER_CLEAR
3393 *
3394 * {@hide}
3395 */
3396 @SystemApi
3397 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3398 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3399
3400 /**
3401 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3402 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3403 *
3404 * <p>Not for use by third-party applications.
3405 *
3406 * @hide
3407 */
3408 @SystemApi
3409 public static final String EXTRA_FORCE_FACTORY_RESET =
3410 "android.intent.extra.FORCE_FACTORY_RESET";
3411
3412 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003413 * Broadcast action: report that a settings element is being restored from backup. The intent
3414 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3415 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3416 * is the value of that settings entry prior to the restore operation. All of these values are
3417 * represented as strings.
3418 *
3419 * <p>This broadcast is sent only for settings provider entries known to require special handling
3420 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3421 * the provider's backup agent implementation.
3422 *
3423 * @see #EXTRA_SETTING_NAME
3424 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3425 * @see #EXTRA_SETTING_NEW_VALUE
3426 * {@hide}
3427 */
3428 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3429
3430 /** {@hide} */
3431 public static final String EXTRA_SETTING_NAME = "setting_name";
3432 /** {@hide} */
3433 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3434 /** {@hide} */
3435 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3436
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003437 /**
3438 * Activity Action: Process a piece of text.
3439 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3440 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3441 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3442 */
3443 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3444 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003445
3446 /**
3447 * Broadcast Action: The sim card state has changed.
3448 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3449 * because TelephonyIntents is an internal class.
3450 * @hide
3451 */
3452 @SystemApi
3453 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3454 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3455
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003456 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003457 * The name of the extra used to define the text to be processed, as a
3458 * CharSequence. Note that this may be a styled CharSequence, so you must use
3459 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003460 */
3461 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3462 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003463 * 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 +00003464 */
3465 public static final String EXTRA_PROCESS_TEXT_READONLY =
3466 "android.intent.extra.PROCESS_TEXT_READONLY";
3467
Bryce Leebc58f592015-09-25 16:43:01 -07003468 /**
3469 * Broadcast action: reports when a new thermal event has been reached. When the device
3470 * is reaching its maximum temperatue, the thermal level reported
3471 * {@hide}
3472 */
3473 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3474 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3475
3476 /** {@hide} */
3477 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3478
3479 /**
3480 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003481 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003482 * {@hide}
3483 */
3484 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3485
3486 /**
3487 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003488 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003489 * {@hide}
3490 */
3491 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3492
3493 /**
3494 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003495 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003496 * {@hide}
3497 */
3498 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3499
3500
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003501 // ---------------------------------------------------------------------
3502 // ---------------------------------------------------------------------
3503 // Standard intent categories (see addCategory()).
3504
3505 /**
3506 * Set if the activity should be an option for the default action
3507 * (center press) to perform on a piece of data. Setting this will
3508 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003509 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003510 * Intent when initiating an action -- it is for use in intent filters
3511 * specified in packages.
3512 */
3513 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3514 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3515 /**
3516 * Activities that can be safely invoked from a browser must support this
3517 * category. For example, if the user is viewing a web page or an e-mail
3518 * and clicks on a link in the text, the Intent generated execute that
3519 * link will require the BROWSABLE category, so that only activities
3520 * supporting this category will be considered as possible actions. By
3521 * supporting this category, you are promising that there is nothing
3522 * damaging (without user intervention) that can happen by invoking any
3523 * matching Intent.
3524 */
3525 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3526 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3527 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003528 * Categories for activities that can participate in voice interaction.
3529 * An activity that supports this category must be prepared to run with
3530 * no UI shown at all (though in some case it may have a UI shown), and
3531 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3532 */
3533 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3534 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3535 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003536 * Set if the activity should be considered as an alternative action to
3537 * the data the user is currently viewing. See also
3538 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3539 * applies to the selection in a list of items.
3540 *
3541 * <p>Supporting this category means that you would like your activity to be
3542 * displayed in the set of alternative things the user can do, usually as
3543 * part of the current activity's options menu. You will usually want to
3544 * include a specific label in the &lt;intent-filter&gt; of this action
3545 * describing to the user what it does.
3546 *
3547 * <p>The action of IntentFilter with this category is important in that it
3548 * describes the specific action the target will perform. This generally
3549 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3550 * a specific name such as "com.android.camera.action.CROP. Only one
3551 * alternative of any particular action will be shown to the user, so using
3552 * a specific action like this makes sure that your alternative will be
3553 * displayed while also allowing other applications to provide their own
3554 * overrides of that particular action.
3555 */
3556 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3557 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3558 /**
3559 * Set if the activity should be considered as an alternative selection
3560 * action to the data the user has currently selected. This is like
3561 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3562 * of items from which the user can select, giving them alternatives to the
3563 * default action that will be performed on it.
3564 */
3565 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3566 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3567 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003568 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003569 */
3570 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3571 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3572 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003573 * Should be displayed in the top-level launcher.
3574 */
3575 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3576 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3577 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003578 * Indicates an activity optimized for Leanback mode, and that should
3579 * be displayed in the Leanback launcher.
3580 */
3581 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3582 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3583 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003584 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3585 * @hide
3586 */
3587 @SystemApi
3588 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3589 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003590 * Provides information about the package it is in; typically used if
3591 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3592 * a front-door to the user without having to be shown in the all apps list.
3593 */
3594 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3595 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3596 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003597 * This is the home activity, that is the first activity that is displayed
3598 * when the device boots.
3599 */
3600 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3601 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3602 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003603 * This is the home activity that is displayed when the device is finished setting up and ready
3604 * for use.
3605 * @hide
3606 */
3607 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3608 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3609 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003610 * This is the setup wizard activity, that is the first activity that is displayed
3611 * when the user sets up the device for the first time.
3612 * @hide
3613 */
3614 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3615 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3616 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003617 * This activity is a preference panel.
3618 */
3619 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3620 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3621 /**
3622 * This activity is a development preference panel.
3623 */
3624 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3625 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3626 /**
3627 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003628 */
3629 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3630 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3631 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003632 * This activity allows the user to browse and download new applications.
3633 */
3634 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3635 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3636 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003637 * This activity may be exercised by the monkey or other automated test tools.
3638 */
3639 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3640 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3641 /**
3642 * To be used as a test (not part of the normal user experience).
3643 */
3644 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3645 /**
3646 * To be used as a unit test (run through the Test Harness).
3647 */
3648 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3649 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003650 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003651 * experience).
3652 */
3653 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003654
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003655 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003656 * Used to indicate that an intent only wants URIs that can be opened with
3657 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3658 * must support at least the columns defined in {@link OpenableColumns} when
3659 * queried.
3660 *
3661 * @see #ACTION_GET_CONTENT
3662 * @see #ACTION_OPEN_DOCUMENT
3663 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003664 */
3665 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3666 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3667
3668 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003669 * Used to indicate that an intent filter can accept files which are not necessarily
3670 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3671 * at least streamable via
3672 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3673 * using one of the stream types exposed via
3674 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3675 *
3676 * @see #ACTION_SEND
3677 * @see #ACTION_SEND_MULTIPLE
3678 */
3679 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3680 public static final String CATEGORY_TYPED_OPENABLE =
3681 "android.intent.category.TYPED_OPENABLE";
3682
3683 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003684 * To be used as code under test for framework instrumentation tests.
3685 */
3686 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3687 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003688 /**
3689 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003690 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3691 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003692 */
3693 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3694 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3695 /**
3696 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003697 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3698 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003699 */
3700 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3701 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003702 /**
3703 * An activity to run when device is inserted into a analog (low end) dock.
3704 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3705 * information, see {@link android.app.UiModeManager}.
3706 */
3707 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3708 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3709
3710 /**
3711 * An activity to run when device is inserted into a digital (high end) dock.
3712 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3713 * information, see {@link android.app.UiModeManager}.
3714 */
3715 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3716 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003717
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003718 /**
3719 * Used to indicate that the activity can be used in a car environment.
3720 */
3721 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3722 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3723
Zak Cohendb6ca492017-01-26 14:09:00 -08003724 /**
3725 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3726 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3727 * information, see {@link android.app.UiModeManager}.
3728 */
3729 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3730 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003731 // ---------------------------------------------------------------------
3732 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003733 // Application launch intent categories (see addCategory()).
3734
3735 /**
3736 * Used with {@link #ACTION_MAIN} to launch the browser application.
3737 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003738 * <p>NOTE: This should not be used as the primary key of an Intent,
3739 * since it will not result in the app launching with the correct
3740 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003741 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003742 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003743 */
3744 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3745 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3746
3747 /**
3748 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3749 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003750 * <p>NOTE: This should not be used as the primary key of an Intent,
3751 * since it will not result in the app launching with the correct
3752 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003753 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003754 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003755 */
3756 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3757 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3758
3759 /**
3760 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3761 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003762 * <p>NOTE: This should not be used as the primary key of an Intent,
3763 * since it will not result in the app launching with the correct
3764 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003765 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003766 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003767 */
3768 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3769 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3770
3771 /**
3772 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3773 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003774 * <p>NOTE: This should not be used as the primary key of an Intent,
3775 * since it will not result in the app launching with the correct
3776 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003777 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003778 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003779 */
3780 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3781 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3782
3783 /**
3784 * Used with {@link #ACTION_MAIN} to launch the email application.
3785 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003786 * <p>NOTE: This should not be used as the primary key of an Intent,
3787 * since it will not result in the app launching with the correct
3788 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003789 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003790 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003791 */
3792 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3793 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3794
3795 /**
3796 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3797 * The activity should be able to view and manipulate image and video files
3798 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003799 * <p>NOTE: This should not be used as the primary key of an Intent,
3800 * since it will not result in the app launching with the correct
3801 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003802 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003803 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003804 */
3805 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3806 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3807
3808 /**
3809 * Used with {@link #ACTION_MAIN} to launch the maps application.
3810 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003811 * <p>NOTE: This should not be used as the primary key of an Intent,
3812 * since it will not result in the app launching with the correct
3813 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003814 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003815 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003816 */
3817 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3818 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3819
3820 /**
3821 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3822 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003823 * <p>NOTE: This should not be used as the primary key of an Intent,
3824 * since it will not result in the app launching with the correct
3825 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003826 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003827 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003828 */
3829 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3830 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3831
3832 /**
3833 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003834 * The activity should be able to play, browse, or manipulate music files
3835 * stored on the device.
3836 * <p>NOTE: This should not be used as the primary key of an Intent,
3837 * since it will not result in the app launching with the correct
3838 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003839 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003840 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003841 */
3842 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3843 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3844
3845 // ---------------------------------------------------------------------
3846 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003847 // Standard extra data keys.
3848
3849 /**
3850 * The initial data to place in a newly created record. Use with
3851 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3852 * fields as would be given to the underlying ContentProvider.insert()
3853 * call.
3854 */
3855 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3856
3857 /**
3858 * A constant CharSequence that is associated with the Intent, used with
3859 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3860 * this may be a styled CharSequence, so you must use
3861 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3862 * retrieve it.
3863 */
3864 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3865
3866 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003867 * A constant String that is associated with the Intent, used with
3868 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3869 * as HTML formatted text. Note that you <em>must</em> also supply
3870 * {@link #EXTRA_TEXT}.
3871 */
3872 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3873
3874 /**
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003875 * A content: URI holding a stream of data associated with the Intent, used
3876 * with {@link #ACTION_SEND} to supply the data being sent.
3877 * <p>
3878 * Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this value
3879 * will be automatically promoted to {@link Intent#setClipData(ClipData)}
3880 * when that value is not already defined.
3881 * <p>
3882 * Starting in {@link android.os.Build.VERSION_CODES#O} this value will be
3883 * automatically demoted from {@link Intent#getClipData()} when this value
3884 * is not already defined.
3885 *
3886 * @deprecated apps should use {@link Intent#setClipData(ClipData)} and
3887 * {@link Intent#getClipData()} instead of this extra, since
3888 * only those APIs can extend temporary permission grants to the
3889 * underlying resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003890 */
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003891 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003892 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3893
3894 /**
3895 * A String[] holding e-mail addresses that should be delivered to.
3896 */
3897 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3898
3899 /**
3900 * A String[] holding e-mail addresses that should be carbon copied.
3901 */
3902 public static final String EXTRA_CC = "android.intent.extra.CC";
3903
3904 /**
3905 * A String[] holding e-mail addresses that should be blind carbon copied.
3906 */
3907 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3908
3909 /**
3910 * A constant string holding the desired subject line of a message.
3911 */
3912 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3913
3914 /**
3915 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003916 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003917 */
3918 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3919
3920 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003921 * An int representing the user id to be used.
3922 *
3923 * @hide
3924 */
3925 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3926
3927 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003928 * An int representing the task id to be retrieved. This is used when a launch from recents is
3929 * intercepted by another action such as credentials confirmation to remember which task should
3930 * be resumed when complete.
3931 *
3932 * @hide
3933 */
3934 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3935
3936 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003937 * An Intent[] describing additional, alternate choices you would like shown with
3938 * {@link #ACTION_CHOOSER}.
3939 *
3940 * <p>An app may be capable of providing several different payload types to complete a
3941 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3942 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3943 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3944 * photo data or a hosted link where the photos can be viewed.</p>
3945 *
3946 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3947 * first/primary/preferred intent in the set. Additional intents specified in
3948 * this extra are ordered; by default intents that appear earlier in the array will be
3949 * preferred over intents that appear later in the array as matches for the same
3950 * target component. To alter this preference, a calling app may also supply
3951 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3952 */
3953 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3954
3955 /**
Adam Powell52c39212016-04-07 15:14:18 -07003956 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3957 * and omitted from a list of components presented to the user.
3958 *
3959 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3960 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3961 * from your own package or other apps from your organization if the idea of sending to those
3962 * targets would be redundant with other app functionality. Filtered components will not
3963 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3964 */
3965 public static final String EXTRA_EXCLUDE_COMPONENTS
3966 = "android.intent.extra.EXCLUDE_COMPONENTS";
3967
3968 /**
3969 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3970 * describing additional high-priority deep-link targets for the chooser to present to the user.
3971 *
3972 * <p>Targets provided in this way will be presented inline with all other targets provided
3973 * by services from other apps. They will be prioritized before other service targets, but
3974 * after those targets provided by sources that the user has manually pinned to the front.</p>
3975 *
3976 * @see #ACTION_CHOOSER
3977 */
3978 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3979
3980 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003981 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3982 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3983 *
3984 * <p>An app preparing an action for another app to complete may wish to allow the user to
3985 * disambiguate between several options for completing the action based on the chosen target
3986 * or otherwise refine the action before it is invoked.
3987 * </p>
3988 *
3989 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3990 * <ul>
3991 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3992 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3993 * chosen target beyond the first</li>
3994 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3995 * should fill in and send once the disambiguation is complete</li>
3996 * </ul>
3997 */
3998 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3999 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4000
4001 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004002 * An {@code ArrayList} of {@code String} annotations describing content for
4003 * {@link #ACTION_CHOOSER}.
4004 *
4005 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4006 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4007 *
4008 * <p>Annotations should describe the major components or topics of the content. It is up to
4009 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4010 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4011 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4012 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4013 * use the following annotations when applicable:</p>
4014 * <ul>
4015 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4016 * health & beauty, and office supplies.</li>
4017 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4018 * happy, and sad.</li>
4019 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4020 * face, finger, standing, and walking.</li>
4021 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4022 * child, and baby.</li>
4023 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4024 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4025 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4026 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4027 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4028 * flowers.</li>
4029 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4030 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4031 * sunglasses, jewelry, handbags and clothing.</li>
4032 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4033 * paper, and silk.</li>
4034 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4035 * cars, and boats.</li>
4036 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4037 * posters.</li>
4038 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4039 * and designs of houses.</li>
4040 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4041 * Christmas and Thanksgiving.</li>
4042 * </ul>
4043 */
4044 public static final String EXTRA_CONTENT_ANNOTATIONS
4045 = "android.intent.extra.CONTENT_ANNOTATIONS";
4046
4047 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004048 * A {@link ResultReceiver} used to return data back to the sender.
4049 *
4050 * <p>Used to complete an app-specific
4051 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4052 *
4053 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4054 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4055 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4056 * when the user selects a target component from the chooser. It is up to the recipient
4057 * to send a result to this ResultReceiver to signal that disambiguation is complete
4058 * and that the chooser should invoke the user's choice.</p>
4059 *
4060 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4061 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4062 * to match and fill in the final Intent or ChooserTarget before starting it.
4063 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4064 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4065 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4066 *
4067 * <p>The result code passed to the ResultReceiver should be
4068 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4069 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4070 * the chooser should finish without starting a target.</p>
4071 */
4072 public static final String EXTRA_RESULT_RECEIVER
4073 = "android.intent.extra.RESULT_RECEIVER";
4074
4075 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004076 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004077 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004078 */
4079 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4080
4081 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004082 * A Parcelable[] of {@link Intent} or
4083 * {@link android.content.pm.LabeledIntent} objects as set with
4084 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4085 * a the front of the list of choices, when shown to the user with a
4086 * {@link #ACTION_CHOOSER}.
4087 */
4088 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4089
4090 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004091 * A {@link IntentSender} to start after ephemeral installation success.
4092 * @hide
4093 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004094 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4095
4096 /**
4097 * A {@link IntentSender} to start after ephemeral installation failure.
4098 * @hide
4099 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004100 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4101
4102 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004103 * The host name that triggered an ephemeral resolution.
4104 * @hide
4105 */
4106 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4107
4108 /**
4109 * An opaque token to track ephemeral resolution.
4110 * @hide
4111 */
4112 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4113
4114 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004115 * The version code of the app to install components from.
4116 * @hide
4117 */
4118 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4119
4120 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004121 * A Bundle forming a mapping of potential target package names to different extras Bundles
4122 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4123 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4124 * be currently installed on the device.
4125 *
4126 * <p>An application may choose to provide alternate extras for the case where a user
4127 * selects an activity from a predetermined set of target packages. If the activity
4128 * the user selects from the chooser belongs to a package with its package name as
4129 * a key in this bundle, the corresponding extras for that package will be merged with
4130 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4131 * extra has the same key as an extra already present in the intent it will overwrite
4132 * the extra from the intent.</p>
4133 *
4134 * <p><em>Examples:</em>
4135 * <ul>
4136 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4137 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4138 * parameters for that target.</li>
4139 * <li>An application may offer additional metadata for known targets of a given intent
4140 * to pass along information only relevant to that target such as account or content
4141 * identifiers already known to that application.</li>
4142 * </ul></p>
4143 */
4144 public static final String EXTRA_REPLACEMENT_EXTRAS =
4145 "android.intent.extra.REPLACEMENT_EXTRAS";
4146
4147 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004148 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4149 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4150 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4151 * {@link ComponentName} of the chosen component.
4152 *
4153 * <p>In some situations this callback may never come, for example if the user abandons
4154 * the chooser, switches to another task or any number of other reasons. Apps should not
4155 * be written assuming that this callback will always occur.</p>
4156 */
4157 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4158 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4159
4160 /**
4161 * The {@link ComponentName} chosen by the user to complete an action.
4162 *
4163 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4164 */
4165 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4166
4167 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004168 * A {@link android.view.KeyEvent} object containing the event that
4169 * triggered the creation of the Intent it is in.
4170 */
4171 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4172
4173 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004174 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4175 * before shutting down.
4176 *
4177 * {@hide}
4178 */
4179 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4180
4181 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004182 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4183 * requested by the user.
4184 *
4185 * {@hide}
4186 */
4187 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4188 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4189
4190 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004191 * 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 -07004192 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4193 * of restarting the application.
4194 */
4195 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4196
4197 /**
4198 * A String holding the phone number originally entered in
4199 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4200 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4201 */
4202 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004204 /**
4205 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4206 * intents to supply the uid the package had been assigned. Also an optional
4207 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4208 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4209 * purpose.
4210 */
4211 public static final String EXTRA_UID = "android.intent.extra.UID";
4212
4213 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004214 * @hide String array of package names.
4215 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004216 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004217 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4218
4219 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004220 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4221 * intents to indicate whether this represents a full uninstall (removing
4222 * both the code and its data) or a partial uninstall (leaving its data,
4223 * implying that this is an update).
4224 */
4225 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004226
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004227 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004228 * @hide
4229 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4230 * intents to indicate that at this point the package has been removed for
4231 * all users on the device.
4232 */
4233 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4234 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4235
4236 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004237 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4238 * intents to indicate that this is a replacement of the package, so this
4239 * broadcast will immediately be followed by an add broadcast for a
4240 * different version of the same package.
4241 */
4242 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004243
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004244 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004245 * Used as an int extra field in {@link android.app.AlarmManager} intents
4246 * to tell the application being invoked how many pending alarms are being
4247 * delievered with the intent. For one-shot alarms this will always be 1.
4248 * For recurring alarms, this might be greater than 1 if the device was
4249 * asleep or powered off at the time an earlier alarm would have been
4250 * delivered.
4251 */
4252 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004253
Jacek Surazski86b6c532009-05-13 14:38:28 +02004254 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004255 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4256 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004257 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4258 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004259 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4260 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4261 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004262 */
4263 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4264
4265 /**
4266 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4267 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004268 */
4269 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4270
4271 /**
4272 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4273 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004274 */
4275 public static final int EXTRA_DOCK_STATE_DESK = 1;
4276
4277 /**
4278 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4279 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004280 */
4281 public static final int EXTRA_DOCK_STATE_CAR = 2;
4282
4283 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004284 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4285 * to represent that the phone is in a analog (low end) dock.
4286 */
4287 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4288
4289 /**
4290 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4291 * to represent that the phone is in a digital (high end) dock.
4292 */
4293 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4294
4295 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004296 * Boolean that can be supplied as meta-data with a dock activity, to
4297 * indicate that the dock should take over the home key when it is active.
4298 */
4299 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004300
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004301 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004302 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4303 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004304 */
4305 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4306
4307 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004308 * Used in the extra field in the remote intent. It's astring token passed with the
4309 * remote intent.
4310 */
4311 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4312 "android.intent.extra.remote_intent_token";
4313
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004314 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004315 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004316 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004317 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004318 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004319 "android.intent.extra.changed_component_name";
4320
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004321 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004322 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004323 * and contains a string array of all of the components that have changed. If
4324 * the state of the overall package has changed, then it will contain an entry
4325 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004326 */
4327 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4328 "android.intent.extra.changed_component_name_list";
4329
4330 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004331 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004332 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004333 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4334 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4335 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004336 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004337 */
4338 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4339 "android.intent.extra.changed_package_list";
4340
4341 /**
4342 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004343 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4344 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004345 * and contains an integer array of uids of all of the components
4346 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004347 */
4348 public static final String EXTRA_CHANGED_UID_LIST =
4349 "android.intent.extra.changed_uid_list";
4350
4351 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004352 * @hide
4353 * Magic extra system code can use when binding, to give a label for
4354 * who it is that has bound to a service. This is an integer giving
4355 * a framework string resource that can be displayed to the user.
4356 */
4357 public static final String EXTRA_CLIENT_LABEL =
4358 "android.intent.extra.client_label";
4359
4360 /**
4361 * @hide
4362 * Magic extra system code can use when binding, to give a PendingIntent object
4363 * that can be launched for the user to disable the system's use of this
4364 * service.
4365 */
4366 public static final String EXTRA_CLIENT_INTENT =
4367 "android.intent.extra.client_intent";
4368
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004369 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004370 * Extra used to indicate that an intent should only return data that is on
4371 * the local device. This is a boolean extra; the default is false. If true,
4372 * an implementation should only allow the user to select data that is
4373 * already on the device, not requiring it be downloaded from a remote
4374 * service when opened.
4375 *
4376 * @see #ACTION_GET_CONTENT
4377 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004378 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004379 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004380 */
4381 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004382 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004383
Amith Yamasani13593602012-03-22 16:16:17 -07004384 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004385 * Extra used to indicate that an intent can allow the user to select and
4386 * return multiple items. This is a boolean extra; the default is false. If
4387 * true, an implementation is allowed to present the user with a UI where
4388 * they can pick multiple items that are all returned to the caller. When
4389 * this happens, they should be returned as the {@link #getClipData()} part
4390 * of the result Intent.
4391 *
4392 * @see #ACTION_GET_CONTENT
4393 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004394 */
4395 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004396 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004397
4398 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004399 * The integer userHandle carried with broadcast intents related to addition, removal and
4400 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4401 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4402 *
Amith Yamasani13593602012-03-22 16:16:17 -07004403 * @hide
4404 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004405 public static final String EXTRA_USER_HANDLE =
4406 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004407
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004408 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004409 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4410 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4411 */
4412 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004413 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004414
4415 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004416 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004417 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4418 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004419 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004420 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4421
4422 /**
4423 * Extra sent in the intent to the BroadcastReceiver that handles
4424 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4425 * the restrictions as key/value pairs.
4426 */
4427 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4428 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004429
Amith Yamasani86118ba2013-03-28 14:33:16 -07004430 /**
4431 * Extra used in the response from a BroadcastReceiver that handles
4432 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4433 */
4434 public static final String EXTRA_RESTRICTIONS_INTENT =
4435 "android.intent.extra.restrictions_intent";
4436
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004437 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004438 * Extra used to communicate a set of acceptable MIME types. The type of the
4439 * extra is {@code String[]}. Values may be a combination of concrete MIME
4440 * types (such as "image/png") and/or partial MIME types (such as
4441 * "audio/*").
4442 *
4443 * @see #ACTION_GET_CONTENT
4444 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004445 */
4446 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4447
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004448 /**
4449 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4450 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004451 * When this is true, hardware devices can use this information to determine that
4452 * they shouldn't do a complete shutdown of their device since this is not a
4453 * complete shutdown down to the kernel, but only user space restarting.
4454 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004455 */
4456 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4457 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4458
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004459 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004460 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4461 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4462 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4463 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004464 *
4465 * @hide for internal use only.
4466 */
4467 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4468 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004469 /** @hide */
4470 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4471 /** @hide */
4472 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4473 /** @hide */
4474 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004475
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004476 /** {@hide} */
4477 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4478
Rubin Xue8490f12015-06-25 12:17:48 +01004479 /** {@hide} */
4480 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4481
Santos Cordon15a13782015-03-31 18:32:31 -07004482 /**
4483 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4484 * activation request.
4485 * TODO: Add information about the structure and response data used with the pending intent.
4486 * @hide
4487 */
4488 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4489 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4490
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004491 /**
4492 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004493 *
4494 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004495 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004496 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004497 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4498
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004499 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004500 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4501 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4502 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004503 *
4504 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004505 * @see #ACTION_QUICK_VIEW
4506 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004507 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004508 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004509 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4510 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004511
4512 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004513 * An optional extra of {@code String[]} indicating which quick view features should be made
4514 * available to the user in the quick view UI while handing a
4515 * {@link Intent#ACTION_QUICK_VIEW} intent.
4516 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4517 * Quick viewer can implement features not listed below.
4518 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4519 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4520 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4521 * <p>
4522 * Requirements:
4523 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4524 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4525 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4526 * internal policies.
4527 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4528 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4529 * disable or hide features.
4530 *
4531 * @see #ACTION_QUICK_VIEW
4532 */
4533 public static final String EXTRA_QUICK_VIEW_FEATURES =
4534 "android.intent.extra.QUICK_VIEW_FEATURES";
4535
4536 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004537 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004538 * When a profile goes into quiet mode, all apps in the profile are killed and the
4539 * profile user is stopped. Widgets originating from the profile are masked, and app
4540 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004541 */
4542 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004543
4544 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004545 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004546 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004547 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4548 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004549 *
4550 * @hide
4551 */
4552 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4553 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4554
4555 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004556 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4557 * whether to show the chooser or not when there is only one application available
4558 * to choose from.
4559 *
4560 * @hide
4561 */
4562 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4563 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4564
4565 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004566 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004567 * to represent that a video codec is allowed to use.
4568 *
4569 * @hide
4570 */
4571 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4572
4573 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004574 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004575 * to represent that a audio codec is allowed to use.
4576 *
4577 * @hide
4578 */
4579 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4580
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004581 // ---------------------------------------------------------------------
4582 // ---------------------------------------------------------------------
4583 // Intent flags (see mFlags variable).
4584
Tor Norbyed9273d62013-05-30 15:59:53 -07004585 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004586 @IntDef(flag = true, value = {
4587 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4588 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004589 @Retention(RetentionPolicy.SOURCE)
4590 public @interface GrantUriMode {}
4591
Jeff Sharkey846318a2014-04-04 12:12:41 -07004592 /** @hide */
4593 @IntDef(flag = true, value = {
4594 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4595 @Retention(RetentionPolicy.SOURCE)
4596 public @interface AccessUriMode {}
4597
4598 /**
4599 * Test if given mode flags specify an access mode, which must be at least
4600 * read and/or write.
4601 *
4602 * @hide
4603 */
4604 public static boolean isAccessUriMode(int modeFlags) {
4605 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4606 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4607 }
4608
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004609 /**
4610 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004611 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004612 * specified in its ClipData. When applying to an Intent's ClipData,
4613 * all URIs as well as recursive traversals through data or other ClipData
4614 * in Intent items will be granted; only the grant flags of the top-level
4615 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004616 */
4617 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4618 /**
4619 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004620 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004621 * specified in its ClipData. When applying to an Intent's ClipData,
4622 * all URIs as well as recursive traversals through data or other ClipData
4623 * in Intent items will be granted; only the grant flags of the top-level
4624 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004625 */
4626 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4627 /**
4628 * Can be set by the caller to indicate that this Intent is coming from
4629 * a background operation, not from direct user interaction.
4630 */
4631 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4632 /**
4633 * A flag you can enable for debugging: when set, log messages will be
4634 * printed during the resolution of this intent to show you what has
4635 * been found to create the final resolved list.
4636 */
4637 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004638 /**
4639 * If set, this intent will not match any components in packages that
4640 * are currently stopped. If this is not set, then the default behavior
4641 * is to include such applications in the result.
4642 */
4643 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4644 /**
4645 * If set, this intent will always match any components in packages that
4646 * are currently stopped. This is the default behavior when
4647 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4648 * flags are set, this one wins (it allows overriding of exclude for
4649 * places where the framework may automatically set the exclude flag).
4650 */
4651 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004652
4653 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004654 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004655 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004656 * persisted across device reboots until explicitly revoked with
4657 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4658 * grant for possible persisting; the receiving application must call
4659 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4660 * actually persist.
4661 *
4662 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4663 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4664 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004665 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004666 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004667 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004668
4669 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004670 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4671 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4672 * applies to any URI that is a prefix match against the original granted
4673 * URI. (Without this flag, the URI must match exactly for access to be
4674 * granted.) Another URI is considered a prefix match only when scheme,
4675 * authority, and all path segments defined by the prefix are an exact
4676 * match.
4677 */
4678 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4679
4680 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004681 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004682 * homework and verified that they correctly handle packages and components
4683 * that come and go over time. In particular:
4684 * <ul>
4685 * <li>Apps installed on external storage, which will appear to be
4686 * uninstalled while the the device is ejected.
4687 * <li>Apps with encryption unaware components, which will appear to not
4688 * exist while the device is locked.
4689 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004690 *
4691 * @hide
4692 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004693 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004694
4695 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004696 * Internal flag used to indicate ephemeral applications should not be
4697 * considered when resolving the intent.
4698 *
4699 * @hide
4700 */
4701 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4702
4703 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004704 * If set, the new activity is not kept in the history stack. As soon as
4705 * the user navigates away from it, the activity is finished. This may also
4706 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4707 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004708 *
4709 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4710 * is never invoked when the current activity starts a new activity which
4711 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004712 */
4713 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4714 /**
4715 * If set, the activity will not be launched if it is already running
4716 * at the top of the history stack.
4717 */
4718 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4719 /**
4720 * If set, this activity will become the start of a new task on this
4721 * history stack. A task (from the activity that started it to the
4722 * next task activity) defines an atomic group of activities that the
4723 * user can move to. Tasks can be moved to the foreground and background;
4724 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004725 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004726 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4727 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004728 *
4729 * <p>This flag is generally used by activities that want
4730 * to present a "launcher" style behavior: they give the user a list of
4731 * separate things that can be done, which otherwise run completely
4732 * independently of the activity launching them.
4733 *
4734 * <p>When using this flag, if a task is already running for the activity
4735 * you are now starting, then a new activity will not be started; instead,
4736 * the current task will simply be brought to the front of the screen with
4737 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4738 * to disable this behavior.
4739 *
4740 * <p>This flag can not be used when the caller is requesting a result from
4741 * the activity being launched.
4742 */
4743 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4744 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004745 * This flag is used to create a new task and launch an activity into it.
4746 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4747 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4748 * search through existing tasks for ones matching this Intent. Only if no such
4749 * task is found would a new task be created. When paired with
4750 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4751 * the search for a matching task and unconditionally start a new task.
4752 *
4753 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4754 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004755 * top-level application launcher.</strong> Used in conjunction with
4756 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4757 * behavior of bringing an existing task to the foreground. When set,
4758 * a new task is <em>always</em> started to host the Activity for the
4759 * Intent, regardless of whether there is already an existing task running
4760 * the same thing.
4761 *
4762 * <p><strong>Because the default system does not include graphical task management,
4763 * you should not use this flag unless you provide some way for a user to
4764 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004765 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004766 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4767 * creating new document tasks.
4768 *
4769 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004770 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004771 *
Scott Main7aee61f2011-02-08 11:25:01 -08004772 * <p>See
4773 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4774 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004775 *
4776 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4777 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004778 */
4779 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4780 /**
4781 * If set, and the activity being launched is already running in the
4782 * current task, then instead of launching a new instance of that activity,
4783 * all of the other activities on top of it will be closed and this Intent
4784 * will be delivered to the (now on top) old activity as a new Intent.
4785 *
4786 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4787 * If D calls startActivity() with an Intent that resolves to the component
4788 * of activity B, then C and D will be finished and B receive the given
4789 * Intent, resulting in the stack now being: A, B.
4790 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004791 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004792 * either receive the new intent you are starting here in its
4793 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004794 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004795 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4796 * the same intent, then it will be finished and re-created; for all other
4797 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4798 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004799 *
4800 * <p>This launch mode can also be used to good effect in conjunction with
4801 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4802 * of a task, it will bring any currently running instance of that task
4803 * to the foreground, and then clear it to its root state. This is
4804 * especially useful, for example, when launching an activity from the
4805 * notification manager.
4806 *
Scott Main7aee61f2011-02-08 11:25:01 -08004807 * <p>See
4808 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4809 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004810 */
4811 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4812 /**
4813 * If set and this intent is being used to launch a new activity from an
4814 * existing one, then the reply target of the existing activity will be
4815 * transfered to the new activity. This way the new activity can call
4816 * {@link android.app.Activity#setResult} and have that result sent back to
4817 * the reply target of the original activity.
4818 */
4819 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4820 /**
4821 * If set and this intent is being used to launch a new activity from an
4822 * existing one, the current activity will not be counted as the top
4823 * activity for deciding whether the new intent should be delivered to
4824 * the top instead of starting a new one. The previous activity will
4825 * be used as the top, with the assumption being that the current activity
4826 * will finish itself immediately.
4827 */
4828 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4829 /**
4830 * If set, the new activity is not kept in the list of recently launched
4831 * activities.
4832 */
4833 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4834 /**
4835 * This flag is not normally set by application code, but set for you by
4836 * the system as described in the
4837 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4838 * launchMode} documentation for the singleTask mode.
4839 */
4840 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4841 /**
4842 * If set, and this activity is either being started in a new task or
4843 * bringing to the top an existing task, then it will be launched as
4844 * the front door of the task. This will result in the application of
4845 * any affinities needed to have that task in the proper state (either
4846 * moving activities to or from it), or simply resetting that task to
4847 * its initial state if needed.
4848 */
4849 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4850 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004851 * This flag is not normally set by application code, but set for you by
4852 * the system if this activity is being launched from history
4853 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004854 */
4855 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004856 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004857 * @deprecated As of API 21 this performs identically to
4858 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004859 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004860 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004861 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004862 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004863 * This flag is used to open a document into a new task rooted at the activity launched
4864 * by this Intent. Through the use of this flag, or its equivalent attribute,
4865 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004866 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004867 *
Craig Mautner026596b2014-05-21 15:35:44 -07004868 * <p>The use of the activity attribute form of this,
4869 * {@link android.R.attr#documentLaunchMode}, is
4870 * preferred over the Intent flag described here. The attribute form allows the
4871 * Activity to specify multiple document behavior for all launchers of the Activity
4872 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004873 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004874 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4875 * it is kept after the activity is finished is different than the use of
4876 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4877 * this flag is being used to create a new recents entry, then by default that entry
4878 * will be removed once the activity is finished. You can modify this behavior with
4879 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4880 *
Craig Mautner026596b2014-05-21 15:35:44 -07004881 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4882 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4883 * equivalent of the Activity manifest specifying {@link
4884 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4885 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4886 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004887 *
Craig Mautner026596b2014-05-21 15:35:44 -07004888 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004889 *
Craig Mautner026596b2014-05-21 15:35:44 -07004890 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004891 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4892 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004893 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004894 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004895 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004896 * callback from occurring on the current frontmost activity before it is
4897 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004898 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004899 * <p>Typically, an activity can rely on that callback to indicate that an
4900 * explicit user action has caused their activity to be moved out of the
4901 * foreground. The callback marks an appropriate point in the activity's
4902 * lifecycle for it to dismiss any notifications that it intends to display
4903 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004904 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004905 * <p>If an activity is ever started via any non-user-driven events such as
4906 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4907 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004908 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004909 */
4910 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004911 /**
4912 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4913 * this flag will cause the launched activity to be brought to the front of its
4914 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004915 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004916 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4917 * If D calls startActivity() with an Intent that resolves to the component
4918 * of activity B, then B will be brought to the front of the history stack,
4919 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004920 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004921 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004922 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004923 */
4924 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004925 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004926 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4927 * this flag will prevent the system from applying an activity transition
4928 * animation to go to the next activity state. This doesn't mean an
4929 * animation will never run -- if another activity change happens that doesn't
4930 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004931 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004932 * when you are going to do a series of activity operations but the
4933 * animation seen by the user shouldn't be driven by the first activity
4934 * change but rather a later one.
4935 */
4936 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4937 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004938 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4939 * this flag will cause any existing task that would be associated with the
4940 * activity to be cleared before the activity is started. That is, the activity
4941 * becomes the new root of an otherwise empty task, and any old activities
4942 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4943 */
4944 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4945 /**
4946 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4947 * this flag will cause a newly launching task to be placed on top of the current
4948 * home activity task (if there is one). That is, pressing back from the task
4949 * will always return the user to home even if that was not the last activity they
4950 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4951 */
4952 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4953 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004954 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4955 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004956 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004957 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004958 * this flag. When set and the task's activity is finished, the recents
4959 * entry will remain in the interface for the user to re-launch it, like a
4960 * recents entry for a top-level application.
4961 * <p>
4962 * The receiving activity can override this request with
4963 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4964 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004965 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004966 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004967 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004968
4969 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004970 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4971 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004972 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4973 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004974 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004975 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004976
4977 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004978 * If set, when sending a broadcast only registered receivers will be
4979 * called -- no BroadcastReceiver components will be launched.
4980 */
4981 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004982 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004983 * If set, when sending a broadcast the new broadcast will replace
4984 * any existing pending broadcast that matches it. Matching is defined
4985 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4986 * true for the intents of the two broadcasts. When a match is found,
4987 * the new broadcast (and receivers associated with it) will replace the
4988 * existing one in the pending broadcast list, remaining at the same
4989 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004990 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004991 * <p>This flag is most typically used with sticky broadcasts, which
4992 * only care about delivering the most recent values of the broadcast
4993 * to their receivers.
4994 */
4995 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4996 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004997 * If set, when sending a broadcast the recipient is allowed to run at
4998 * foreground priority, with a shorter timeout interval. During normal
4999 * broadcasts the receivers are not automatically hoisted out of the
5000 * background priority class.
5001 */
5002 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5003 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005004 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5005 * They can still propagate results through to later receivers, but they can not prevent
5006 * later receivers from seeing the broadcast.
5007 */
5008 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5009 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005010 * If set, when sending a broadcast <i>before boot has completed</i> only
5011 * registered receivers will be called -- no BroadcastReceiver components
5012 * will be launched. Sticky intent state will be recorded properly even
5013 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5014 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005015 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005016 * <p>This flag is only for use by system sevices as a convenience to
5017 * avoid having to implement a more complex mechanism around detection
5018 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005019 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005020 * @hide
5021 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005022 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005023 /**
5024 * Set when this broadcast is for a boot upgrade, a special mode that
5025 * allows the broadcast to be sent before the system is ready and launches
5026 * the app process with no providers running in it.
5027 * @hide
5028 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005029 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005030 /**
5031 * If set, the broadcast will always go to manifest receivers in background (cached
5032 * or not running) apps, regardless of whether that would be done by default. By
5033 * default they will only receive broadcasts if the broadcast has specified an
5034 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005035 *
5036 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5037 * the broadcast code there must also be changed to match.
5038 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005039 * @hide
5040 */
5041 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5042 /**
5043 * If set, the broadcast will never go to manifest receivers in background (cached
5044 * or not running) apps, regardless of whether that would be done by default. By
5045 * default they will receive broadcasts if the broadcast has specified an
5046 * explicit component or package name.
5047 * @hide
5048 */
5049 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005050 /**
5051 * If set, this broadcast is being sent from the shell.
5052 * @hide
5053 */
5054 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005055
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005056 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005057 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5058 * will not receive broadcasts.
5059 *
5060 * <em>This flag has no effect when used by an Instant App.</em>
5061 */
5062 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5063
5064 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005065 * @hide Flags that can't be changed with PendingIntent.
5066 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005067 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5068 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5069 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005070
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005071 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005072 // ---------------------------------------------------------------------
5073 // toUri() and parseUri() options.
5074
5075 /**
5076 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5077 * always has the "intent:" scheme. This syntax can be used when you want
5078 * to later disambiguate between URIs that are intended to describe an
5079 * Intent vs. all others that should be treated as raw URIs. When used
5080 * with {@link #parseUri}, any other scheme will result in a generic
5081 * VIEW action for that raw URI.
5082 */
5083 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005084
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005085 /**
5086 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5087 * always has the "android-app:" scheme. This is a variation of
5088 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5089 * http/https URI being delivered to a specific package name. The format
5090 * is:
5091 *
5092 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005093 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005094 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005095 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5096 * you must also include a scheme; including a path also requires both a host and a scheme.
5097 * The final #Intent; fragment can be used without a scheme, host, or path.
5098 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005099 * used with intents that have a {@link #setSelector}, since the base intent
5100 * will always have an explicit package name.</p>
5101 *
5102 * <p>Some examples of how this scheme maps to Intent objects:</p>
5103 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5104 * <colgroup align="left" />
5105 * <colgroup align="left" />
5106 * <thead>
5107 * <tr><th>URI</th> <th>Intent</th></tr>
5108 * </thead>
5109 *
5110 * <tbody>
5111 * <tr><td><code>android-app://com.example.app</code></td>
5112 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5113 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5114 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5115 * </table></td>
5116 * </tr>
5117 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5118 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5119 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5120 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5121 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5122 * </table></td>
5123 * </tr>
5124 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5125 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5126 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5127 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5128 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5129 * </table></td>
5130 * </tr>
5131 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5132 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5133 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5134 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5135 * </table></td>
5136 * </tr>
5137 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5138 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5139 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5140 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5141 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5142 * </table></td>
5143 * </tr>
5144 * <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>
5145 * <td><table border="" style="margin:0" >
5146 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5147 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5148 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5149 * </table></td>
5150 * </tr>
5151 * </tbody>
5152 * </table>
5153 */
5154 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5155
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005156 /**
5157 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5158 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5159 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5160 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5161 * generated Intent can not cause unexpected data access to happen.
5162 *
5163 * <p>If you do not trust the source of the URI being parsed, you should still do further
5164 * processing to protect yourself from it. In particular, when using it to start an
5165 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5166 * that can handle it.</p>
5167 */
5168 public static final int URI_ALLOW_UNSAFE = 1<<2;
5169
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005170 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005171
5172 private String mAction;
5173 private Uri mData;
5174 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005175 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005176 private ComponentName mComponent;
5177 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005178 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005179 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005180 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005181 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005182 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005183 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005184 /** Token to track instant app launches. Local only; do not copy cross-process. */
5185 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005186
5187 // ---------------------------------------------------------------------
5188
5189 /**
5190 * Create an empty intent.
5191 */
5192 public Intent() {
5193 }
5194
5195 /**
5196 * Copy constructor.
5197 */
5198 public Intent(Intent o) {
5199 this.mAction = o.mAction;
5200 this.mData = o.mData;
5201 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005202 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005203 this.mComponent = o.mComponent;
5204 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005205 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005206 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005207 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005208 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005209 }
5210 if (o.mExtras != null) {
5211 this.mExtras = new Bundle(o.mExtras);
5212 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005213 if (o.mSourceBounds != null) {
5214 this.mSourceBounds = new Rect(o.mSourceBounds);
5215 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005216 if (o.mSelector != null) {
5217 this.mSelector = new Intent(o.mSelector);
5218 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005219 if (o.mClipData != null) {
5220 this.mClipData = new ClipData(o.mClipData);
5221 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005222 }
5223
5224 @Override
5225 public Object clone() {
5226 return new Intent(this);
5227 }
5228
5229 private Intent(Intent o, boolean all) {
5230 this.mAction = o.mAction;
5231 this.mData = o.mData;
5232 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005233 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005234 this.mComponent = o.mComponent;
5235 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005236 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005237 }
5238 }
5239
5240 /**
5241 * Make a clone of only the parts of the Intent that are relevant for
5242 * filter matching: the action, data, type, component, and categories.
5243 */
5244 public Intent cloneFilter() {
5245 return new Intent(this, false);
5246 }
5247
5248 /**
5249 * Create an intent with a given action. All other fields (data, type,
5250 * class) are null. Note that the action <em>must</em> be in a
5251 * namespace because Intents are used globally in the system -- for
5252 * example the system VIEW action is android.intent.action.VIEW; an
5253 * application's custom action would be something like
5254 * com.google.app.myapp.CUSTOM_ACTION.
5255 *
5256 * @param action The Intent action, such as ACTION_VIEW.
5257 */
5258 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005259 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005260 }
5261
5262 /**
5263 * Create an intent with a given action and for a given data url. Note
5264 * that the action <em>must</em> be in a namespace because Intents are
5265 * used globally in the system -- for example the system VIEW action is
5266 * android.intent.action.VIEW; an application's custom action would be
5267 * something like com.google.app.myapp.CUSTOM_ACTION.
5268 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005269 * <p><em>Note: scheme and host name matching in the Android framework is
5270 * case-sensitive, unlike the formal RFC. As a result,
5271 * you should always ensure that you write your Uri with these elements
5272 * using lower case letters, and normalize any Uris you receive from
5273 * outside of Android to ensure the scheme and host is lower case.</em></p>
5274 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005275 * @param action The Intent action, such as ACTION_VIEW.
5276 * @param uri The Intent data URI.
5277 */
5278 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005279 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005280 mData = uri;
5281 }
5282
5283 /**
5284 * Create an intent for a specific component. All other fields (action, data,
5285 * type, class) are null, though they can be modified later with explicit
5286 * calls. This provides a convenient way to create an intent that is
5287 * intended to execute a hard-coded class name, rather than relying on the
5288 * system to find an appropriate class for you; see {@link #setComponent}
5289 * for more information on the repercussions of this.
5290 *
5291 * @param packageContext A Context of the application package implementing
5292 * this class.
5293 * @param cls The component class that is to be used for the intent.
5294 *
5295 * @see #setClass
5296 * @see #setComponent
5297 * @see #Intent(String, android.net.Uri , Context, Class)
5298 */
5299 public Intent(Context packageContext, Class<?> cls) {
5300 mComponent = new ComponentName(packageContext, cls);
5301 }
5302
5303 /**
5304 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005305 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005306 * construct the Intent and then calling {@link #setClass} to set its
5307 * class.
5308 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005309 * <p><em>Note: scheme and host name matching in the Android framework is
5310 * case-sensitive, unlike the formal RFC. As a result,
5311 * you should always ensure that you write your Uri with these elements
5312 * using lower case letters, and normalize any Uris you receive from
5313 * outside of Android to ensure the scheme and host is lower case.</em></p>
5314 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005315 * @param action The Intent action, such as ACTION_VIEW.
5316 * @param uri The Intent data URI.
5317 * @param packageContext A Context of the application package implementing
5318 * this class.
5319 * @param cls The component class that is to be used for the intent.
5320 *
5321 * @see #Intent(String, android.net.Uri)
5322 * @see #Intent(Context, Class)
5323 * @see #setClass
5324 * @see #setComponent
5325 */
5326 public Intent(String action, Uri uri,
5327 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005328 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005329 mData = uri;
5330 mComponent = new ComponentName(packageContext, cls);
5331 }
5332
5333 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005334 * Create an intent to launch the main (root) activity of a task. This
5335 * is the Intent that is started when the application's is launched from
5336 * Home. For anything else that wants to launch an application in the
5337 * same way, it is important that they use an Intent structured the same
5338 * way, and can use this function to ensure this is the case.
5339 *
5340 * <p>The returned Intent has the given Activity component as its explicit
5341 * component, {@link #ACTION_MAIN} as its action, and includes the
5342 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5343 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5344 * to do that through {@link #addFlags(int)} on the returned Intent.
5345 *
5346 * @param mainActivity The main activity component that this Intent will
5347 * launch.
5348 * @return Returns a newly created Intent that can be used to launch the
5349 * activity as a main application entry.
5350 *
5351 * @see #setClass
5352 * @see #setComponent
5353 */
5354 public static Intent makeMainActivity(ComponentName mainActivity) {
5355 Intent intent = new Intent(ACTION_MAIN);
5356 intent.setComponent(mainActivity);
5357 intent.addCategory(CATEGORY_LAUNCHER);
5358 return intent;
5359 }
5360
5361 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005362 * Make an Intent for the main activity of an application, without
5363 * specifying a specific activity to run but giving a selector to find
5364 * the activity. This results in a final Intent that is structured
5365 * the same as when the application is launched from
5366 * Home. For anything else that wants to launch an application in the
5367 * same way, it is important that they use an Intent structured the same
5368 * way, and can use this function to ensure this is the case.
5369 *
5370 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5371 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5372 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5373 * to do that through {@link #addFlags(int)} on the returned Intent.
5374 *
5375 * @param selectorAction The action name of the Intent's selector.
5376 * @param selectorCategory The name of a category to add to the Intent's
5377 * selector.
5378 * @return Returns a newly created Intent that can be used to launch the
5379 * activity as a main application entry.
5380 *
5381 * @see #setSelector(Intent)
5382 */
5383 public static Intent makeMainSelectorActivity(String selectorAction,
5384 String selectorCategory) {
5385 Intent intent = new Intent(ACTION_MAIN);
5386 intent.addCategory(CATEGORY_LAUNCHER);
5387 Intent selector = new Intent();
5388 selector.setAction(selectorAction);
5389 selector.addCategory(selectorCategory);
5390 intent.setSelector(selector);
5391 return intent;
5392 }
5393
5394 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005395 * Make an Intent that can be used to re-launch an application's task
5396 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5397 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5398 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5399 *
5400 * @param mainActivity The activity component that is the root of the
5401 * task; this is the activity that has been published in the application's
5402 * manifest as the main launcher icon.
5403 *
5404 * @return Returns a newly created Intent that can be used to relaunch the
5405 * activity's task in its root state.
5406 */
5407 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5408 Intent intent = makeMainActivity(mainActivity);
5409 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5410 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5411 return intent;
5412 }
5413
5414 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005415 * Call {@link #parseUri} with 0 flags.
5416 * @deprecated Use {@link #parseUri} instead.
5417 */
5418 @Deprecated
5419 public static Intent getIntent(String uri) throws URISyntaxException {
5420 return parseUri(uri, 0);
5421 }
Tom Taylord4a47292009-12-21 13:59:18 -08005422
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005423 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005424 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005425 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005426 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005427 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005428 *
5429 * <p>The URI given here must not be relative -- that is, it must include
5430 * the scheme and full path.
5431 *
5432 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005433 * @param flags Additional processing flags. Either 0,
5434 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005435 *
5436 * @return Intent The newly created Intent object.
5437 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005438 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5439 * it bad (as parsed by the Uri class) or the Intent data within the
5440 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005441 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005442 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005443 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005444 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005445 int i = 0;
5446 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005447 final boolean androidApp = uri.startsWith("android-app:");
5448
5449 // Validate intent scheme if requested.
5450 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5451 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005452 Intent intent = new Intent(ACTION_VIEW);
5453 try {
5454 intent.setData(Uri.parse(uri));
5455 } catch (IllegalArgumentException e) {
5456 throw new URISyntaxException(uri, e.getMessage());
5457 }
5458 return intent;
5459 }
5460 }
Tom Taylord4a47292009-12-21 13:59:18 -08005461
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005462 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005463 // simple case
5464 if (i == -1) {
5465 if (!androidApp) {
5466 return new Intent(ACTION_VIEW, Uri.parse(uri));
5467 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005468
5469 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005470 } else if (!uri.startsWith("#Intent;", i)) {
5471 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005472 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005473 } else {
5474 i = -1;
5475 }
5476 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005477
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005478 // new format
5479 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005480 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005481 boolean explicitAction = false;
5482 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005483
5484 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005485 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005486 String data;
5487 if (i >= 0) {
5488 data = uri.substring(0, i);
5489 i += 8; // length of "#Intent;"
5490 } else {
5491 data = uri;
5492 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005493
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005494 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005495 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005496 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005497 if (eq < 0) eq = i-1;
5498 int semi = uri.indexOf(';', i);
5499 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005500
5501 // action
5502 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005503 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005504 if (!inSelector) {
5505 explicitAction = true;
5506 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005507 }
5508
5509 // categories
5510 else if (uri.startsWith("category=", i)) {
5511 intent.addCategory(value);
5512 }
5513
5514 // type
5515 else if (uri.startsWith("type=", i)) {
5516 intent.mType = value;
5517 }
5518
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005519 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005520 else if (uri.startsWith("launchFlags=", i)) {
5521 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005522 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5523 intent.mFlags &= ~IMMUTABLE_FLAGS;
5524 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005525 }
5526
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005527 // package
5528 else if (uri.startsWith("package=", i)) {
5529 intent.mPackage = value;
5530 }
5531
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005532 // component
5533 else if (uri.startsWith("component=", i)) {
5534 intent.mComponent = ComponentName.unflattenFromString(value);
5535 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005536
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005537 // scheme
5538 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005539 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005540 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005541 } else {
5542 scheme = value;
5543 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005544 }
5545
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005546 // source bounds
5547 else if (uri.startsWith("sourceBounds=", i)) {
5548 intent.mSourceBounds = Rect.unflattenFromString(value);
5549 }
5550
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005551 // selector
5552 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5553 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005554 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005555 }
5556
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005557 // extra
5558 else {
5559 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005560 // create Bundle if it doesn't already exist
5561 if (intent.mExtras == null) intent.mExtras = new Bundle();
5562 Bundle b = intent.mExtras;
5563 // add EXTRA
5564 if (uri.startsWith("S.", i)) b.putString(key, value);
5565 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5566 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5567 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5568 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5569 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5570 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5571 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5572 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5573 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5574 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005575
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005576 // move to the next item
5577 i = semi + 1;
5578 }
5579
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005580 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005581 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005582 if (baseIntent.mPackage == null) {
5583 baseIntent.setSelector(intent);
5584 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005585 intent = baseIntent;
5586 }
5587
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005588 if (data != null) {
5589 if (data.startsWith("intent:")) {
5590 data = data.substring(7);
5591 if (scheme != null) {
5592 data = scheme + ':' + data;
5593 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005594 } else if (data.startsWith("android-app:")) {
5595 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5596 // Correctly formed android-app, first part is package name.
5597 int end = data.indexOf('/', 14);
5598 if (end < 0) {
5599 // All we have is a package name.
5600 intent.mPackage = data.substring(14);
5601 if (!explicitAction) {
5602 intent.setAction(ACTION_MAIN);
5603 }
5604 data = "";
5605 } else {
5606 // Target the Intent at the given package name always.
5607 String authority = null;
5608 intent.mPackage = data.substring(14, end);
5609 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005610 if ((end+1) < data.length()) {
5611 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5612 // Found a scheme, remember it.
5613 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005614 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005615 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5616 // Found a authority, remember it.
5617 authority = data.substring(end+1, newEnd);
5618 end = newEnd;
5619 }
5620 } else {
5621 // All we have is a scheme.
5622 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005623 }
5624 }
5625 if (scheme == null) {
5626 // If there was no scheme, then this just targets the package.
5627 if (!explicitAction) {
5628 intent.setAction(ACTION_MAIN);
5629 }
5630 data = "";
5631 } else if (authority == null) {
5632 data = scheme + ":";
5633 } else {
5634 data = scheme + "://" + authority + data.substring(end);
5635 }
5636 }
5637 } else {
5638 data = "";
5639 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005640 }
Tom Taylord4a47292009-12-21 13:59:18 -08005641
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005642 if (data.length() > 0) {
5643 try {
5644 intent.mData = Uri.parse(data);
5645 } catch (IllegalArgumentException e) {
5646 throw new URISyntaxException(uri, e.getMessage());
5647 }
5648 }
5649 }
Tom Taylord4a47292009-12-21 13:59:18 -08005650
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005651 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005652
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005653 } catch (IndexOutOfBoundsException e) {
5654 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5655 }
5656 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005658 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005659 return getIntentOld(uri, 0);
5660 }
5661
5662 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005663 Intent intent;
5664
5665 int i = uri.lastIndexOf('#');
5666 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005667 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005668 final int intentFragmentStart = i;
5669 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005670
5671 i++;
5672
5673 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005674 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005675 i += 7;
5676 int j = uri.indexOf(')', i);
5677 action = uri.substring(i, j);
5678 i = j + 1;
5679 }
5680
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005681 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005682
5683 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005684 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005685 i += 11;
5686 int j = uri.indexOf(')', i);
5687 while (i < j) {
5688 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005689 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005690 if (i < sep) {
5691 intent.addCategory(uri.substring(i, sep));
5692 }
5693 i = sep + 1;
5694 }
5695 i = j + 1;
5696 }
5697
5698 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005699 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005700 i += 5;
5701 int j = uri.indexOf(')', i);
5702 intent.mType = uri.substring(i, j);
5703 i = j + 1;
5704 }
5705
5706 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005707 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005708 i += 12;
5709 int j = uri.indexOf(')', i);
5710 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005711 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5712 intent.mFlags &= ~IMMUTABLE_FLAGS;
5713 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005714 i = j + 1;
5715 }
5716
5717 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005718 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005719 i += 10;
5720 int j = uri.indexOf(')', i);
5721 int sep = uri.indexOf('!', i);
5722 if (sep >= 0 && sep < j) {
5723 String pkg = uri.substring(i, sep);
5724 String cls = uri.substring(sep + 1, j);
5725 intent.mComponent = new ComponentName(pkg, cls);
5726 }
5727 i = j + 1;
5728 }
5729
5730 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005731 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005732 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005734 final int closeParen = uri.indexOf(')', i);
5735 if (closeParen == -1) throw new URISyntaxException(uri,
5736 "EXTRA missing trailing ')'", i);
5737
5738 while (i < closeParen) {
5739 // fetch the key value
5740 int j = uri.indexOf('=', i);
5741 if (j <= i + 1 || i >= closeParen) {
5742 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5743 }
5744 char type = uri.charAt(i);
5745 i++;
5746 String key = uri.substring(i, j);
5747 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005748
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005749 // get type-value
5750 j = uri.indexOf('!', i);
5751 if (j == -1 || j >= closeParen) j = closeParen;
5752 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5753 String value = uri.substring(i, j);
5754 i = j;
5755
5756 // create Bundle if it doesn't already exist
5757 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005758
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005759 // add item to bundle
5760 try {
5761 switch (type) {
5762 case 'S':
5763 intent.mExtras.putString(key, Uri.decode(value));
5764 break;
5765 case 'B':
5766 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5767 break;
5768 case 'b':
5769 intent.mExtras.putByte(key, Byte.parseByte(value));
5770 break;
5771 case 'c':
5772 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5773 break;
5774 case 'd':
5775 intent.mExtras.putDouble(key, Double.parseDouble(value));
5776 break;
5777 case 'f':
5778 intent.mExtras.putFloat(key, Float.parseFloat(value));
5779 break;
5780 case 'i':
5781 intent.mExtras.putInt(key, Integer.parseInt(value));
5782 break;
5783 case 'l':
5784 intent.mExtras.putLong(key, Long.parseLong(value));
5785 break;
5786 case 's':
5787 intent.mExtras.putShort(key, Short.parseShort(value));
5788 break;
5789 default:
5790 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5791 }
5792 } catch (NumberFormatException e) {
5793 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5794 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005795
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005796 char ch = uri.charAt(i);
5797 if (ch == ')') break;
5798 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5799 i++;
5800 }
5801 }
5802
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005803 if (isIntentFragment) {
5804 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5805 } else {
5806 intent.mData = Uri.parse(uri);
5807 }
Tom Taylord4a47292009-12-21 13:59:18 -08005808
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005809 if (intent.mAction == null) {
5810 // By default, if no action is specified, then use VIEW.
5811 intent.mAction = ACTION_VIEW;
5812 }
5813
5814 } else {
5815 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5816 }
5817
5818 return intent;
5819 }
5820
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005821 /** @hide */
5822 public interface CommandOptionHandler {
5823 boolean handleOption(String opt, ShellCommand cmd);
5824 }
5825
5826 /** @hide */
5827 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5828 throws URISyntaxException {
5829 Intent intent = new Intent();
5830 Intent baseIntent = intent;
5831 boolean hasIntentInfo = false;
5832
5833 Uri data = null;
5834 String type = null;
5835
5836 String opt;
5837 while ((opt=cmd.getNextOption()) != null) {
5838 switch (opt) {
5839 case "-a":
5840 intent.setAction(cmd.getNextArgRequired());
5841 if (intent == baseIntent) {
5842 hasIntentInfo = true;
5843 }
5844 break;
5845 case "-d":
5846 data = Uri.parse(cmd.getNextArgRequired());
5847 if (intent == baseIntent) {
5848 hasIntentInfo = true;
5849 }
5850 break;
5851 case "-t":
5852 type = cmd.getNextArgRequired();
5853 if (intent == baseIntent) {
5854 hasIntentInfo = true;
5855 }
5856 break;
5857 case "-c":
5858 intent.addCategory(cmd.getNextArgRequired());
5859 if (intent == baseIntent) {
5860 hasIntentInfo = true;
5861 }
5862 break;
5863 case "-e":
5864 case "--es": {
5865 String key = cmd.getNextArgRequired();
5866 String value = cmd.getNextArgRequired();
5867 intent.putExtra(key, value);
5868 }
5869 break;
5870 case "--esn": {
5871 String key = cmd.getNextArgRequired();
5872 intent.putExtra(key, (String) null);
5873 }
5874 break;
5875 case "--ei": {
5876 String key = cmd.getNextArgRequired();
5877 String value = cmd.getNextArgRequired();
5878 intent.putExtra(key, Integer.decode(value));
5879 }
5880 break;
5881 case "--eu": {
5882 String key = cmd.getNextArgRequired();
5883 String value = cmd.getNextArgRequired();
5884 intent.putExtra(key, Uri.parse(value));
5885 }
5886 break;
5887 case "--ecn": {
5888 String key = cmd.getNextArgRequired();
5889 String value = cmd.getNextArgRequired();
5890 ComponentName cn = ComponentName.unflattenFromString(value);
5891 if (cn == null)
5892 throw new IllegalArgumentException("Bad component name: " + value);
5893 intent.putExtra(key, cn);
5894 }
5895 break;
5896 case "--eia": {
5897 String key = cmd.getNextArgRequired();
5898 String value = cmd.getNextArgRequired();
5899 String[] strings = value.split(",");
5900 int[] list = new int[strings.length];
5901 for (int i = 0; i < strings.length; i++) {
5902 list[i] = Integer.decode(strings[i]);
5903 }
5904 intent.putExtra(key, list);
5905 }
5906 break;
5907 case "--eial": {
5908 String key = cmd.getNextArgRequired();
5909 String value = cmd.getNextArgRequired();
5910 String[] strings = value.split(",");
5911 ArrayList<Integer> list = new ArrayList<>(strings.length);
5912 for (int i = 0; i < strings.length; i++) {
5913 list.add(Integer.decode(strings[i]));
5914 }
5915 intent.putExtra(key, list);
5916 }
5917 break;
5918 case "--el": {
5919 String key = cmd.getNextArgRequired();
5920 String value = cmd.getNextArgRequired();
5921 intent.putExtra(key, Long.valueOf(value));
5922 }
5923 break;
5924 case "--ela": {
5925 String key = cmd.getNextArgRequired();
5926 String value = cmd.getNextArgRequired();
5927 String[] strings = value.split(",");
5928 long[] list = new long[strings.length];
5929 for (int i = 0; i < strings.length; i++) {
5930 list[i] = Long.valueOf(strings[i]);
5931 }
5932 intent.putExtra(key, list);
5933 hasIntentInfo = true;
5934 }
5935 break;
5936 case "--elal": {
5937 String key = cmd.getNextArgRequired();
5938 String value = cmd.getNextArgRequired();
5939 String[] strings = value.split(",");
5940 ArrayList<Long> list = new ArrayList<>(strings.length);
5941 for (int i = 0; i < strings.length; i++) {
5942 list.add(Long.valueOf(strings[i]));
5943 }
5944 intent.putExtra(key, list);
5945 hasIntentInfo = true;
5946 }
5947 break;
5948 case "--ef": {
5949 String key = cmd.getNextArgRequired();
5950 String value = cmd.getNextArgRequired();
5951 intent.putExtra(key, Float.valueOf(value));
5952 hasIntentInfo = true;
5953 }
5954 break;
5955 case "--efa": {
5956 String key = cmd.getNextArgRequired();
5957 String value = cmd.getNextArgRequired();
5958 String[] strings = value.split(",");
5959 float[] list = new float[strings.length];
5960 for (int i = 0; i < strings.length; i++) {
5961 list[i] = Float.valueOf(strings[i]);
5962 }
5963 intent.putExtra(key, list);
5964 hasIntentInfo = true;
5965 }
5966 break;
5967 case "--efal": {
5968 String key = cmd.getNextArgRequired();
5969 String value = cmd.getNextArgRequired();
5970 String[] strings = value.split(",");
5971 ArrayList<Float> list = new ArrayList<>(strings.length);
5972 for (int i = 0; i < strings.length; i++) {
5973 list.add(Float.valueOf(strings[i]));
5974 }
5975 intent.putExtra(key, list);
5976 hasIntentInfo = true;
5977 }
5978 break;
5979 case "--esa": {
5980 String key = cmd.getNextArgRequired();
5981 String value = cmd.getNextArgRequired();
5982 // Split on commas unless they are preceeded by an escape.
5983 // The escape character must be escaped for the string and
5984 // again for the regex, thus four escape characters become one.
5985 String[] strings = value.split("(?<!\\\\),");
5986 intent.putExtra(key, strings);
5987 hasIntentInfo = true;
5988 }
5989 break;
5990 case "--esal": {
5991 String key = cmd.getNextArgRequired();
5992 String value = cmd.getNextArgRequired();
5993 // Split on commas unless they are preceeded by an escape.
5994 // The escape character must be escaped for the string and
5995 // again for the regex, thus four escape characters become one.
5996 String[] strings = value.split("(?<!\\\\),");
5997 ArrayList<String> list = new ArrayList<>(strings.length);
5998 for (int i = 0; i < strings.length; i++) {
5999 list.add(strings[i]);
6000 }
6001 intent.putExtra(key, list);
6002 hasIntentInfo = true;
6003 }
6004 break;
6005 case "--ez": {
6006 String key = cmd.getNextArgRequired();
6007 String value = cmd.getNextArgRequired().toLowerCase();
6008 // Boolean.valueOf() results in false for anything that is not "true", which is
6009 // error-prone in shell commands
6010 boolean arg;
6011 if ("true".equals(value) || "t".equals(value)) {
6012 arg = true;
6013 } else if ("false".equals(value) || "f".equals(value)) {
6014 arg = false;
6015 } else {
6016 try {
6017 arg = Integer.decode(value) != 0;
6018 } catch (NumberFormatException ex) {
6019 throw new IllegalArgumentException("Invalid boolean value: " + value);
6020 }
6021 }
6022
6023 intent.putExtra(key, arg);
6024 }
6025 break;
6026 case "-n": {
6027 String str = cmd.getNextArgRequired();
6028 ComponentName cn = ComponentName.unflattenFromString(str);
6029 if (cn == null)
6030 throw new IllegalArgumentException("Bad component name: " + str);
6031 intent.setComponent(cn);
6032 if (intent == baseIntent) {
6033 hasIntentInfo = true;
6034 }
6035 }
6036 break;
6037 case "-p": {
6038 String str = cmd.getNextArgRequired();
6039 intent.setPackage(str);
6040 if (intent == baseIntent) {
6041 hasIntentInfo = true;
6042 }
6043 }
6044 break;
6045 case "-f":
6046 String str = cmd.getNextArgRequired();
6047 intent.setFlags(Integer.decode(str).intValue());
6048 break;
6049 case "--grant-read-uri-permission":
6050 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6051 break;
6052 case "--grant-write-uri-permission":
6053 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6054 break;
6055 case "--grant-persistable-uri-permission":
6056 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6057 break;
6058 case "--grant-prefix-uri-permission":
6059 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6060 break;
6061 case "--exclude-stopped-packages":
6062 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6063 break;
6064 case "--include-stopped-packages":
6065 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6066 break;
6067 case "--debug-log-resolution":
6068 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6069 break;
6070 case "--activity-brought-to-front":
6071 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6072 break;
6073 case "--activity-clear-top":
6074 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6075 break;
6076 case "--activity-clear-when-task-reset":
6077 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6078 break;
6079 case "--activity-exclude-from-recents":
6080 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6081 break;
6082 case "--activity-launched-from-history":
6083 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6084 break;
6085 case "--activity-multiple-task":
6086 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6087 break;
6088 case "--activity-no-animation":
6089 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6090 break;
6091 case "--activity-no-history":
6092 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6093 break;
6094 case "--activity-no-user-action":
6095 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6096 break;
6097 case "--activity-previous-is-top":
6098 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6099 break;
6100 case "--activity-reorder-to-front":
6101 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6102 break;
6103 case "--activity-reset-task-if-needed":
6104 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6105 break;
6106 case "--activity-single-top":
6107 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6108 break;
6109 case "--activity-clear-task":
6110 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6111 break;
6112 case "--activity-task-on-home":
6113 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6114 break;
6115 case "--receiver-registered-only":
6116 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6117 break;
6118 case "--receiver-replace-pending":
6119 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6120 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006121 case "--receiver-foreground":
6122 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6123 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006124 case "--receiver-no-abort":
6125 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6126 break;
6127 case "--receiver-include-background":
6128 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6129 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006130 case "--selector":
6131 intent.setDataAndType(data, type);
6132 intent = new Intent();
6133 break;
6134 default:
6135 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6136 // Okay, caller handled this option.
6137 } else {
6138 throw new IllegalArgumentException("Unknown option: " + opt);
6139 }
6140 break;
6141 }
6142 }
6143 intent.setDataAndType(data, type);
6144
6145 final boolean hasSelector = intent != baseIntent;
6146 if (hasSelector) {
6147 // A selector was specified; fix up.
6148 baseIntent.setSelector(intent);
6149 intent = baseIntent;
6150 }
6151
6152 String arg = cmd.getNextArg();
6153 baseIntent = null;
6154 if (arg == null) {
6155 if (hasSelector) {
6156 // If a selector has been specified, and no arguments
6157 // have been supplied for the main Intent, then we can
6158 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6159 // need to have a component name specified yet, the
6160 // selector will take care of that.
6161 baseIntent = new Intent(Intent.ACTION_MAIN);
6162 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6163 }
6164 } else if (arg.indexOf(':') >= 0) {
6165 // The argument is a URI. Fully parse it, and use that result
6166 // to fill in any data not specified so far.
6167 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6168 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6169 } else if (arg.indexOf('/') >= 0) {
6170 // The argument is a component name. Build an Intent to launch
6171 // it.
6172 baseIntent = new Intent(Intent.ACTION_MAIN);
6173 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6174 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6175 } else {
6176 // Assume the argument is a package name.
6177 baseIntent = new Intent(Intent.ACTION_MAIN);
6178 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6179 baseIntent.setPackage(arg);
6180 }
6181 if (baseIntent != null) {
6182 Bundle extras = intent.getExtras();
6183 intent.replaceExtras((Bundle)null);
6184 Bundle uriExtras = baseIntent.getExtras();
6185 baseIntent.replaceExtras((Bundle)null);
6186 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6187 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6188 for (String c : cats) {
6189 baseIntent.removeCategory(c);
6190 }
6191 }
6192 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6193 if (extras == null) {
6194 extras = uriExtras;
6195 } else if (uriExtras != null) {
6196 uriExtras.putAll(extras);
6197 extras = uriExtras;
6198 }
6199 intent.replaceExtras(extras);
6200 hasIntentInfo = true;
6201 }
6202
6203 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6204 return intent;
6205 }
6206
6207 /** @hide */
6208 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6209 final String[] lines = new String[] {
6210 "<INTENT> specifications include these flags and arguments:",
6211 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6212 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6213 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6214 " [--esn <EXTRA_KEY> ...]",
6215 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6216 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6217 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6218 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6219 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6220 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6221 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6222 " (mutiple extras passed as Integer[])",
6223 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6224 " (mutiple extras passed as List<Integer>)",
6225 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6226 " (mutiple extras passed as Long[])",
6227 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6228 " (mutiple extras passed as List<Long>)",
6229 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6230 " (mutiple extras passed as Float[])",
6231 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6232 " (mutiple extras passed as List<Float>)",
6233 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6234 " (mutiple extras passed as String[]; to embed a comma into a string,",
6235 " escape it using \"\\,\")",
6236 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6237 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6238 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006239 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006240 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6241 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6242 " [--debug-log-resolution] [--exclude-stopped-packages]",
6243 " [--include-stopped-packages]",
6244 " [--activity-brought-to-front] [--activity-clear-top]",
6245 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6246 " [--activity-launched-from-history] [--activity-multiple-task]",
6247 " [--activity-no-animation] [--activity-no-history]",
6248 " [--activity-no-user-action] [--activity-previous-is-top]",
6249 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6250 " [--activity-single-top] [--activity-clear-task]",
6251 " [--activity-task-on-home]",
6252 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006253 " [--receiver-foreground] [--receiver-no-abort]",
6254 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006255 " [--selector]",
6256 " [<URI> | <PACKAGE> | <COMPONENT>]"
6257 };
6258 for (String line : lines) {
6259 pw.print(prefix);
6260 pw.println(line);
6261 }
6262 }
6263
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006264 /**
6265 * Retrieve the general action to be performed, such as
6266 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6267 * the information in the intent should be interpreted -- most importantly,
6268 * what to do with the data returned by {@link #getData}.
6269 *
6270 * @return The action of this intent or null if none is specified.
6271 *
6272 * @see #setAction
6273 */
6274 public String getAction() {
6275 return mAction;
6276 }
6277
6278 /**
6279 * Retrieve data this intent is operating on. This URI specifies the name
6280 * of the data; often it uses the content: scheme, specifying data in a
6281 * content provider. Other schemes may be handled by specific activities,
6282 * such as http: by the web browser.
6283 *
6284 * @return The URI of the data this intent is targeting or null.
6285 *
6286 * @see #getScheme
6287 * @see #setData
6288 */
6289 public Uri getData() {
6290 return mData;
6291 }
6292
6293 /**
6294 * The same as {@link #getData()}, but returns the URI as an encoded
6295 * String.
6296 */
6297 public String getDataString() {
6298 return mData != null ? mData.toString() : null;
6299 }
6300
6301 /**
6302 * Return the scheme portion of the intent's data. If the data is null or
6303 * does not include a scheme, null is returned. Otherwise, the scheme
6304 * prefix without the final ':' is returned, i.e. "http".
6305 *
6306 * <p>This is the same as calling getData().getScheme() (and checking for
6307 * null data).
6308 *
6309 * @return The scheme of this intent.
6310 *
6311 * @see #getData
6312 */
6313 public String getScheme() {
6314 return mData != null ? mData.getScheme() : null;
6315 }
6316
6317 /**
6318 * Retrieve any explicit MIME type included in the intent. This is usually
6319 * null, as the type is determined by the intent data.
6320 *
6321 * @return If a type was manually set, it is returned; else null is
6322 * returned.
6323 *
6324 * @see #resolveType(ContentResolver)
6325 * @see #setType
6326 */
6327 public String getType() {
6328 return mType;
6329 }
6330
6331 /**
6332 * Return the MIME data type of this intent. If the type field is
6333 * explicitly set, that is simply returned. Otherwise, if the data is set,
6334 * the type of that data is returned. If neither fields are set, a null is
6335 * returned.
6336 *
6337 * @return The MIME type of this intent.
6338 *
6339 * @see #getType
6340 * @see #resolveType(ContentResolver)
6341 */
6342 public String resolveType(Context context) {
6343 return resolveType(context.getContentResolver());
6344 }
6345
6346 /**
6347 * Return the MIME data type of this intent. If the type field is
6348 * explicitly set, that is simply returned. Otherwise, if the data is set,
6349 * the type of that data is returned. If neither fields are set, a null is
6350 * returned.
6351 *
6352 * @param resolver A ContentResolver that can be used to determine the MIME
6353 * type of the intent's data.
6354 *
6355 * @return The MIME type of this intent.
6356 *
6357 * @see #getType
6358 * @see #resolveType(Context)
6359 */
6360 public String resolveType(ContentResolver resolver) {
6361 if (mType != null) {
6362 return mType;
6363 }
6364 if (mData != null) {
6365 if ("content".equals(mData.getScheme())) {
6366 return resolver.getType(mData);
6367 }
6368 }
6369 return null;
6370 }
6371
6372 /**
6373 * Return the MIME data type of this intent, only if it will be needed for
6374 * intent resolution. This is not generally useful for application code;
6375 * it is used by the frameworks for communicating with back-end system
6376 * services.
6377 *
6378 * @param resolver A ContentResolver that can be used to determine the MIME
6379 * type of the intent's data.
6380 *
6381 * @return The MIME type of this intent, or null if it is unknown or not
6382 * needed.
6383 */
6384 public String resolveTypeIfNeeded(ContentResolver resolver) {
6385 if (mComponent != null) {
6386 return mType;
6387 }
6388 return resolveType(resolver);
6389 }
6390
6391 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006392 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006393 *
6394 * @param category The category to check.
6395 *
6396 * @return boolean True if the intent contains the category, else false.
6397 *
6398 * @see #getCategories
6399 * @see #addCategory
6400 */
6401 public boolean hasCategory(String category) {
6402 return mCategories != null && mCategories.contains(category);
6403 }
6404
6405 /**
6406 * Return the set of all categories in the intent. If there are no categories,
6407 * returns NULL.
6408 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006409 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006410 *
6411 * @see #hasCategory
6412 * @see #addCategory
6413 */
6414 public Set<String> getCategories() {
6415 return mCategories;
6416 }
6417
6418 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006419 * Return the specific selector associated with this Intent. If there is
6420 * none, returns null. See {@link #setSelector} for more information.
6421 *
6422 * @see #setSelector
6423 */
6424 public Intent getSelector() {
6425 return mSelector;
6426 }
6427
6428 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006429 * Return the {@link ClipData} associated with this Intent. If there is
6430 * none, returns null. See {@link #setClipData} for more information.
6431 *
John Spurlock125d1332013-11-25 11:58:37 -05006432 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006433 */
6434 public ClipData getClipData() {
6435 return mClipData;
6436 }
6437
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006438 /** @hide */
6439 public int getContentUserHint() {
6440 return mContentUserHint;
6441 }
6442
Todd Kennedyb3b431302017-03-20 16:05:48 -07006443 /** @hide */
6444 public String getLaunchToken() {
6445 return mLaunchToken;
6446 }
6447
6448 /** @hide */
6449 public void setLaunchToken(String launchToken) {
6450 mLaunchToken = launchToken;
6451 }
6452
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006453 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006454 * Sets the ClassLoader that will be used when unmarshalling
6455 * any Parcelable values from the extras of this Intent.
6456 *
6457 * @param loader a ClassLoader, or null to use the default loader
6458 * at the time of unmarshalling.
6459 */
6460 public void setExtrasClassLoader(ClassLoader loader) {
6461 if (mExtras != null) {
6462 mExtras.setClassLoader(loader);
6463 }
6464 }
6465
6466 /**
6467 * Returns true if an extra value is associated with the given name.
6468 * @param name the extra's name
6469 * @return true if the given extra is present.
6470 */
6471 public boolean hasExtra(String name) {
6472 return mExtras != null && mExtras.containsKey(name);
6473 }
6474
6475 /**
6476 * Returns true if the Intent's extras contain a parcelled file descriptor.
6477 * @return true if the Intent contains a parcelled file descriptor.
6478 */
6479 public boolean hasFileDescriptors() {
6480 return mExtras != null && mExtras.hasFileDescriptors();
6481 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006482
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006483 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006484 public void setAllowFds(boolean allowFds) {
6485 if (mExtras != null) {
6486 mExtras.setAllowFds(allowFds);
6487 }
6488 }
6489
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006490 /** {@hide} */
6491 public void setDefusable(boolean defusable) {
6492 if (mExtras != null) {
6493 mExtras.setDefusable(defusable);
6494 }
6495 }
6496
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006497 /**
6498 * Retrieve extended data from the intent.
6499 *
6500 * @param name The name of the desired item.
6501 *
6502 * @return the value of an item that previously added with putExtra()
6503 * or null if none was found.
6504 *
6505 * @deprecated
6506 * @hide
6507 */
6508 @Deprecated
6509 public Object getExtra(String name) {
6510 return getExtra(name, null);
6511 }
6512
6513 /**
6514 * Retrieve extended data from the intent.
6515 *
6516 * @param name The name of the desired item.
6517 * @param defaultValue the value to be returned if no value of the desired
6518 * type is stored with the given name.
6519 *
6520 * @return the value of an item that previously added with putExtra()
6521 * or the default value if none was found.
6522 *
6523 * @see #putExtra(String, boolean)
6524 */
6525 public boolean getBooleanExtra(String name, boolean defaultValue) {
6526 return mExtras == null ? defaultValue :
6527 mExtras.getBoolean(name, defaultValue);
6528 }
6529
6530 /**
6531 * Retrieve extended data from the intent.
6532 *
6533 * @param name The name of the desired item.
6534 * @param defaultValue the value to be returned if no value of the desired
6535 * type is stored with the given name.
6536 *
6537 * @return the value of an item that previously added with putExtra()
6538 * or the default value if none was found.
6539 *
6540 * @see #putExtra(String, byte)
6541 */
6542 public byte getByteExtra(String name, byte defaultValue) {
6543 return mExtras == null ? defaultValue :
6544 mExtras.getByte(name, defaultValue);
6545 }
6546
6547 /**
6548 * Retrieve extended data from the intent.
6549 *
6550 * @param name The name of the desired item.
6551 * @param defaultValue the value to be returned if no value of the desired
6552 * type is stored with the given name.
6553 *
6554 * @return the value of an item that previously added with putExtra()
6555 * or the default value if none was found.
6556 *
6557 * @see #putExtra(String, short)
6558 */
6559 public short getShortExtra(String name, short defaultValue) {
6560 return mExtras == null ? defaultValue :
6561 mExtras.getShort(name, defaultValue);
6562 }
6563
6564 /**
6565 * Retrieve extended data from the intent.
6566 *
6567 * @param name The name of the desired item.
6568 * @param defaultValue the value to be returned if no value of the desired
6569 * type is stored with the given name.
6570 *
6571 * @return the value of an item that previously added with putExtra()
6572 * or the default value if none was found.
6573 *
6574 * @see #putExtra(String, char)
6575 */
6576 public char getCharExtra(String name, char defaultValue) {
6577 return mExtras == null ? defaultValue :
6578 mExtras.getChar(name, defaultValue);
6579 }
6580
6581 /**
6582 * Retrieve extended data from the intent.
6583 *
6584 * @param name The name of the desired item.
6585 * @param defaultValue the value to be returned if no value of the desired
6586 * type is stored with the given name.
6587 *
6588 * @return the value of an item that previously added with putExtra()
6589 * or the default value if none was found.
6590 *
6591 * @see #putExtra(String, int)
6592 */
6593 public int getIntExtra(String name, int defaultValue) {
6594 return mExtras == null ? defaultValue :
6595 mExtras.getInt(name, defaultValue);
6596 }
6597
6598 /**
6599 * Retrieve extended data from the intent.
6600 *
6601 * @param name The name of the desired item.
6602 * @param defaultValue the value to be returned if no value of the desired
6603 * type is stored with the given name.
6604 *
6605 * @return the value of an item that previously added with putExtra()
6606 * or the default value if none was found.
6607 *
6608 * @see #putExtra(String, long)
6609 */
6610 public long getLongExtra(String name, long defaultValue) {
6611 return mExtras == null ? defaultValue :
6612 mExtras.getLong(name, defaultValue);
6613 }
6614
6615 /**
6616 * Retrieve extended data from the intent.
6617 *
6618 * @param name The name of the desired item.
6619 * @param defaultValue the value to be returned if no value of the desired
6620 * type is stored with the given name.
6621 *
6622 * @return the value of an item that previously added with putExtra(),
6623 * or the default value if no such item is present
6624 *
6625 * @see #putExtra(String, float)
6626 */
6627 public float getFloatExtra(String name, float defaultValue) {
6628 return mExtras == null ? defaultValue :
6629 mExtras.getFloat(name, defaultValue);
6630 }
6631
6632 /**
6633 * Retrieve extended data from the intent.
6634 *
6635 * @param name The name of the desired item.
6636 * @param defaultValue the value to be returned if no value of the desired
6637 * type is stored with the given name.
6638 *
6639 * @return the value of an item that previously added with putExtra()
6640 * or the default value if none was found.
6641 *
6642 * @see #putExtra(String, double)
6643 */
6644 public double getDoubleExtra(String name, double defaultValue) {
6645 return mExtras == null ? defaultValue :
6646 mExtras.getDouble(name, defaultValue);
6647 }
6648
6649 /**
6650 * Retrieve extended data from the intent.
6651 *
6652 * @param name The name of the desired item.
6653 *
6654 * @return the value of an item that previously added with putExtra()
6655 * or null if no String value was found.
6656 *
6657 * @see #putExtra(String, String)
6658 */
6659 public String getStringExtra(String name) {
6660 return mExtras == null ? null : mExtras.getString(name);
6661 }
6662
6663 /**
6664 * Retrieve extended data from the intent.
6665 *
6666 * @param name The name of the desired item.
6667 *
6668 * @return the value of an item that previously added with putExtra()
6669 * or null if no CharSequence value was found.
6670 *
6671 * @see #putExtra(String, CharSequence)
6672 */
6673 public CharSequence getCharSequenceExtra(String name) {
6674 return mExtras == null ? null : mExtras.getCharSequence(name);
6675 }
6676
6677 /**
6678 * Retrieve extended data from the intent.
6679 *
6680 * @param name The name of the desired item.
6681 *
6682 * @return the value of an item that previously added with putExtra()
6683 * or null if no Parcelable value was found.
6684 *
6685 * @see #putExtra(String, Parcelable)
6686 */
6687 public <T extends Parcelable> T getParcelableExtra(String name) {
6688 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6689 }
6690
6691 /**
6692 * Retrieve extended data from the intent.
6693 *
6694 * @param name The name of the desired item.
6695 *
6696 * @return the value of an item that previously added with putExtra()
6697 * or null if no Parcelable[] value was found.
6698 *
6699 * @see #putExtra(String, Parcelable[])
6700 */
6701 public Parcelable[] getParcelableArrayExtra(String name) {
6702 return mExtras == null ? null : mExtras.getParcelableArray(name);
6703 }
6704
6705 /**
6706 * Retrieve extended data from the intent.
6707 *
6708 * @param name The name of the desired item.
6709 *
6710 * @return the value of an item that previously added with putExtra()
6711 * or null if no ArrayList<Parcelable> value was found.
6712 *
6713 * @see #putParcelableArrayListExtra(String, ArrayList)
6714 */
6715 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6716 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6717 }
6718
6719 /**
6720 * Retrieve extended data from the intent.
6721 *
6722 * @param name The name of the desired item.
6723 *
6724 * @return the value of an item that previously added with putExtra()
6725 * or null if no Serializable value was found.
6726 *
6727 * @see #putExtra(String, Serializable)
6728 */
6729 public Serializable getSerializableExtra(String name) {
6730 return mExtras == null ? null : mExtras.getSerializable(name);
6731 }
6732
6733 /**
6734 * Retrieve extended data from the intent.
6735 *
6736 * @param name The name of the desired item.
6737 *
6738 * @return the value of an item that previously added with putExtra()
6739 * or null if no ArrayList<Integer> value was found.
6740 *
6741 * @see #putIntegerArrayListExtra(String, ArrayList)
6742 */
6743 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6744 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6745 }
6746
6747 /**
6748 * Retrieve extended data from the intent.
6749 *
6750 * @param name The name of the desired item.
6751 *
6752 * @return the value of an item that previously added with putExtra()
6753 * or null if no ArrayList<String> value was found.
6754 *
6755 * @see #putStringArrayListExtra(String, ArrayList)
6756 */
6757 public ArrayList<String> getStringArrayListExtra(String name) {
6758 return mExtras == null ? null : mExtras.getStringArrayList(name);
6759 }
6760
6761 /**
6762 * Retrieve extended data from the intent.
6763 *
6764 * @param name The name of the desired item.
6765 *
6766 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006767 * or null if no ArrayList<CharSequence> value was found.
6768 *
6769 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6770 */
6771 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6772 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6773 }
6774
6775 /**
6776 * Retrieve extended data from the intent.
6777 *
6778 * @param name The name of the desired item.
6779 *
6780 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006781 * or null if no boolean array value was found.
6782 *
6783 * @see #putExtra(String, boolean[])
6784 */
6785 public boolean[] getBooleanArrayExtra(String name) {
6786 return mExtras == null ? null : mExtras.getBooleanArray(name);
6787 }
6788
6789 /**
6790 * Retrieve extended data from the intent.
6791 *
6792 * @param name The name of the desired item.
6793 *
6794 * @return the value of an item that previously added with putExtra()
6795 * or null if no byte array value was found.
6796 *
6797 * @see #putExtra(String, byte[])
6798 */
6799 public byte[] getByteArrayExtra(String name) {
6800 return mExtras == null ? null : mExtras.getByteArray(name);
6801 }
6802
6803 /**
6804 * Retrieve extended data from the intent.
6805 *
6806 * @param name The name of the desired item.
6807 *
6808 * @return the value of an item that previously added with putExtra()
6809 * or null if no short array value was found.
6810 *
6811 * @see #putExtra(String, short[])
6812 */
6813 public short[] getShortArrayExtra(String name) {
6814 return mExtras == null ? null : mExtras.getShortArray(name);
6815 }
6816
6817 /**
6818 * Retrieve extended data from the intent.
6819 *
6820 * @param name The name of the desired item.
6821 *
6822 * @return the value of an item that previously added with putExtra()
6823 * or null if no char array value was found.
6824 *
6825 * @see #putExtra(String, char[])
6826 */
6827 public char[] getCharArrayExtra(String name) {
6828 return mExtras == null ? null : mExtras.getCharArray(name);
6829 }
6830
6831 /**
6832 * Retrieve extended data from the intent.
6833 *
6834 * @param name The name of the desired item.
6835 *
6836 * @return the value of an item that previously added with putExtra()
6837 * or null if no int array value was found.
6838 *
6839 * @see #putExtra(String, int[])
6840 */
6841 public int[] getIntArrayExtra(String name) {
6842 return mExtras == null ? null : mExtras.getIntArray(name);
6843 }
6844
6845 /**
6846 * Retrieve extended data from the intent.
6847 *
6848 * @param name The name of the desired item.
6849 *
6850 * @return the value of an item that previously added with putExtra()
6851 * or null if no long array value was found.
6852 *
6853 * @see #putExtra(String, long[])
6854 */
6855 public long[] getLongArrayExtra(String name) {
6856 return mExtras == null ? null : mExtras.getLongArray(name);
6857 }
6858
6859 /**
6860 * Retrieve extended data from the intent.
6861 *
6862 * @param name The name of the desired item.
6863 *
6864 * @return the value of an item that previously added with putExtra()
6865 * or null if no float array value was found.
6866 *
6867 * @see #putExtra(String, float[])
6868 */
6869 public float[] getFloatArrayExtra(String name) {
6870 return mExtras == null ? null : mExtras.getFloatArray(name);
6871 }
6872
6873 /**
6874 * Retrieve extended data from the intent.
6875 *
6876 * @param name The name of the desired item.
6877 *
6878 * @return the value of an item that previously added with putExtra()
6879 * or null if no double array value was found.
6880 *
6881 * @see #putExtra(String, double[])
6882 */
6883 public double[] getDoubleArrayExtra(String name) {
6884 return mExtras == null ? null : mExtras.getDoubleArray(name);
6885 }
6886
6887 /**
6888 * Retrieve extended data from the intent.
6889 *
6890 * @param name The name of the desired item.
6891 *
6892 * @return the value of an item that previously added with putExtra()
6893 * or null if no String array value was found.
6894 *
6895 * @see #putExtra(String, String[])
6896 */
6897 public String[] getStringArrayExtra(String name) {
6898 return mExtras == null ? null : mExtras.getStringArray(name);
6899 }
6900
6901 /**
6902 * Retrieve extended data from the intent.
6903 *
6904 * @param name The name of the desired item.
6905 *
6906 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006907 * or null if no CharSequence array value was found.
6908 *
6909 * @see #putExtra(String, CharSequence[])
6910 */
6911 public CharSequence[] getCharSequenceArrayExtra(String name) {
6912 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6913 }
6914
6915 /**
6916 * Retrieve extended data from the intent.
6917 *
6918 * @param name The name of the desired item.
6919 *
6920 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006921 * or null if no Bundle value was found.
6922 *
6923 * @see #putExtra(String, Bundle)
6924 */
6925 public Bundle getBundleExtra(String name) {
6926 return mExtras == null ? null : mExtras.getBundle(name);
6927 }
6928
6929 /**
6930 * Retrieve extended data from the intent.
6931 *
6932 * @param name The name of the desired item.
6933 *
6934 * @return the value of an item that previously added with putExtra()
6935 * or null if no IBinder value was found.
6936 *
6937 * @see #putExtra(String, IBinder)
6938 *
6939 * @deprecated
6940 * @hide
6941 */
6942 @Deprecated
6943 public IBinder getIBinderExtra(String name) {
6944 return mExtras == null ? null : mExtras.getIBinder(name);
6945 }
6946
6947 /**
6948 * Retrieve extended data from the intent.
6949 *
6950 * @param name The name of the desired item.
6951 * @param defaultValue The default value to return in case no item is
6952 * associated with the key 'name'
6953 *
6954 * @return the value of an item that previously added with putExtra()
6955 * or defaultValue if none was found.
6956 *
6957 * @see #putExtra
6958 *
6959 * @deprecated
6960 * @hide
6961 */
6962 @Deprecated
6963 public Object getExtra(String name, Object defaultValue) {
6964 Object result = defaultValue;
6965 if (mExtras != null) {
6966 Object result2 = mExtras.get(name);
6967 if (result2 != null) {
6968 result = result2;
6969 }
6970 }
6971
6972 return result;
6973 }
6974
6975 /**
6976 * Retrieves a map of extended data from the intent.
6977 *
6978 * @return the map of all extras previously added with putExtra(),
6979 * or null if none have been added.
6980 */
6981 public Bundle getExtras() {
6982 return (mExtras != null)
6983 ? new Bundle(mExtras)
6984 : null;
6985 }
6986
6987 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006988 * Filter extras to only basic types.
6989 * @hide
6990 */
6991 public void removeUnsafeExtras() {
6992 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006993 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006994 }
6995 }
6996
6997 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006998 * Retrieve any special flags associated with this intent. You will
6999 * normally just set them with {@link #setFlags} and let the system
7000 * take the appropriate action with them.
7001 *
7002 * @return int The currently set flags.
7003 *
7004 * @see #setFlags
7005 */
7006 public int getFlags() {
7007 return mFlags;
7008 }
7009
Dianne Hackborne7f97212011-02-24 14:40:20 -08007010 /** @hide */
7011 public boolean isExcludingStopped() {
7012 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7013 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7014 }
7015
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007016 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007017 * Retrieve the application package name this Intent is limited to. When
7018 * resolving an Intent, if non-null this limits the resolution to only
7019 * components in the given application package.
7020 *
7021 * @return The name of the application package for the Intent.
7022 *
7023 * @see #resolveActivity
7024 * @see #setPackage
7025 */
7026 public String getPackage() {
7027 return mPackage;
7028 }
7029
7030 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007031 * Retrieve the concrete component associated with the intent. When receiving
7032 * an intent, this is the component that was found to best handle it (that is,
7033 * yourself) and will always be non-null; in all other cases it will be
7034 * null unless explicitly set.
7035 *
7036 * @return The name of the application component to handle the intent.
7037 *
7038 * @see #resolveActivity
7039 * @see #setComponent
7040 */
7041 public ComponentName getComponent() {
7042 return mComponent;
7043 }
7044
7045 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007046 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7047 * used as a hint to the receiver for animations and the like. Null means that there
7048 * is no source bounds.
7049 */
7050 public Rect getSourceBounds() {
7051 return mSourceBounds;
7052 }
7053
7054 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007055 * Return the Activity component that should be used to handle this intent.
7056 * The appropriate component is determined based on the information in the
7057 * intent, evaluated as follows:
7058 *
7059 * <p>If {@link #getComponent} returns an explicit class, that is returned
7060 * without any further consideration.
7061 *
7062 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7063 * category to be considered.
7064 *
7065 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7066 * action.
7067 *
7068 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7069 * this type.
7070 *
7071 * <p>If {@link #addCategory} has added any categories, the activity must
7072 * handle ALL of the categories specified.
7073 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007074 * <p>If {@link #getPackage} is non-NULL, only activity components in
7075 * that application package will be considered.
7076 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007077 * <p>If there are no activities that satisfy all of these conditions, a
7078 * null string is returned.
7079 *
7080 * <p>If multiple activities are found to satisfy the intent, the one with
7081 * the highest priority will be used. If there are multiple activities
7082 * with the same priority, the system will either pick the best activity
7083 * based on user preference, or resolve to a system class that will allow
7084 * the user to pick an activity and forward from there.
7085 *
7086 * <p>This method is implemented simply by calling
7087 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7088 * true.</p>
7089 * <p> This API is called for you as part of starting an activity from an
7090 * intent. You do not normally need to call it yourself.</p>
7091 *
7092 * @param pm The package manager with which to resolve the Intent.
7093 *
7094 * @return Name of the component implementing an activity that can
7095 * display the intent.
7096 *
7097 * @see #setComponent
7098 * @see #getComponent
7099 * @see #resolveActivityInfo
7100 */
7101 public ComponentName resolveActivity(PackageManager pm) {
7102 if (mComponent != null) {
7103 return mComponent;
7104 }
7105
7106 ResolveInfo info = pm.resolveActivity(
7107 this, PackageManager.MATCH_DEFAULT_ONLY);
7108 if (info != null) {
7109 return new ComponentName(
7110 info.activityInfo.applicationInfo.packageName,
7111 info.activityInfo.name);
7112 }
7113
7114 return null;
7115 }
7116
7117 /**
7118 * Resolve the Intent into an {@link ActivityInfo}
7119 * describing the activity that should execute the intent. Resolution
7120 * follows the same rules as described for {@link #resolveActivity}, but
7121 * you get back the completely information about the resolved activity
7122 * instead of just its class name.
7123 *
7124 * @param pm The package manager with which to resolve the Intent.
7125 * @param flags Addition information to retrieve as per
7126 * {@link PackageManager#getActivityInfo(ComponentName, int)
7127 * PackageManager.getActivityInfo()}.
7128 *
7129 * @return PackageManager.ActivityInfo
7130 *
7131 * @see #resolveActivity
7132 */
7133 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7134 ActivityInfo ai = null;
7135 if (mComponent != null) {
7136 try {
7137 ai = pm.getActivityInfo(mComponent, flags);
7138 } catch (PackageManager.NameNotFoundException e) {
7139 // ignore
7140 }
7141 } else {
7142 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007143 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007144 if (info != null) {
7145 ai = info.activityInfo;
7146 }
7147 }
7148
7149 return ai;
7150 }
7151
7152 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007153 * Special function for use by the system to resolve service
7154 * intents to system apps. Throws an exception if there are
7155 * multiple potential matches to the Intent. Returns null if
7156 * there are no matches.
7157 * @hide
7158 */
7159 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7160 if (mComponent != null) {
7161 return mComponent;
7162 }
7163
7164 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7165 if (results == null) {
7166 return null;
7167 }
7168 ComponentName comp = null;
7169 for (int i=0; i<results.size(); i++) {
7170 ResolveInfo ri = results.get(i);
7171 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7172 continue;
7173 }
7174 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7175 ri.serviceInfo.name);
7176 if (comp != null) {
7177 throw new IllegalStateException("Multiple system services handle " + this
7178 + ": " + comp + ", " + foundComp);
7179 }
7180 comp = foundComp;
7181 }
7182 return comp;
7183 }
7184
7185 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007186 * Set the general action to be performed.
7187 *
7188 * @param action An action name, such as ACTION_VIEW. Application-specific
7189 * actions should be prefixed with the vendor's package name.
7190 *
7191 * @return Returns the same Intent object, for chaining multiple calls
7192 * into a single statement.
7193 *
7194 * @see #getAction
7195 */
7196 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007197 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007198 return this;
7199 }
7200
7201 /**
7202 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007203 * clears any type that was previously set by {@link #setType} or
7204 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007205 *
Nick Pellyccae4122012-01-09 14:12:58 -08007206 * <p><em>Note: scheme matching in the Android framework is
7207 * case-sensitive, unlike the formal RFC. As a result,
7208 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007209 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007210 * {@link #setDataAndNormalize}
7211 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007212 *
Nick Pellyccae4122012-01-09 14:12:58 -08007213 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007214 *
7215 * @return Returns the same Intent object, for chaining multiple calls
7216 * into a single statement.
7217 *
7218 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007219 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007220 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007221 */
7222 public Intent setData(Uri data) {
7223 mData = data;
7224 mType = null;
7225 return this;
7226 }
7227
7228 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007229 * Normalize and set the data this intent is operating on.
7230 *
7231 * <p>This method automatically clears any type that was
7232 * previously set (for example, by {@link #setType}).
7233 *
7234 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007235 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007236 * so really this is just a convenience method for
7237 * <pre>
7238 * setData(data.normalize())
7239 * </pre>
7240 *
7241 * @param data The Uri of the data this intent is now targeting.
7242 *
7243 * @return Returns the same Intent object, for chaining multiple calls
7244 * into a single statement.
7245 *
7246 * @see #getData
7247 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007248 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007249 */
7250 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007251 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007252 }
7253
7254 /**
7255 * Set an explicit MIME data type.
7256 *
7257 * <p>This is used to create intents that only specify a type and not data,
7258 * for example to indicate the type of data to return.
7259 *
7260 * <p>This method automatically clears any data that was
7261 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007262 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007263 * <p><em>Note: MIME type matching in the Android framework is
7264 * case-sensitive, unlike formal RFC MIME types. As a result,
7265 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007266 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7267 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007268 *
7269 * @param type The MIME type of the data being handled by this intent.
7270 *
7271 * @return Returns the same Intent object, for chaining multiple calls
7272 * into a single statement.
7273 *
7274 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007275 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007276 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007277 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007278 */
7279 public Intent setType(String type) {
7280 mData = null;
7281 mType = type;
7282 return this;
7283 }
7284
7285 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007286 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007287 *
Nick Pellyccae4122012-01-09 14:12:58 -08007288 * <p>This is used to create intents that only specify a type and not data,
7289 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007290 *
Nick Pellyccae4122012-01-09 14:12:58 -08007291 * <p>This method automatically clears any data that was
7292 * previously set (for example by {@link #setData}).
7293 *
7294 * <p>The MIME type is normalized using
7295 * {@link #normalizeMimeType} before it is set,
7296 * so really this is just a convenience method for
7297 * <pre>
7298 * setType(Intent.normalizeMimeType(type))
7299 * </pre>
7300 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007301 * @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 *
Nick Pellyccae4122012-01-09 14:12:58 -08007306 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007307 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007308 * @see #normalizeMimeType
7309 */
7310 public Intent setTypeAndNormalize(String type) {
7311 return setType(normalizeMimeType(type));
7312 }
7313
7314 /**
7315 * (Usually optional) Set the data for the intent along with an explicit
7316 * MIME data type. This method should very rarely be used -- it allows you
7317 * to override the MIME type that would ordinarily be inferred from the
7318 * data with your own type given here.
7319 *
7320 * <p><em>Note: MIME type and Uri scheme matching in the
7321 * Android framework is case-sensitive, unlike the formal RFC definitions.
7322 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007323 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007324 * {@link #setDataAndTypeAndNormalize}
7325 * to ensure that they are converted to lower case.</em>
7326 *
7327 * @param data The Uri of the data this intent is now targeting.
7328 * @param type The MIME type of the data being handled by this intent.
7329 *
7330 * @return Returns the same Intent object, for chaining multiple calls
7331 * into a single statement.
7332 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007333 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007334 * @see #setData
7335 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007336 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007337 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007338 */
7339 public Intent setDataAndType(Uri data, String type) {
7340 mData = data;
7341 mType = type;
7342 return this;
7343 }
7344
7345 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007346 * (Usually optional) Normalize and set both the data Uri and an explicit
7347 * MIME data type. This method should very rarely be used -- it allows you
7348 * to override the MIME type that would ordinarily be inferred from the
7349 * data with your own type given here.
7350 *
7351 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007352 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007353 * before they are set, so really this is just a convenience method for
7354 * <pre>
7355 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7356 * </pre>
7357 *
7358 * @param data The Uri of the data this intent is now targeting.
7359 * @param type The MIME type of the data being handled by this intent.
7360 *
7361 * @return Returns the same Intent object, for chaining multiple calls
7362 * into a single statement.
7363 *
7364 * @see #setType
7365 * @see #setData
7366 * @see #setDataAndType
7367 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007368 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007369 */
7370 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007371 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007372 }
7373
7374 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007375 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007376 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007377 * activities that provide <em>all</em> of the requested categories will be
7378 * used.
7379 *
7380 * @param category The desired category. This can be either one of the
7381 * predefined Intent categories, or a custom category in your own
7382 * namespace.
7383 *
7384 * @return Returns the same Intent object, for chaining multiple calls
7385 * into a single statement.
7386 *
7387 * @see #hasCategory
7388 * @see #removeCategory
7389 */
7390 public Intent addCategory(String category) {
7391 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007392 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007393 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007394 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007395 return this;
7396 }
7397
7398 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007399 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007400 *
7401 * @param category The category to remove.
7402 *
7403 * @see #addCategory
7404 */
7405 public void removeCategory(String category) {
7406 if (mCategories != null) {
7407 mCategories.remove(category);
7408 if (mCategories.size() == 0) {
7409 mCategories = null;
7410 }
7411 }
7412 }
7413
7414 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007415 * Set a selector for this Intent. This is a modification to the kinds of
7416 * things the Intent will match. If the selector is set, it will be used
7417 * when trying to find entities that can handle the Intent, instead of the
7418 * main contents of the Intent. This allows you build an Intent containing
7419 * a generic protocol while targeting it more specifically.
7420 *
7421 * <p>An example of where this may be used is with things like
7422 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7423 * Intent that will launch the Browser application. However, the correct
7424 * main entry point of an application is actually {@link #ACTION_MAIN}
7425 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7426 * used to specify the actual Activity to launch. If you launch the browser
7427 * with something different, undesired behavior may happen if the user has
7428 * previously or later launches it the normal way, since they do not match.
7429 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7430 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7431 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7432 *
7433 * <p>Setting a selector does not impact the behavior of
7434 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7435 * desired behavior of a selector -- it does not impact the base meaning
7436 * of the Intent, just what kinds of things will be matched against it
7437 * when determining who can handle it.</p>
7438 *
7439 * <p>You can not use both a selector and {@link #setPackage(String)} on
7440 * the same base Intent.</p>
7441 *
7442 * @param selector The desired selector Intent; set to null to not use
7443 * a special selector.
7444 */
7445 public void setSelector(Intent selector) {
7446 if (selector == this) {
7447 throw new IllegalArgumentException(
7448 "Intent being set as a selector of itself");
7449 }
7450 if (selector != null && mPackage != null) {
7451 throw new IllegalArgumentException(
7452 "Can't set selector when package name is already set");
7453 }
7454 mSelector = selector;
7455 }
7456
7457 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007458 * Set a {@link ClipData} associated with this Intent. This replaces any
7459 * previously set ClipData.
7460 *
7461 * <p>The ClipData in an intent is not used for Intent matching or other
7462 * such operations. Semantically it is like extras, used to transmit
7463 * additional data with the Intent. The main feature of using this over
7464 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7465 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7466 * items included in the clip data. This is useful, in particular, if
7467 * you want to transmit an Intent containing multiple <code>content:</code>
7468 * URIs for which the recipient may not have global permission to access the
7469 * content provider.
7470 *
7471 * <p>If the ClipData contains items that are themselves Intents, any
7472 * grant flags in those Intents will be ignored. Only the top-level flags
7473 * of the main Intent are respected, and will be applied to all Uri or
7474 * Intent items in the clip (or sub-items of the clip).
7475 *
7476 * <p>The MIME type, label, and icon in the ClipData object are not
7477 * directly used by Intent. Applications should generally rely on the
7478 * MIME type of the Intent itself, not what it may find in the ClipData.
7479 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007480 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007481 *
7482 * @param clip The new clip to set. May be null to clear the current clip.
7483 */
7484 public void setClipData(ClipData clip) {
7485 mClipData = clip;
7486 }
7487
7488 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007489 * This is NOT a secure mechanism to identify the user who sent the intent.
7490 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7491 * who sent the intent.
7492 * @hide
7493 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007494 public void prepareToLeaveUser(int userId) {
7495 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7496 // We want mContentUserHint to refer to the original user, so don't do anything.
7497 if (mContentUserHint == UserHandle.USER_CURRENT) {
7498 mContentUserHint = userId;
7499 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007500 }
7501
7502 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007503 * Add extended data to the intent. The name must include a package
7504 * prefix, for example the app com.android.contacts would use names
7505 * like "com.android.contacts.ShowAll".
7506 *
7507 * @param name The name of the extra data, with package prefix.
7508 * @param value The boolean data value.
7509 *
7510 * @return Returns the same Intent object, for chaining multiple calls
7511 * into a single statement.
7512 *
7513 * @see #putExtras
7514 * @see #removeExtra
7515 * @see #getBooleanExtra(String, boolean)
7516 */
7517 public Intent putExtra(String name, boolean value) {
7518 if (mExtras == null) {
7519 mExtras = new Bundle();
7520 }
7521 mExtras.putBoolean(name, value);
7522 return this;
7523 }
7524
7525 /**
7526 * Add extended data to the intent. The name must include a package
7527 * prefix, for example the app com.android.contacts would use names
7528 * like "com.android.contacts.ShowAll".
7529 *
7530 * @param name The name of the extra data, with package prefix.
7531 * @param value The byte data value.
7532 *
7533 * @return Returns the same Intent object, for chaining multiple calls
7534 * into a single statement.
7535 *
7536 * @see #putExtras
7537 * @see #removeExtra
7538 * @see #getByteExtra(String, byte)
7539 */
7540 public Intent putExtra(String name, byte value) {
7541 if (mExtras == null) {
7542 mExtras = new Bundle();
7543 }
7544 mExtras.putByte(name, value);
7545 return this;
7546 }
7547
7548 /**
7549 * Add extended data to the intent. The name must include a package
7550 * prefix, for example the app com.android.contacts would use names
7551 * like "com.android.contacts.ShowAll".
7552 *
7553 * @param name The name of the extra data, with package prefix.
7554 * @param value The char data value.
7555 *
7556 * @return Returns the same Intent object, for chaining multiple calls
7557 * into a single statement.
7558 *
7559 * @see #putExtras
7560 * @see #removeExtra
7561 * @see #getCharExtra(String, char)
7562 */
7563 public Intent putExtra(String name, char value) {
7564 if (mExtras == null) {
7565 mExtras = new Bundle();
7566 }
7567 mExtras.putChar(name, value);
7568 return this;
7569 }
7570
7571 /**
7572 * Add extended data to the intent. The name must include a package
7573 * prefix, for example the app com.android.contacts would use names
7574 * like "com.android.contacts.ShowAll".
7575 *
7576 * @param name The name of the extra data, with package prefix.
7577 * @param value The short data value.
7578 *
7579 * @return Returns the same Intent object, for chaining multiple calls
7580 * into a single statement.
7581 *
7582 * @see #putExtras
7583 * @see #removeExtra
7584 * @see #getShortExtra(String, short)
7585 */
7586 public Intent putExtra(String name, short value) {
7587 if (mExtras == null) {
7588 mExtras = new Bundle();
7589 }
7590 mExtras.putShort(name, value);
7591 return this;
7592 }
7593
7594 /**
7595 * Add extended data to the intent. The name must include a package
7596 * prefix, for example the app com.android.contacts would use names
7597 * like "com.android.contacts.ShowAll".
7598 *
7599 * @param name The name of the extra data, with package prefix.
7600 * @param value The integer data value.
7601 *
7602 * @return Returns the same Intent object, for chaining multiple calls
7603 * into a single statement.
7604 *
7605 * @see #putExtras
7606 * @see #removeExtra
7607 * @see #getIntExtra(String, int)
7608 */
7609 public Intent putExtra(String name, int value) {
7610 if (mExtras == null) {
7611 mExtras = new Bundle();
7612 }
7613 mExtras.putInt(name, value);
7614 return this;
7615 }
7616
7617 /**
7618 * Add extended data to the intent. The name must include a package
7619 * prefix, for example the app com.android.contacts would use names
7620 * like "com.android.contacts.ShowAll".
7621 *
7622 * @param name The name of the extra data, with package prefix.
7623 * @param value The long data value.
7624 *
7625 * @return Returns the same Intent object, for chaining multiple calls
7626 * into a single statement.
7627 *
7628 * @see #putExtras
7629 * @see #removeExtra
7630 * @see #getLongExtra(String, long)
7631 */
7632 public Intent putExtra(String name, long value) {
7633 if (mExtras == null) {
7634 mExtras = new Bundle();
7635 }
7636 mExtras.putLong(name, value);
7637 return this;
7638 }
7639
7640 /**
7641 * Add extended data to the intent. The name must include a package
7642 * prefix, for example the app com.android.contacts would use names
7643 * like "com.android.contacts.ShowAll".
7644 *
7645 * @param name The name of the extra data, with package prefix.
7646 * @param value The float data value.
7647 *
7648 * @return Returns the same Intent object, for chaining multiple calls
7649 * into a single statement.
7650 *
7651 * @see #putExtras
7652 * @see #removeExtra
7653 * @see #getFloatExtra(String, float)
7654 */
7655 public Intent putExtra(String name, float value) {
7656 if (mExtras == null) {
7657 mExtras = new Bundle();
7658 }
7659 mExtras.putFloat(name, value);
7660 return this;
7661 }
7662
7663 /**
7664 * Add extended data to the intent. The name must include a package
7665 * prefix, for example the app com.android.contacts would use names
7666 * like "com.android.contacts.ShowAll".
7667 *
7668 * @param name The name of the extra data, with package prefix.
7669 * @param value The double data value.
7670 *
7671 * @return Returns the same Intent object, for chaining multiple calls
7672 * into a single statement.
7673 *
7674 * @see #putExtras
7675 * @see #removeExtra
7676 * @see #getDoubleExtra(String, double)
7677 */
7678 public Intent putExtra(String name, double value) {
7679 if (mExtras == null) {
7680 mExtras = new Bundle();
7681 }
7682 mExtras.putDouble(name, value);
7683 return this;
7684 }
7685
7686 /**
7687 * Add extended data to the intent. The name must include a package
7688 * prefix, for example the app com.android.contacts would use names
7689 * like "com.android.contacts.ShowAll".
7690 *
7691 * @param name The name of the extra data, with package prefix.
7692 * @param value The String data value.
7693 *
7694 * @return Returns the same Intent object, for chaining multiple calls
7695 * into a single statement.
7696 *
7697 * @see #putExtras
7698 * @see #removeExtra
7699 * @see #getStringExtra(String)
7700 */
7701 public Intent putExtra(String name, String value) {
7702 if (mExtras == null) {
7703 mExtras = new Bundle();
7704 }
7705 mExtras.putString(name, value);
7706 return this;
7707 }
7708
7709 /**
7710 * Add extended data to the intent. The name must include a package
7711 * prefix, for example the app com.android.contacts would use names
7712 * like "com.android.contacts.ShowAll".
7713 *
7714 * @param name The name of the extra data, with package prefix.
7715 * @param value The CharSequence data value.
7716 *
7717 * @return Returns the same Intent object, for chaining multiple calls
7718 * into a single statement.
7719 *
7720 * @see #putExtras
7721 * @see #removeExtra
7722 * @see #getCharSequenceExtra(String)
7723 */
7724 public Intent putExtra(String name, CharSequence value) {
7725 if (mExtras == null) {
7726 mExtras = new Bundle();
7727 }
7728 mExtras.putCharSequence(name, value);
7729 return this;
7730 }
7731
7732 /**
7733 * Add extended data to the intent. The name must include a package
7734 * prefix, for example the app com.android.contacts would use names
7735 * like "com.android.contacts.ShowAll".
7736 *
7737 * @param name The name of the extra data, with package prefix.
7738 * @param value The Parcelable data value.
7739 *
7740 * @return Returns the same Intent object, for chaining multiple calls
7741 * into a single statement.
7742 *
7743 * @see #putExtras
7744 * @see #removeExtra
7745 * @see #getParcelableExtra(String)
7746 */
7747 public Intent putExtra(String name, Parcelable value) {
7748 if (mExtras == null) {
7749 mExtras = new Bundle();
7750 }
7751 mExtras.putParcelable(name, value);
7752 return this;
7753 }
7754
7755 /**
7756 * Add extended data to the intent. The name must include a package
7757 * prefix, for example the app com.android.contacts would use names
7758 * like "com.android.contacts.ShowAll".
7759 *
7760 * @param name The name of the extra data, with package prefix.
7761 * @param value The Parcelable[] data value.
7762 *
7763 * @return Returns the same Intent object, for chaining multiple calls
7764 * into a single statement.
7765 *
7766 * @see #putExtras
7767 * @see #removeExtra
7768 * @see #getParcelableArrayExtra(String)
7769 */
7770 public Intent putExtra(String name, Parcelable[] value) {
7771 if (mExtras == null) {
7772 mExtras = new Bundle();
7773 }
7774 mExtras.putParcelableArray(name, value);
7775 return this;
7776 }
7777
7778 /**
7779 * Add extended data to the intent. The name must include a package
7780 * prefix, for example the app com.android.contacts would use names
7781 * like "com.android.contacts.ShowAll".
7782 *
7783 * @param name The name of the extra data, with package prefix.
7784 * @param value The ArrayList<Parcelable> data value.
7785 *
7786 * @return Returns the same Intent object, for chaining multiple calls
7787 * into a single statement.
7788 *
7789 * @see #putExtras
7790 * @see #removeExtra
7791 * @see #getParcelableArrayListExtra(String)
7792 */
7793 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7794 if (mExtras == null) {
7795 mExtras = new Bundle();
7796 }
7797 mExtras.putParcelableArrayList(name, value);
7798 return this;
7799 }
7800
7801 /**
7802 * Add extended data to the intent. The name must include a package
7803 * prefix, for example the app com.android.contacts would use names
7804 * like "com.android.contacts.ShowAll".
7805 *
7806 * @param name The name of the extra data, with package prefix.
7807 * @param value The ArrayList<Integer> data value.
7808 *
7809 * @return Returns the same Intent object, for chaining multiple calls
7810 * into a single statement.
7811 *
7812 * @see #putExtras
7813 * @see #removeExtra
7814 * @see #getIntegerArrayListExtra(String)
7815 */
7816 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7817 if (mExtras == null) {
7818 mExtras = new Bundle();
7819 }
7820 mExtras.putIntegerArrayList(name, value);
7821 return this;
7822 }
7823
7824 /**
7825 * Add extended data to the intent. The name must include a package
7826 * prefix, for example the app com.android.contacts would use names
7827 * like "com.android.contacts.ShowAll".
7828 *
7829 * @param name The name of the extra data, with package prefix.
7830 * @param value The ArrayList<String> data value.
7831 *
7832 * @return Returns the same Intent object, for chaining multiple calls
7833 * into a single statement.
7834 *
7835 * @see #putExtras
7836 * @see #removeExtra
7837 * @see #getStringArrayListExtra(String)
7838 */
7839 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7840 if (mExtras == null) {
7841 mExtras = new Bundle();
7842 }
7843 mExtras.putStringArrayList(name, value);
7844 return this;
7845 }
7846
7847 /**
7848 * Add extended data to the intent. The name must include a package
7849 * prefix, for example the app com.android.contacts would use names
7850 * like "com.android.contacts.ShowAll".
7851 *
7852 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007853 * @param value The ArrayList<CharSequence> data value.
7854 *
7855 * @return Returns the same Intent object, for chaining multiple calls
7856 * into a single statement.
7857 *
7858 * @see #putExtras
7859 * @see #removeExtra
7860 * @see #getCharSequenceArrayListExtra(String)
7861 */
7862 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7863 if (mExtras == null) {
7864 mExtras = new Bundle();
7865 }
7866 mExtras.putCharSequenceArrayList(name, value);
7867 return this;
7868 }
7869
7870 /**
7871 * Add extended data to the intent. The name must include a package
7872 * prefix, for example the app com.android.contacts would use names
7873 * like "com.android.contacts.ShowAll".
7874 *
7875 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007876 * @param value The Serializable data value.
7877 *
7878 * @return Returns the same Intent object, for chaining multiple calls
7879 * into a single statement.
7880 *
7881 * @see #putExtras
7882 * @see #removeExtra
7883 * @see #getSerializableExtra(String)
7884 */
7885 public Intent putExtra(String name, Serializable value) {
7886 if (mExtras == null) {
7887 mExtras = new Bundle();
7888 }
7889 mExtras.putSerializable(name, value);
7890 return this;
7891 }
7892
7893 /**
7894 * Add extended data to the intent. The name must include a package
7895 * prefix, for example the app com.android.contacts would use names
7896 * like "com.android.contacts.ShowAll".
7897 *
7898 * @param name The name of the extra data, with package prefix.
7899 * @param value The boolean array data value.
7900 *
7901 * @return Returns the same Intent object, for chaining multiple calls
7902 * into a single statement.
7903 *
7904 * @see #putExtras
7905 * @see #removeExtra
7906 * @see #getBooleanArrayExtra(String)
7907 */
7908 public Intent putExtra(String name, boolean[] value) {
7909 if (mExtras == null) {
7910 mExtras = new Bundle();
7911 }
7912 mExtras.putBooleanArray(name, value);
7913 return this;
7914 }
7915
7916 /**
7917 * Add extended data to the intent. The name must include a package
7918 * prefix, for example the app com.android.contacts would use names
7919 * like "com.android.contacts.ShowAll".
7920 *
7921 * @param name The name of the extra data, with package prefix.
7922 * @param value The byte array data value.
7923 *
7924 * @return Returns the same Intent object, for chaining multiple calls
7925 * into a single statement.
7926 *
7927 * @see #putExtras
7928 * @see #removeExtra
7929 * @see #getByteArrayExtra(String)
7930 */
7931 public Intent putExtra(String name, byte[] value) {
7932 if (mExtras == null) {
7933 mExtras = new Bundle();
7934 }
7935 mExtras.putByteArray(name, value);
7936 return this;
7937 }
7938
7939 /**
7940 * Add extended data to the intent. The name must include a package
7941 * prefix, for example the app com.android.contacts would use names
7942 * like "com.android.contacts.ShowAll".
7943 *
7944 * @param name The name of the extra data, with package prefix.
7945 * @param value The short array data value.
7946 *
7947 * @return Returns the same Intent object, for chaining multiple calls
7948 * into a single statement.
7949 *
7950 * @see #putExtras
7951 * @see #removeExtra
7952 * @see #getShortArrayExtra(String)
7953 */
7954 public Intent putExtra(String name, short[] value) {
7955 if (mExtras == null) {
7956 mExtras = new Bundle();
7957 }
7958 mExtras.putShortArray(name, value);
7959 return this;
7960 }
7961
7962 /**
7963 * Add extended data to the intent. The name must include a package
7964 * prefix, for example the app com.android.contacts would use names
7965 * like "com.android.contacts.ShowAll".
7966 *
7967 * @param name The name of the extra data, with package prefix.
7968 * @param value The char array data value.
7969 *
7970 * @return Returns the same Intent object, for chaining multiple calls
7971 * into a single statement.
7972 *
7973 * @see #putExtras
7974 * @see #removeExtra
7975 * @see #getCharArrayExtra(String)
7976 */
7977 public Intent putExtra(String name, char[] value) {
7978 if (mExtras == null) {
7979 mExtras = new Bundle();
7980 }
7981 mExtras.putCharArray(name, value);
7982 return this;
7983 }
7984
7985 /**
7986 * Add extended data to the intent. The name must include a package
7987 * prefix, for example the app com.android.contacts would use names
7988 * like "com.android.contacts.ShowAll".
7989 *
7990 * @param name The name of the extra data, with package prefix.
7991 * @param value The int array data value.
7992 *
7993 * @return Returns the same Intent object, for chaining multiple calls
7994 * into a single statement.
7995 *
7996 * @see #putExtras
7997 * @see #removeExtra
7998 * @see #getIntArrayExtra(String)
7999 */
8000 public Intent putExtra(String name, int[] value) {
8001 if (mExtras == null) {
8002 mExtras = new Bundle();
8003 }
8004 mExtras.putIntArray(name, value);
8005 return this;
8006 }
8007
8008 /**
8009 * Add extended data to the intent. The name must include a package
8010 * prefix, for example the app com.android.contacts would use names
8011 * like "com.android.contacts.ShowAll".
8012 *
8013 * @param name The name of the extra data, with package prefix.
8014 * @param value The byte array data value.
8015 *
8016 * @return Returns the same Intent object, for chaining multiple calls
8017 * into a single statement.
8018 *
8019 * @see #putExtras
8020 * @see #removeExtra
8021 * @see #getLongArrayExtra(String)
8022 */
8023 public Intent putExtra(String name, long[] value) {
8024 if (mExtras == null) {
8025 mExtras = new Bundle();
8026 }
8027 mExtras.putLongArray(name, value);
8028 return this;
8029 }
8030
8031 /**
8032 * Add extended data to the intent. The name must include a package
8033 * prefix, for example the app com.android.contacts would use names
8034 * like "com.android.contacts.ShowAll".
8035 *
8036 * @param name The name of the extra data, with package prefix.
8037 * @param value The float array data value.
8038 *
8039 * @return Returns the same Intent object, for chaining multiple calls
8040 * into a single statement.
8041 *
8042 * @see #putExtras
8043 * @see #removeExtra
8044 * @see #getFloatArrayExtra(String)
8045 */
8046 public Intent putExtra(String name, float[] value) {
8047 if (mExtras == null) {
8048 mExtras = new Bundle();
8049 }
8050 mExtras.putFloatArray(name, value);
8051 return this;
8052 }
8053
8054 /**
8055 * Add extended data to the intent. The name must include a package
8056 * prefix, for example the app com.android.contacts would use names
8057 * like "com.android.contacts.ShowAll".
8058 *
8059 * @param name The name of the extra data, with package prefix.
8060 * @param value The double array data value.
8061 *
8062 * @return Returns the same Intent object, for chaining multiple calls
8063 * into a single statement.
8064 *
8065 * @see #putExtras
8066 * @see #removeExtra
8067 * @see #getDoubleArrayExtra(String)
8068 */
8069 public Intent putExtra(String name, double[] value) {
8070 if (mExtras == null) {
8071 mExtras = new Bundle();
8072 }
8073 mExtras.putDoubleArray(name, value);
8074 return this;
8075 }
8076
8077 /**
8078 * Add extended data to the intent. The name must include a package
8079 * prefix, for example the app com.android.contacts would use names
8080 * like "com.android.contacts.ShowAll".
8081 *
8082 * @param name The name of the extra data, with package prefix.
8083 * @param value The String array data value.
8084 *
8085 * @return Returns the same Intent object, for chaining multiple calls
8086 * into a single statement.
8087 *
8088 * @see #putExtras
8089 * @see #removeExtra
8090 * @see #getStringArrayExtra(String)
8091 */
8092 public Intent putExtra(String name, String[] value) {
8093 if (mExtras == null) {
8094 mExtras = new Bundle();
8095 }
8096 mExtras.putStringArray(name, value);
8097 return this;
8098 }
8099
8100 /**
8101 * Add extended data to the intent. The name must include a package
8102 * prefix, for example the app com.android.contacts would use names
8103 * like "com.android.contacts.ShowAll".
8104 *
8105 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008106 * @param value The CharSequence array data value.
8107 *
8108 * @return Returns the same Intent object, for chaining multiple calls
8109 * into a single statement.
8110 *
8111 * @see #putExtras
8112 * @see #removeExtra
8113 * @see #getCharSequenceArrayExtra(String)
8114 */
8115 public Intent putExtra(String name, CharSequence[] value) {
8116 if (mExtras == null) {
8117 mExtras = new Bundle();
8118 }
8119 mExtras.putCharSequenceArray(name, value);
8120 return this;
8121 }
8122
8123 /**
8124 * Add extended data to the intent. The name must include a package
8125 * prefix, for example the app com.android.contacts would use names
8126 * like "com.android.contacts.ShowAll".
8127 *
8128 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008129 * @param value The Bundle data value.
8130 *
8131 * @return Returns the same Intent object, for chaining multiple calls
8132 * into a single statement.
8133 *
8134 * @see #putExtras
8135 * @see #removeExtra
8136 * @see #getBundleExtra(String)
8137 */
8138 public Intent putExtra(String name, Bundle value) {
8139 if (mExtras == null) {
8140 mExtras = new Bundle();
8141 }
8142 mExtras.putBundle(name, value);
8143 return this;
8144 }
8145
8146 /**
8147 * Add extended data to the intent. The name must include a package
8148 * prefix, for example the app com.android.contacts would use names
8149 * like "com.android.contacts.ShowAll".
8150 *
8151 * @param name The name of the extra data, with package prefix.
8152 * @param value The IBinder data value.
8153 *
8154 * @return Returns the same Intent object, for chaining multiple calls
8155 * into a single statement.
8156 *
8157 * @see #putExtras
8158 * @see #removeExtra
8159 * @see #getIBinderExtra(String)
8160 *
8161 * @deprecated
8162 * @hide
8163 */
8164 @Deprecated
8165 public Intent putExtra(String name, IBinder value) {
8166 if (mExtras == null) {
8167 mExtras = new Bundle();
8168 }
8169 mExtras.putIBinder(name, value);
8170 return this;
8171 }
8172
8173 /**
8174 * Copy all extras in 'src' in to this intent.
8175 *
8176 * @param src Contains the extras to copy.
8177 *
8178 * @see #putExtra
8179 */
8180 public Intent putExtras(Intent src) {
8181 if (src.mExtras != null) {
8182 if (mExtras == null) {
8183 mExtras = new Bundle(src.mExtras);
8184 } else {
8185 mExtras.putAll(src.mExtras);
8186 }
8187 }
8188 return this;
8189 }
8190
8191 /**
8192 * Add a set of extended data to the intent. The keys must include a package
8193 * prefix, for example the app com.android.contacts would use names
8194 * like "com.android.contacts.ShowAll".
8195 *
8196 * @param extras The Bundle of extras to add to this intent.
8197 *
8198 * @see #putExtra
8199 * @see #removeExtra
8200 */
8201 public Intent putExtras(Bundle extras) {
8202 if (mExtras == null) {
8203 mExtras = new Bundle();
8204 }
8205 mExtras.putAll(extras);
8206 return this;
8207 }
8208
8209 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008210 * Completely replace the extras in the Intent with the extras in the
8211 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008212 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008213 * @param src The exact extras contained in this Intent are copied
8214 * into the target intent, replacing any that were previously there.
8215 */
8216 public Intent replaceExtras(Intent src) {
8217 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8218 return this;
8219 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008220
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008221 /**
8222 * Completely replace the extras in the Intent with the given Bundle of
8223 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008224 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008225 * @param extras The new set of extras in the Intent, or null to erase
8226 * all extras.
8227 */
8228 public Intent replaceExtras(Bundle extras) {
8229 mExtras = extras != null ? new Bundle(extras) : null;
8230 return this;
8231 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008232
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008233 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008234 * Remove extended data from the intent.
8235 *
8236 * @see #putExtra
8237 */
8238 public void removeExtra(String name) {
8239 if (mExtras != null) {
8240 mExtras.remove(name);
8241 if (mExtras.size() == 0) {
8242 mExtras = null;
8243 }
8244 }
8245 }
8246
8247 /**
8248 * Set special flags controlling how this intent is handled. Most values
8249 * here depend on the type of component being executed by the Intent,
8250 * specifically the FLAG_ACTIVITY_* flags are all for use with
8251 * {@link Context#startActivity Context.startActivity()} and the
8252 * FLAG_RECEIVER_* flags are all for use with
8253 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8254 *
Scott Main7aee61f2011-02-08 11:25:01 -08008255 * <p>See the
8256 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8257 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008258 * the behavior of your application.
8259 *
8260 * @param flags The desired flags.
8261 *
8262 * @return Returns the same Intent object, for chaining multiple calls
8263 * into a single statement.
8264 *
8265 * @see #getFlags
8266 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008267 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008268 *
8269 * @see #FLAG_GRANT_READ_URI_PERMISSION
8270 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008271 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8272 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008273 * @see #FLAG_DEBUG_LOG_RESOLUTION
8274 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008275 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008276 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008277 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008278 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008279 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8280 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008281 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008282 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008283 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008284 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008285 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008286 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008287 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008288 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8289 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008290 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008291 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008292 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008293 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8294 */
8295 public Intent setFlags(int flags) {
8296 mFlags = flags;
8297 return this;
8298 }
8299
8300 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008301 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008302 *
8303 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008304 * @return Returns the same Intent object, for chaining multiple calls into
8305 * a single statement.
8306 * @see #setFlags(int)
8307 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008308 */
8309 public Intent addFlags(int flags) {
8310 mFlags |= flags;
8311 return this;
8312 }
8313
8314 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008315 * Remove these flags from the intent.
8316 *
8317 * @param flags The flags to remove.
8318 * @see #setFlags(int)
8319 * @see #addFlags(int)
8320 */
8321 public void removeFlags(int flags) {
8322 mFlags &= ~flags;
8323 }
8324
8325 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008326 * (Usually optional) Set an explicit application package name that limits
8327 * the components this Intent will resolve to. If left to the default
8328 * value of null, all components in all applications will considered.
8329 * If non-null, the Intent can only match the components in the given
8330 * application package.
8331 *
8332 * @param packageName The name of the application package to handle the
8333 * intent, or null to allow any application package.
8334 *
8335 * @return Returns the same Intent object, for chaining multiple calls
8336 * into a single statement.
8337 *
8338 * @see #getPackage
8339 * @see #resolveActivity
8340 */
8341 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008342 if (packageName != null && mSelector != null) {
8343 throw new IllegalArgumentException(
8344 "Can't set package name when selector is already set");
8345 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008346 mPackage = packageName;
8347 return this;
8348 }
8349
8350 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008351 * (Usually optional) Explicitly set the component to handle the intent.
8352 * If left with the default value of null, the system will determine the
8353 * appropriate class to use based on the other fields (action, data,
8354 * type, categories) in the Intent. If this class is defined, the
8355 * specified class will always be used regardless of the other fields. You
8356 * should only set this value when you know you absolutely want a specific
8357 * class to be used; otherwise it is better to let the system find the
8358 * appropriate class so that you will respect the installed applications
8359 * and user preferences.
8360 *
8361 * @param component The name of the application component to handle the
8362 * intent, or null to let the system find one for you.
8363 *
8364 * @return Returns the same Intent object, for chaining multiple calls
8365 * into a single statement.
8366 *
8367 * @see #setClass
8368 * @see #setClassName(Context, String)
8369 * @see #setClassName(String, String)
8370 * @see #getComponent
8371 * @see #resolveActivity
8372 */
8373 public Intent setComponent(ComponentName component) {
8374 mComponent = component;
8375 return this;
8376 }
8377
8378 /**
8379 * Convenience for calling {@link #setComponent} with an
8380 * explicit class name.
8381 *
8382 * @param packageContext A Context of the application package implementing
8383 * this class.
8384 * @param className The name of a class inside of the application package
8385 * that will be used as the component for this Intent.
8386 *
8387 * @return Returns the same Intent object, for chaining multiple calls
8388 * into a single statement.
8389 *
8390 * @see #setComponent
8391 * @see #setClass
8392 */
8393 public Intent setClassName(Context packageContext, String className) {
8394 mComponent = new ComponentName(packageContext, className);
8395 return this;
8396 }
8397
8398 /**
8399 * Convenience for calling {@link #setComponent} with an
8400 * explicit application package name and class name.
8401 *
8402 * @param packageName The name of the package implementing the desired
8403 * component.
8404 * @param className The name of a class inside of the application package
8405 * that will be used as the component for this Intent.
8406 *
8407 * @return Returns the same Intent object, for chaining multiple calls
8408 * into a single statement.
8409 *
8410 * @see #setComponent
8411 * @see #setClass
8412 */
8413 public Intent setClassName(String packageName, String className) {
8414 mComponent = new ComponentName(packageName, className);
8415 return this;
8416 }
8417
8418 /**
8419 * Convenience for calling {@link #setComponent(ComponentName)} with the
8420 * name returned by a {@link Class} object.
8421 *
8422 * @param packageContext A Context of the application package implementing
8423 * this class.
8424 * @param cls The class name to set, equivalent to
8425 * <code>setClassName(context, cls.getName())</code>.
8426 *
8427 * @return Returns the same Intent object, for chaining multiple calls
8428 * into a single statement.
8429 *
8430 * @see #setComponent
8431 */
8432 public Intent setClass(Context packageContext, Class<?> cls) {
8433 mComponent = new ComponentName(packageContext, cls);
8434 return this;
8435 }
8436
8437 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008438 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8439 * used as a hint to the receiver for animations and the like. Null means that there
8440 * is no source bounds.
8441 */
8442 public void setSourceBounds(Rect r) {
8443 if (r != null) {
8444 mSourceBounds = new Rect(r);
8445 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008446 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008447 }
8448 }
8449
Tor Norbyed9273d62013-05-30 15:59:53 -07008450 /** @hide */
8451 @IntDef(flag = true,
8452 value = {
8453 FILL_IN_ACTION,
8454 FILL_IN_DATA,
8455 FILL_IN_CATEGORIES,
8456 FILL_IN_COMPONENT,
8457 FILL_IN_PACKAGE,
8458 FILL_IN_SOURCE_BOUNDS,
8459 FILL_IN_SELECTOR,
8460 FILL_IN_CLIP_DATA
8461 })
8462 @Retention(RetentionPolicy.SOURCE)
8463 public @interface FillInFlags {}
8464
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008465 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008466 * Use with {@link #fillIn} to allow the current action value to be
8467 * overwritten, even if it is already set.
8468 */
8469 public static final int FILL_IN_ACTION = 1<<0;
8470
8471 /**
8472 * Use with {@link #fillIn} to allow the current data or type value
8473 * overwritten, even if it is already set.
8474 */
8475 public static final int FILL_IN_DATA = 1<<1;
8476
8477 /**
8478 * Use with {@link #fillIn} to allow the current categories to be
8479 * overwritten, even if they are already set.
8480 */
8481 public static final int FILL_IN_CATEGORIES = 1<<2;
8482
8483 /**
8484 * Use with {@link #fillIn} to allow the current component value to be
8485 * overwritten, even if it is already set.
8486 */
8487 public static final int FILL_IN_COMPONENT = 1<<3;
8488
8489 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008490 * Use with {@link #fillIn} to allow the current package value to be
8491 * overwritten, even if it is already set.
8492 */
8493 public static final int FILL_IN_PACKAGE = 1<<4;
8494
8495 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008496 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008497 * overwritten, even if it is already set.
8498 */
8499 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8500
8501 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008502 * Use with {@link #fillIn} to allow the current selector to be
8503 * overwritten, even if it is already set.
8504 */
8505 public static final int FILL_IN_SELECTOR = 1<<6;
8506
8507 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008508 * Use with {@link #fillIn} to allow the current ClipData to be
8509 * overwritten, even if it is already set.
8510 */
8511 public static final int FILL_IN_CLIP_DATA = 1<<7;
8512
8513 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008514 * Copy the contents of <var>other</var> in to this object, but only
8515 * where fields are not defined by this object. For purposes of a field
8516 * being defined, the following pieces of data in the Intent are
8517 * considered to be separate fields:
8518 *
8519 * <ul>
8520 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008521 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008522 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8523 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008524 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008525 * <li> component, as set by {@link #setComponent(ComponentName)} or
8526 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008527 * <li> source bounds, as set by {@link #setSourceBounds}.
8528 * <li> selector, as set by {@link #setSelector(Intent)}.
8529 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008530 * <li> each top-level name in the associated extras.
8531 * </ul>
8532 *
8533 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008534 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008535 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8536 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8537 * the restriction where the corresponding field will not be replaced if
8538 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008539 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008540 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8541 * is explicitly specified. The selector will only be copied if
8542 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008543 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008544 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8545 * and Intent B with {action="gotit", data-type="some/thing",
8546 * categories="one","two"}.
8547 *
8548 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8549 * containing: {action="gotit", data-type="some/thing",
8550 * categories="bar"}.
8551 *
8552 * @param other Another Intent whose values are to be used to fill in
8553 * the current one.
8554 * @param flags Options to control which fields can be filled in.
8555 *
8556 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008557 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008558 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008559 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008560 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008561 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008562 @FillInFlags
8563 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008564 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008565 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008566 if (other.mAction != null
8567 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008568 mAction = other.mAction;
8569 changes |= FILL_IN_ACTION;
8570 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008571 if ((other.mData != null || other.mType != null)
8572 && ((mData == null && mType == null)
8573 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008574 mData = other.mData;
8575 mType = other.mType;
8576 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008577 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008578 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008579 if (other.mCategories != null
8580 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008582 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 }
8584 changes |= FILL_IN_CATEGORIES;
8585 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008586 if (other.mPackage != null
8587 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008588 // Only do this if mSelector is not set.
8589 if (mSelector == null) {
8590 mPackage = other.mPackage;
8591 changes |= FILL_IN_PACKAGE;
8592 }
8593 }
8594 // Selector is special: it can only be set if explicitly allowed,
8595 // for the same reason as the component name.
8596 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8597 if (mPackage == null) {
8598 mSelector = new Intent(other.mSelector);
8599 mPackage = null;
8600 changes |= FILL_IN_SELECTOR;
8601 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008602 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008603 if (other.mClipData != null
8604 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8605 mClipData = other.mClipData;
8606 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008607 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008608 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008609 // Component is special: it can -only- be set if explicitly allowed,
8610 // since otherwise the sender could force the intent somewhere the
8611 // originator didn't intend.
8612 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008613 mComponent = other.mComponent;
8614 changes |= FILL_IN_COMPONENT;
8615 }
8616 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008617 if (other.mSourceBounds != null
8618 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8619 mSourceBounds = new Rect(other.mSourceBounds);
8620 changes |= FILL_IN_SOURCE_BOUNDS;
8621 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008622 if (mExtras == null) {
8623 if (other.mExtras != null) {
8624 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008625 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008626 }
8627 } else if (other.mExtras != null) {
8628 try {
8629 Bundle newb = new Bundle(other.mExtras);
8630 newb.putAll(mExtras);
8631 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008632 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008633 } catch (RuntimeException e) {
8634 // Modifying the extras can cause us to unparcel the contents
8635 // of the bundle, and if we do this in the system process that
8636 // may fail. We really should handle this (i.e., the Bundle
8637 // impl shouldn't be on top of a plain map), but for now just
8638 // ignore it and keep the original contents. :(
8639 Log.w("Intent", "Failure filling in extras", e);
8640 }
8641 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008642 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8643 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8644 mContentUserHint = other.mContentUserHint;
8645 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008646 return changes;
8647 }
8648
8649 /**
8650 * Wrapper class holding an Intent and implementing comparisons on it for
8651 * the purpose of filtering. The class implements its
8652 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8653 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8654 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8655 * on the wrapped Intent.
8656 */
8657 public static final class FilterComparison {
8658 private final Intent mIntent;
8659 private final int mHashCode;
8660
8661 public FilterComparison(Intent intent) {
8662 mIntent = intent;
8663 mHashCode = intent.filterHashCode();
8664 }
8665
8666 /**
8667 * Return the Intent that this FilterComparison represents.
8668 * @return Returns the Intent held by the FilterComparison. Do
8669 * not modify!
8670 */
8671 public Intent getIntent() {
8672 return mIntent;
8673 }
8674
8675 @Override
8676 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008677 if (obj instanceof FilterComparison) {
8678 Intent other = ((FilterComparison)obj).mIntent;
8679 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008680 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008681 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008682 }
8683
8684 @Override
8685 public int hashCode() {
8686 return mHashCode;
8687 }
8688 }
8689
8690 /**
8691 * Determine if two intents are the same for the purposes of intent
8692 * resolution (filtering). That is, if their action, data, type,
8693 * class, and categories are the same. This does <em>not</em> compare
8694 * any extra data included in the intents.
8695 *
8696 * @param other The other Intent to compare against.
8697 *
8698 * @return Returns true if action, data, type, class, and categories
8699 * are the same.
8700 */
8701 public boolean filterEquals(Intent other) {
8702 if (other == null) {
8703 return false;
8704 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008705 if (!Objects.equals(this.mAction, other.mAction)) return false;
8706 if (!Objects.equals(this.mData, other.mData)) return false;
8707 if (!Objects.equals(this.mType, other.mType)) return false;
8708 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8709 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8710 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008711
8712 return true;
8713 }
8714
8715 /**
8716 * Generate hash code that matches semantics of filterEquals().
8717 *
8718 * @return Returns the hash value of the action, data, type, class, and
8719 * categories.
8720 *
8721 * @see #filterEquals
8722 */
8723 public int filterHashCode() {
8724 int code = 0;
8725 if (mAction != null) {
8726 code += mAction.hashCode();
8727 }
8728 if (mData != null) {
8729 code += mData.hashCode();
8730 }
8731 if (mType != null) {
8732 code += mType.hashCode();
8733 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008734 if (mPackage != null) {
8735 code += mPackage.hashCode();
8736 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008737 if (mComponent != null) {
8738 code += mComponent.hashCode();
8739 }
8740 if (mCategories != null) {
8741 code += mCategories.hashCode();
8742 }
8743 return code;
8744 }
8745
8746 @Override
8747 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008748 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008749
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008750 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008751 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008752 b.append(" }");
8753
8754 return b.toString();
8755 }
8756
8757 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008758 public String toInsecureString() {
8759 StringBuilder b = new StringBuilder(128);
8760
8761 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008762 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008763 b.append(" }");
8764
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008765 return b.toString();
8766 }
Romain Guy4969af72009-06-17 10:53:19 -07008767
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008768 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008769 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008770 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008771
8772 b.append("Intent { ");
8773 toShortString(b, false, true, true, true);
8774 b.append(" }");
8775
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008776 return b.toString();
8777 }
8778
8779 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008780 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8781 StringBuilder b = new StringBuilder(128);
8782 toShortString(b, secure, comp, extras, clip);
8783 return b.toString();
8784 }
8785
8786 /** @hide */
8787 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8788 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008789 boolean first = true;
8790 if (mAction != null) {
8791 b.append("act=").append(mAction);
8792 first = false;
8793 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008794 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008795 if (!first) {
8796 b.append(' ');
8797 }
8798 first = false;
8799 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008800 for (int i=0; i<mCategories.size(); i++) {
8801 if (i > 0) b.append(',');
8802 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008803 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008804 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008805 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008806 if (mData != null) {
8807 if (!first) {
8808 b.append(' ');
8809 }
8810 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008811 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008812 if (secure) {
8813 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008814 } else {
8815 b.append(mData);
8816 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008817 }
8818 if (mType != null) {
8819 if (!first) {
8820 b.append(' ');
8821 }
8822 first = false;
8823 b.append("typ=").append(mType);
8824 }
8825 if (mFlags != 0) {
8826 if (!first) {
8827 b.append(' ');
8828 }
8829 first = false;
8830 b.append("flg=0x").append(Integer.toHexString(mFlags));
8831 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008832 if (mPackage != null) {
8833 if (!first) {
8834 b.append(' ');
8835 }
8836 first = false;
8837 b.append("pkg=").append(mPackage);
8838 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008839 if (comp && mComponent != null) {
8840 if (!first) {
8841 b.append(' ');
8842 }
8843 first = false;
8844 b.append("cmp=").append(mComponent.flattenToShortString());
8845 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008846 if (mSourceBounds != null) {
8847 if (!first) {
8848 b.append(' ');
8849 }
8850 first = false;
8851 b.append("bnds=").append(mSourceBounds.toShortString());
8852 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008853 if (mClipData != null) {
8854 if (!first) {
8855 b.append(' ');
8856 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008857 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008858 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008859 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008860 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008861 if (mClipData.getDescription() != null) {
8862 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8863 } else {
8864 first = true;
8865 }
8866 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008867 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008868 first = false;
8869 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008870 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008871 if (extras && mExtras != null) {
8872 if (!first) {
8873 b.append(' ');
8874 }
8875 first = false;
8876 b.append("(has extras)");
8877 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008878 if (mContentUserHint != UserHandle.USER_CURRENT) {
8879 if (!first) {
8880 b.append(' ');
8881 }
8882 first = false;
8883 b.append("u=").append(mContentUserHint);
8884 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008885 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008886 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008887 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008888 b.append("}");
8889 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008890 }
8891
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008892 /**
8893 * Call {@link #toUri} with 0 flags.
8894 * @deprecated Use {@link #toUri} instead.
8895 */
8896 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008897 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008898 return toUri(0);
8899 }
8900
8901 /**
8902 * Convert this Intent into a String holding a URI representation of it.
8903 * The returned URI string has been properly URI encoded, so it can be
8904 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8905 * Intent's data as the base URI, with an additional fragment describing
8906 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008907 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008908 * <p>You can convert the returned string back to an Intent with
8909 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008910 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008911 * @param flags Additional operating flags. Either 0,
8912 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008913 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008914 * @return Returns a URI encoding URI string describing the entire contents
8915 * of the Intent.
8916 */
8917 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008918 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008919 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8920 if (mPackage == null) {
8921 throw new IllegalArgumentException(
8922 "Intent must include an explicit package name to build an android-app: "
8923 + this);
8924 }
8925 uri.append("android-app://");
8926 uri.append(mPackage);
8927 String scheme = null;
8928 if (mData != null) {
8929 scheme = mData.getScheme();
8930 if (scheme != null) {
8931 uri.append('/');
8932 uri.append(scheme);
8933 String authority = mData.getEncodedAuthority();
8934 if (authority != null) {
8935 uri.append('/');
8936 uri.append(authority);
8937 String path = mData.getEncodedPath();
8938 if (path != null) {
8939 uri.append(path);
8940 }
8941 String queryParams = mData.getEncodedQuery();
8942 if (queryParams != null) {
8943 uri.append('?');
8944 uri.append(queryParams);
8945 }
8946 String fragment = mData.getEncodedFragment();
8947 if (fragment != null) {
8948 uri.append('#');
8949 uri.append(fragment);
8950 }
8951 }
8952 }
8953 }
8954 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8955 mPackage, flags);
8956 return uri.toString();
8957 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008958 String scheme = null;
8959 if (mData != null) {
8960 String data = mData.toString();
8961 if ((flags&URI_INTENT_SCHEME) != 0) {
8962 final int N = data.length();
8963 for (int i=0; i<N; i++) {
8964 char c = data.charAt(i);
8965 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8966 || c == '.' || c == '-') {
8967 continue;
8968 }
8969 if (c == ':' && i > 0) {
8970 // Valid scheme.
8971 scheme = data.substring(0, i);
8972 uri.append("intent:");
8973 data = data.substring(i+1);
8974 break;
8975 }
Tom Taylord4a47292009-12-21 13:59:18 -08008976
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008977 // No scheme.
8978 break;
8979 }
8980 }
8981 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008982
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008983 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8984 uri.append("intent:");
8985 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008986
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008987 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008988
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008989 return uri.toString();
8990 }
8991
8992 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8993 String defPackage, int flags) {
8994 StringBuilder frag = new StringBuilder(128);
8995
8996 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008997 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008998 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008999 // Note that for now we are not going to try to handle the
9000 // data part; not clear how to represent this as a URI, and
9001 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009002 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9003 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009004 }
9005
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009006 if (frag.length() > 0) {
9007 uri.append("#Intent;");
9008 uri.append(frag);
9009 uri.append("end");
9010 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009011 }
9012
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009013 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9014 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009015 if (scheme != null) {
9016 uri.append("scheme=").append(scheme).append(';');
9017 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009018 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009019 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009020 }
9021 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009022 for (int i=0; i<mCategories.size(); i++) {
9023 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009024 }
9025 }
9026 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009027 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009028 }
9029 if (mFlags != 0) {
9030 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9031 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009032 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009033 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9034 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009035 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009036 uri.append("component=").append(Uri.encode(
9037 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009038 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009039 if (mSourceBounds != null) {
9040 uri.append("sourceBounds=")
9041 .append(Uri.encode(mSourceBounds.flattenToString()))
9042 .append(';');
9043 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009044 if (mExtras != null) {
9045 for (String key : mExtras.keySet()) {
9046 final Object value = mExtras.get(key);
9047 char entryType =
9048 value instanceof String ? 'S' :
9049 value instanceof Boolean ? 'B' :
9050 value instanceof Byte ? 'b' :
9051 value instanceof Character ? 'c' :
9052 value instanceof Double ? 'd' :
9053 value instanceof Float ? 'f' :
9054 value instanceof Integer ? 'i' :
9055 value instanceof Long ? 'l' :
9056 value instanceof Short ? 's' :
9057 '\0';
9058
9059 if (entryType != '\0') {
9060 uri.append(entryType);
9061 uri.append('.');
9062 uri.append(Uri.encode(key));
9063 uri.append('=');
9064 uri.append(Uri.encode(value.toString()));
9065 uri.append(';');
9066 }
9067 }
9068 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009069 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009070
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009071 public int describeContents() {
9072 return (mExtras != null) ? mExtras.describeContents() : 0;
9073 }
9074
9075 public void writeToParcel(Parcel out, int flags) {
9076 out.writeString(mAction);
9077 Uri.writeToParcel(out, mData);
9078 out.writeString(mType);
9079 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009080 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009081 ComponentName.writeToParcel(mComponent, out);
9082
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009083 if (mSourceBounds != null) {
9084 out.writeInt(1);
9085 mSourceBounds.writeToParcel(out, flags);
9086 } else {
9087 out.writeInt(0);
9088 }
9089
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009090 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009091 final int N = mCategories.size();
9092 out.writeInt(N);
9093 for (int i=0; i<N; i++) {
9094 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009095 }
9096 } else {
9097 out.writeInt(0);
9098 }
9099
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009100 if (mSelector != null) {
9101 out.writeInt(1);
9102 mSelector.writeToParcel(out, flags);
9103 } else {
9104 out.writeInt(0);
9105 }
9106
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009107 if (mClipData != null) {
9108 out.writeInt(1);
9109 mClipData.writeToParcel(out, flags);
9110 } else {
9111 out.writeInt(0);
9112 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009113 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 out.writeBundle(mExtras);
9115 }
9116
9117 public static final Parcelable.Creator<Intent> CREATOR
9118 = new Parcelable.Creator<Intent>() {
9119 public Intent createFromParcel(Parcel in) {
9120 return new Intent(in);
9121 }
9122 public Intent[] newArray(int size) {
9123 return new Intent[size];
9124 }
9125 };
9126
Dianne Hackborneb034652009-09-07 00:49:58 -07009127 /** @hide */
9128 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009129 readFromParcel(in);
9130 }
9131
9132 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009133 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009134 mData = Uri.CREATOR.createFromParcel(in);
9135 mType = in.readString();
9136 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009137 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009138 mComponent = ComponentName.readFromParcel(in);
9139
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009140 if (in.readInt() != 0) {
9141 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9142 }
9143
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009144 int N = in.readInt();
9145 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009146 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009147 int i;
9148 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009149 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009150 }
9151 } else {
9152 mCategories = null;
9153 }
9154
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009155 if (in.readInt() != 0) {
9156 mSelector = new Intent(in);
9157 }
9158
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009159 if (in.readInt() != 0) {
9160 mClipData = new ClipData(in);
9161 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009162 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009163 mExtras = in.readBundle();
9164 }
9165
9166 /**
9167 * Parses the "intent" element (and its children) from XML and instantiates
9168 * an Intent object. The given XML parser should be located at the tag
9169 * where parsing should start (often named "intent"), from which the
9170 * basic action, data, type, and package and class name will be
9171 * retrieved. The function will then parse in to any child elements,
9172 * looking for <category android:name="xxx"> tags to add categories and
9173 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9174 * to the intent.
9175 *
9176 * @param resources The Resources to use when inflating resources.
9177 * @param parser The XML parser pointing at an "intent" tag.
9178 * @param attrs The AttributeSet interface for retrieving extended
9179 * attribute data at the current <var>parser</var> location.
9180 * @return An Intent object matching the XML data.
9181 * @throws XmlPullParserException If there was an XML parsing error.
9182 * @throws IOException If there was an I/O error.
9183 */
9184 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9185 throws XmlPullParserException, IOException {
9186 Intent intent = new Intent();
9187
9188 TypedArray sa = resources.obtainAttributes(attrs,
9189 com.android.internal.R.styleable.Intent);
9190
9191 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9192
9193 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9194 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9195 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9196
9197 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9198 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9199 if (packageName != null && className != null) {
9200 intent.setComponent(new ComponentName(packageName, className));
9201 }
9202
9203 sa.recycle();
9204
9205 int outerDepth = parser.getDepth();
9206 int type;
9207 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9208 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9209 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9210 continue;
9211 }
9212
9213 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009214 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009215 sa = resources.obtainAttributes(attrs,
9216 com.android.internal.R.styleable.IntentCategory);
9217 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9218 sa.recycle();
9219
9220 if (cat != null) {
9221 intent.addCategory(cat);
9222 }
9223 XmlUtils.skipCurrentTag(parser);
9224
Craig Mautner21d24a22014-04-23 11:45:37 -07009225 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009226 if (intent.mExtras == null) {
9227 intent.mExtras = new Bundle();
9228 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009229 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009230 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009231
9232 } else {
9233 XmlUtils.skipCurrentTag(parser);
9234 }
9235 }
9236
9237 return intent;
9238 }
Nick Pellyccae4122012-01-09 14:12:58 -08009239
Craig Mautner21d24a22014-04-23 11:45:37 -07009240 /** @hide */
9241 public void saveToXml(XmlSerializer out) throws IOException {
9242 if (mAction != null) {
9243 out.attribute(null, ATTR_ACTION, mAction);
9244 }
9245 if (mData != null) {
9246 out.attribute(null, ATTR_DATA, mData.toString());
9247 }
9248 if (mType != null) {
9249 out.attribute(null, ATTR_TYPE, mType);
9250 }
9251 if (mComponent != null) {
9252 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9253 }
9254 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9255
9256 if (mCategories != null) {
9257 out.startTag(null, TAG_CATEGORIES);
9258 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9259 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9260 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009261 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009262 }
9263 }
9264
9265 /** @hide */
9266 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9267 XmlPullParserException {
9268 Intent intent = new Intent();
9269 final int outerDepth = in.getDepth();
9270
9271 int attrCount = in.getAttributeCount();
9272 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9273 final String attrName = in.getAttributeName(attrNdx);
9274 final String attrValue = in.getAttributeValue(attrNdx);
9275 if (ATTR_ACTION.equals(attrName)) {
9276 intent.setAction(attrValue);
9277 } else if (ATTR_DATA.equals(attrName)) {
9278 intent.setData(Uri.parse(attrValue));
9279 } else if (ATTR_TYPE.equals(attrName)) {
9280 intent.setType(attrValue);
9281 } else if (ATTR_COMPONENT.equals(attrName)) {
9282 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9283 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009284 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009285 } else {
9286 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9287 }
9288 }
9289
9290 int event;
9291 String name;
9292 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9293 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9294 if (event == XmlPullParser.START_TAG) {
9295 name = in.getName();
9296 if (TAG_CATEGORIES.equals(name)) {
9297 attrCount = in.getAttributeCount();
9298 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9299 intent.addCategory(in.getAttributeValue(attrNdx));
9300 }
9301 } else {
9302 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9303 XmlUtils.skipCurrentTag(in);
9304 }
9305 }
9306 }
9307
9308 return intent;
9309 }
9310
Nick Pellyccae4122012-01-09 14:12:58 -08009311 /**
9312 * Normalize a MIME data type.
9313 *
9314 * <p>A normalized MIME type has white-space trimmed,
9315 * content-type parameters removed, and is lower-case.
9316 * This aligns the type with Android best practices for
9317 * intent filtering.
9318 *
9319 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9320 * "text/x-vCard" becomes "text/x-vcard".
9321 *
9322 * <p>All MIME types received from outside Android (such as user input,
9323 * or external sources like Bluetooth, NFC, or the Internet) should
9324 * be normalized before they are used to create an Intent.
9325 *
9326 * @param type MIME data type to normalize
9327 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009328 * @see #setType
9329 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009330 */
9331 public static String normalizeMimeType(String type) {
9332 if (type == null) {
9333 return null;
9334 }
9335
Elliott Hughescb64d432013-08-02 10:00:44 -07009336 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009337
9338 final int semicolonIndex = type.indexOf(';');
9339 if (semicolonIndex != -1) {
9340 type = type.substring(0, semicolonIndex);
9341 }
9342 return type;
9343 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009344
9345 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009346 * Prepare this {@link Intent} to leave an app process.
9347 *
9348 * @hide
9349 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009350 public void prepareToLeaveProcess(Context context) {
9351 final boolean leavingPackage = (mComponent == null)
9352 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9353 prepareToLeaveProcess(leavingPackage);
9354 }
9355
9356 /**
9357 * Prepare this {@link Intent} to leave an app process.
9358 *
9359 * @hide
9360 */
9361 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009362 setAllowFds(false);
9363
9364 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009365 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009366 }
9367 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009368 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009369 }
9370
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009371 if (mExtras != null && !mExtras.isParcelled()) {
9372 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9373 if (intent instanceof Intent) {
9374 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9375 }
9376 }
9377
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009378 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9379 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009380 switch (mAction) {
9381 case ACTION_MEDIA_REMOVED:
9382 case ACTION_MEDIA_UNMOUNTED:
9383 case ACTION_MEDIA_CHECKING:
9384 case ACTION_MEDIA_NOFS:
9385 case ACTION_MEDIA_MOUNTED:
9386 case ACTION_MEDIA_SHARED:
9387 case ACTION_MEDIA_UNSHARED:
9388 case ACTION_MEDIA_BAD_REMOVAL:
9389 case ACTION_MEDIA_UNMOUNTABLE:
9390 case ACTION_MEDIA_EJECT:
9391 case ACTION_MEDIA_SCANNER_STARTED:
9392 case ACTION_MEDIA_SCANNER_FINISHED:
9393 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009394 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9395 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009396 // Ignore legacy actions
9397 break;
9398 default:
9399 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009400 }
9401 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009402
9403 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9404 && leavingPackage) {
9405 switch (mAction) {
9406 case ACTION_PROVIDER_CHANGED:
9407 // Ignore actions that don't need to grant
9408 break;
9409 default:
9410 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9411 }
9412 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009413 }
9414
9415 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009416 * @hide
9417 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009418 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009419 // We just entered destination process, so we should be able to read all
9420 // parcelables inside.
9421 setDefusable(true);
9422
9423 if (mSelector != null) {
9424 mSelector.prepareToEnterProcess();
9425 }
9426 if (mClipData != null) {
9427 mClipData.prepareToEnterProcess();
9428 }
9429
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009430 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009431 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9432 fixUris(mContentUserHint);
9433 mContentUserHint = UserHandle.USER_CURRENT;
9434 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009435 }
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06009436
9437 // If someone is sending us ClipData, but not EXTRA_STREAM, offer to
9438 // downgrade that content for older apps to find
9439 if (mClipData != null && mClipData.getItemCount() > 0 && !hasExtra(EXTRA_STREAM)) {
9440 final String action = getAction();
9441 if (ACTION_SEND.equals(action)) {
9442 putExtra(EXTRA_STREAM, mClipData.getItemAt(0).getUri());
9443 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
9444 final ArrayList<Uri> list = new ArrayList<>();
9445 for (int i = 0; i < mClipData.getItemCount(); i++) {
9446 list.add(mClipData.getItemAt(i).getUri());
9447 }
9448 putExtra(EXTRA_STREAM, list);
9449 }
9450 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009451 }
9452
9453 /**
9454 * @hide
9455 */
9456 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009457 Uri data = getData();
9458 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009459 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009460 }
9461 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009462 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009463 }
9464 String action = getAction();
9465 if (ACTION_SEND.equals(action)) {
9466 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9467 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009468 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009469 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009470 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009471 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9472 if (streams != null) {
9473 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9474 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009475 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009476 }
9477 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9478 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009479 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9480 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9481 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9482 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9483 if (output != null) {
9484 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9485 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009486 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009487 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009488
9489 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009490 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009491 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9492 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009493 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009494 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009495 * @hide
9496 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009497 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009498 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009499 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009500
9501 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009502 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009503
9504 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009505 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009506 // Inspect contained intents to see if we need to migrate extras. We
9507 // don't promote ClipData to the parent, since ChooserActivity will
9508 // already start the picked item as the caller, and we can't combine
9509 // the flags in a safe way.
9510
9511 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009512 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009513 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9514 if (intent != null) {
9515 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009516 }
9517 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009518 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009519 try {
9520 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9521 if (intents != null) {
9522 for (int i = 0; i < intents.length; i++) {
9523 final Intent intent = (Intent) intents[i];
9524 if (intent != null) {
9525 migrated |= intent.migrateExtraStreamToClipData();
9526 }
9527 }
9528 }
9529 } catch (ClassCastException e) {
9530 }
9531 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009532
9533 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009534 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009535 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9536 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9537 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9538 if (stream != null || text != null || htmlText != null) {
9539 final ClipData clipData = new ClipData(
9540 null, new String[] { getType() },
9541 new ClipData.Item(text, htmlText, null, stream));
9542 setClipData(clipData);
9543 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009544 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009545 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009546 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009547 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009548
9549 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009550 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009551 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9552 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9553 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9554 int num = -1;
9555 if (streams != null) {
9556 num = streams.size();
9557 }
9558 if (texts != null) {
9559 if (num >= 0 && num != texts.size()) {
9560 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009561 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009562 }
9563 num = texts.size();
9564 }
9565 if (htmlTexts != null) {
9566 if (num >= 0 && num != htmlTexts.size()) {
9567 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009568 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009569 }
9570 num = htmlTexts.size();
9571 }
9572 if (num > 0) {
9573 final ClipData clipData = new ClipData(
9574 null, new String[] { getType() },
9575 makeClipItem(streams, texts, htmlTexts, 0));
9576
9577 for (int i = 1; i < num; i++) {
9578 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9579 }
9580
9581 setClipData(clipData);
9582 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009583 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009584 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009585 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009586 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009587 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9588 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9589 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9590 final Uri output;
9591 try {
9592 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9593 } catch (ClassCastException e) {
9594 return false;
9595 }
9596 if (output != null) {
9597 setClipData(ClipData.newRawUri("", output));
9598 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9599 return true;
9600 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009601 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009602
9603 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009604 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009605
9606 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9607 ArrayList<String> htmlTexts, int which) {
9608 Uri uri = streams != null ? streams.get(which) : null;
9609 CharSequence text = texts != null ? texts.get(which) : null;
9610 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9611 return new ClipData.Item(text, htmlText, null, uri);
9612 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009613
9614 /** @hide */
9615 public boolean isDocument() {
9616 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9617 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009618}