blob: b070b63eaf94ee210ddb25792e5bed16eaa4b757 [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.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900671 * <p>Input: {@link #getData} is a mandatory content URI of the item to
672 * preview. {@link #getClipData} contains an optional list of content URIs
673 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
674 * optional index of the URI in the clip data to show first.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900675 * <p>By default quick viewers are supposed to be lightweight and focus on
676 * previewing the content only. They should not expose features such as printing,
677 * opening in an external app, deleting, rotating, casting, etc.
678 * However, if {@link #EXTRA_QUICK_VIEW_ADVANCED} is true, then the quick viewer
679 * may show advanced UI which includes convenience actions suitable for the passed
680 * Uris.
Steve McKayc78bcb82015-07-31 14:35:22 -0700681 * <p>Output: nothing.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900682 * @see #EXTRA_QUICK_VIEW_ADVANCED
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900683 * @see #EXTRA_INDEX
Steve McKayc78bcb82015-07-31 14:35:22 -0700684 */
685 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
686 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
687
688 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700689 * Used to indicate that some piece of data should be attached to some other
690 * place. For example, image data could be attached to a contact. It is up
691 * to the recipient to decide where the data should be attached; the intent
692 * does not specify the ultimate destination.
693 * <p>Input: {@link #getData} is URI of data to be attached.
694 * <p>Output: nothing.
695 */
696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
697 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800698
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700699 /**
700 * Activity Action: Provide explicit editable access to the given data.
701 * <p>Input: {@link #getData} is URI of data to be edited.
702 * <p>Output: nothing.
703 */
704 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
705 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800706
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700707 /**
708 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
709 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
710 * The extras can contain type specific data to pass through to the editing/creating
711 * activity.
712 * <p>Output: The URI of the item that was picked. This must be a content:
713 * URI so that any receiver can access it.
714 */
715 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
716 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800717
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700718 /**
719 * Activity Action: Pick an item from the data, returning what was selected.
720 * <p>Input: {@link #getData} is URI containing a directory of data
721 * (vnd.android.cursor.dir/*) from which to pick an item.
722 * <p>Output: The URI of the item that was picked.
723 */
724 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
725 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800726
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700727 /**
728 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800729 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800730 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
731 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700732 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
733 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800734 * (value: ShortcutIconResource).</p>
735 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800736 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700737 * @see #EXTRA_SHORTCUT_INTENT
738 * @see #EXTRA_SHORTCUT_NAME
739 * @see #EXTRA_SHORTCUT_ICON
740 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
741 * @see android.content.Intent.ShortcutIconResource
742 */
743 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
744 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
745
746 /**
747 * The name of the extra used to define the Intent of a shortcut.
748 *
749 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800750 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700751 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800752 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700753 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
754 /**
755 * The name of the extra used to define the name of a shortcut.
756 *
757 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800758 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800760 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700761 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
762 /**
763 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
764 *
765 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800766 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800768 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700769 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
770 /**
771 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
772 *
773 * @see #ACTION_CREATE_SHORTCUT
774 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800777 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700778 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
779 "android.intent.extra.shortcut.ICON_RESOURCE";
780
781 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500782 * An activity that provides a user interface for adjusting application preferences.
783 * Optional but recommended settings for all applications which have settings.
784 */
785 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
786 public static final String ACTION_APPLICATION_PREFERENCES
787 = "android.intent.action.APPLICATION_PREFERENCES";
788
789 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700790 * Activity Action: Launch an activity showing the app information.
791 * For applications which install other applications (such as app stores), it is recommended
792 * to handle this action for providing the app information to the user.
793 *
794 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
795 * to be displayed.
796 * <p>Output: Nothing.
797 */
798 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
799 public static final String ACTION_SHOW_APP_INFO
800 = "android.intent.action.SHOW_APP_INFO";
801
802 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800803 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700804 *
805 * @see Intent#ACTION_CREATE_SHORTCUT
806 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800807 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
808 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700809 */
810 public static class ShortcutIconResource implements Parcelable {
811 /**
812 * The package name of the application containing the icon.
813 */
814 public String packageName;
815
816 /**
817 * The resource name of the icon, including package, name and type.
818 */
819 public String resourceName;
820
821 /**
822 * Creates a new ShortcutIconResource for the specified context and resource
823 * identifier.
824 *
825 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700826 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700827 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700828 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700829 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700830 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700831 ShortcutIconResource icon = new ShortcutIconResource();
832 icon.packageName = context.getPackageName();
833 icon.resourceName = context.getResources().getResourceName(resourceId);
834 return icon;
835 }
836
837 /**
838 * Used to read a ShortcutIconResource from a Parcel.
839 */
840 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
841 new Parcelable.Creator<ShortcutIconResource>() {
842
843 public ShortcutIconResource createFromParcel(Parcel source) {
844 ShortcutIconResource icon = new ShortcutIconResource();
845 icon.packageName = source.readString();
846 icon.resourceName = source.readString();
847 return icon;
848 }
849
850 public ShortcutIconResource[] newArray(int size) {
851 return new ShortcutIconResource[size];
852 }
853 };
854
855 /**
856 * No special parcel contents.
857 */
858 public int describeContents() {
859 return 0;
860 }
861
862 public void writeToParcel(Parcel dest, int flags) {
863 dest.writeString(packageName);
864 dest.writeString(resourceName);
865 }
866
867 @Override
868 public String toString() {
869 return resourceName;
870 }
871 }
872
873 /**
874 * Activity Action: Display an activity chooser, allowing the user to pick
875 * what they want to before proceeding. This can be used as an alternative
876 * to the standard activity picker that is displayed by the system when
877 * you try to start an activity with multiple possible matches, with these
878 * differences in behavior:
879 * <ul>
880 * <li>You can specify the title that will appear in the activity chooser.
881 * <li>The user does not have the option to make one of the matching
882 * activities a preferred activity, and all possible activities will
883 * always be shown even if one of them is currently marked as the
884 * preferred activity.
885 * </ul>
886 * <p>
887 * This action should be used when the user will naturally expect to
888 * select an activity in order to proceed. An example if when not to use
889 * it is when the user clicks on a "mailto:" link. They would naturally
890 * expect to go directly to their mail app, so startActivity() should be
891 * called directly: it will
892 * either launch the current preferred app, or put up a dialog allowing the
893 * user to pick an app to use and optionally marking that as preferred.
894 * <p>
895 * In contrast, if the user is selecting a menu item to send a picture
896 * they are viewing to someone else, there are many different things they
897 * may want to do at this point: send it through e-mail, upload it to a
898 * web service, etc. In this case the CHOOSER action should be used, to
899 * always present to the user a list of the things they can do, with a
900 * nice title given by the caller such as "Send this photo with:".
901 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700902 * If you need to grant URI permissions through a chooser, you must specify
903 * the permissions to be granted on the ACTION_CHOOSER Intent
904 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
905 * {@link #setClipData} to specify the URIs to be granted as well as
906 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
907 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
908 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700909 * As a convenience, an Intent of this form can be created with the
910 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700911 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700912 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700913 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
914 * and can optionally have a {@link #EXTRA_TITLE} field containing the
915 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700916 * <p>
917 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700918 */
919 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
920 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
921
922 /**
923 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
924 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700925 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
926 * target intent, also optionally supplying a title. If the target
927 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
928 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
929 * set in the returned chooser intent, with its ClipData set appropriately:
930 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500931 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700932 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700933 * @param target The Intent that the user will be selecting an activity
934 * to perform.
935 * @param title Optional title that will be displayed in the chooser.
936 * @return Return a new Intent object that you can hand to
937 * {@link Context#startActivity(Intent) Context.startActivity()} and
938 * related methods.
939 */
940 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700941 return createChooser(target, title, null);
942 }
943
944 /**
945 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
946 *
947 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
948 * target intent, also optionally supplying a title. If the target
949 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
950 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
951 * set in the returned chooser intent, with its ClipData set appropriately:
952 * either a direct reflection of {@link #getClipData()} if that is non-null,
953 * or a new ClipData built from {@link #getData()}.</p>
954 *
955 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
956 * when the user makes a choice. This can be useful if the calling application wants
957 * to remember the last chosen target and surface it as a more prominent or one-touch
958 * affordance elsewhere in the UI for next time.</p>
959 *
960 * @param target The Intent that the user will be selecting an activity
961 * to perform.
962 * @param title Optional title that will be displayed in the chooser.
963 * @param sender Optional IntentSender to be called when a choice is made.
964 * @return Return a new Intent object that you can hand to
965 * {@link Context#startActivity(Intent) Context.startActivity()} and
966 * related methods.
967 */
968 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700969 Intent intent = new Intent(ACTION_CHOOSER);
970 intent.putExtra(EXTRA_INTENT, target);
971 if (title != null) {
972 intent.putExtra(EXTRA_TITLE, title);
973 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700974
Adam Powell0b3c1122014-10-09 12:50:14 -0700975 if (sender != null) {
976 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
977 }
978
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700979 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700980 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
981 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
982 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700983 if (permFlags != 0) {
984 ClipData targetClipData = target.getClipData();
985 if (targetClipData == null && target.getData() != null) {
986 ClipData.Item item = new ClipData.Item(target.getData());
987 String[] mimeTypes;
988 if (target.getType() != null) {
989 mimeTypes = new String[] { target.getType() };
990 } else {
991 mimeTypes = new String[] { };
992 }
993 targetClipData = new ClipData(null, mimeTypes, item);
994 }
995 if (targetClipData != null) {
996 intent.setClipData(targetClipData);
997 intent.addFlags(permFlags);
998 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700999 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001000
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001001 return intent;
1002 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001003
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001004 /**
1005 * Activity Action: Allow the user to select a particular kind of data and
1006 * return it. This is different than {@link #ACTION_PICK} in that here we
1007 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001008 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001009 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001010 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001011 * etc.
1012 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001013 * 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 -07001014 * of data, such as a person contact, you set the MIME type to the kind of
1015 * data you want and launch it with {@link Context#startActivity(Intent)}.
1016 * The system will then launch the best application to select that kind
1017 * of data for you.
1018 * <p>
1019 * You may also be interested in any of a set of types of content the user
1020 * can pick. For example, an e-mail application that wants to allow the
1021 * user to add an attachment to an e-mail message can use this action to
1022 * bring up a list of all of the types of content the user can attach.
1023 * <p>
1024 * In this case, you should wrap the GET_CONTENT intent with a chooser
1025 * (through {@link #createChooser}), which will give the proper interface
1026 * for the user to pick how to send your data and allow you to specify
1027 * a prompt indicating what they are doing. You will usually specify a
1028 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1029 * broad range of content types the user can select from.
1030 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001031 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001032 * only pick from data that can be represented as a stream. This is
1033 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1034 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001035 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001036 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001037 * is locally available on the device. For example, if this extra is set
1038 * to true then an image picker should not show any pictures that are available
1039 * from a remote server but not already on the local device (thus requiring
1040 * they be downloaded when opened).
1041 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001042 * If the caller can handle multiple returned items (the user performing
1043 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1044 * to indicate this.
1045 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001046 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1047 * that no URI is supplied in the intent, as there are no constraints on
1048 * where the returned data originally comes from. You may also include the
1049 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001050 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001051 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1052 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001053 * <p>
1054 * Output: The URI of the item that was picked. This must be a content:
1055 * URI so that any receiver can access it.
1056 */
1057 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1058 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1059 /**
1060 * Activity Action: Dial a number as specified by the data. This shows a
1061 * UI with the number being dialed, allowing the user to explicitly
1062 * initiate the call.
1063 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1064 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1065 * number.
1066 * <p>Output: nothing.
1067 */
1068 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1069 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1070 /**
1071 * Activity Action: Perform a call to someone specified by the data.
1072 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1073 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1074 * number.
1075 * <p>Output: nothing.
1076 *
1077 * <p>Note: there will be restrictions on which applications can initiate a
1078 * call; most applications should use the {@link #ACTION_DIAL}.
1079 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1080 * numbers. Applications can <strong>dial</strong> emergency numbers using
1081 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001082 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001083 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001084 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001085 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001086 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001087 */
1088 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1089 public static final String ACTION_CALL = "android.intent.action.CALL";
1090 /**
1091 * Activity Action: Perform a call to an emergency number specified by the
1092 * data.
1093 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1094 * tel: URI of an explicit phone number.
1095 * <p>Output: nothing.
1096 * @hide
1097 */
1098 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 */
1107 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001108
Santos Cordon15a13782015-03-31 18:32:31 -07001109 /**
fionaxuadfe7002017-02-17 17:20:46 -08001110 * Activity Action: Main entry point for carrier setup apps.
1111 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1112 * carrier service and typically require
1113 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1114 * fulfill their duties.
1115 */
1116 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1117 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1118 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001119 * Activity Action: Send a message to someone specified by the data.
1120 * <p>Input: {@link #getData} is URI describing the target.
1121 * <p>Output: nothing.
1122 */
1123 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1124 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1125 /**
1126 * Activity Action: Deliver some data to someone else. Who the data is
1127 * being delivered to is not specified; it is up to the receiver of this
1128 * action to ask the user where the data should be sent.
1129 * <p>
1130 * When launching a SEND intent, you should usually wrap it in a chooser
1131 * (through {@link #createChooser}), which will give the proper interface
1132 * for the user to pick how to send your data and allow you to specify
1133 * a prompt indicating what they are doing.
1134 * <p>
1135 * Input: {@link #getType} is the MIME type of the data being sent.
1136 * get*Extra can have either a {@link #EXTRA_TEXT}
1137 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1138 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1139 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1140 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001141 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1142 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1143 * your text with HTML formatting.
1144 * <p>
1145 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1146 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1147 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1148 * content: URIs and other advanced features of {@link ClipData}. If
1149 * using this approach, you still must supply the same data through the
1150 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1151 * for compatibility with old applications. If you don't set a ClipData,
1152 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001153 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001154 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1155 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1156 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1157 * be openable only as asset typed files using
1158 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1159 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001160 * Optional standard extras, which may be interpreted by some recipients as
1161 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1162 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1163 * <p>
1164 * Output: nothing.
1165 */
1166 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1167 public static final String ACTION_SEND = "android.intent.action.SEND";
1168 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001169 * Activity Action: Deliver multiple data to someone else.
1170 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001171 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001172 * <p>
1173 * Input: {@link #getType} is the MIME type of the data being sent.
1174 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001175 * #EXTRA_STREAM} field, containing the data to be sent. If using
1176 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1177 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001178 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001179 * Multiple types are supported, and receivers should handle mixed types
1180 * whenever possible. The right way for the receiver to check them is to
1181 * use the content resolver on each URI. The intent sender should try to
1182 * put the most concrete mime type in the intent type, but it can fall
1183 * back to {@literal <type>/*} or {@literal *}/* as needed.
1184 * <p>
1185 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1186 * be image/jpg, but if you are sending image/jpg and image/png, then the
1187 * intent's type should be image/*.
1188 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001189 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1190 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1191 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1192 * content: URIs and other advanced features of {@link ClipData}. If
1193 * using this approach, you still must supply the same data through the
1194 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1195 * for compatibility with old applications. If you don't set a ClipData,
1196 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1197 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001198 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1199 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1200 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1201 * be openable only as asset typed files using
1202 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1203 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001204 * Optional standard extras, which may be interpreted by some recipients as
1205 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1206 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1207 * <p>
1208 * Output: nothing.
1209 */
1210 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1211 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1212 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001213 * Activity Action: Handle an incoming phone call.
1214 * <p>Input: nothing.
1215 * <p>Output: nothing.
1216 */
1217 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1218 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1219 /**
1220 * Activity Action: Insert an empty item into the given container.
1221 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1222 * in which to place the data.
1223 * <p>Output: URI of the new data that was created.
1224 */
1225 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1226 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1227 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001228 * Activity Action: Create a new item in the given container, initializing it
1229 * from the current contents of the clipboard.
1230 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1231 * in which to place the data.
1232 * <p>Output: URI of the new data that was created.
1233 */
1234 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1235 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1236 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001237 * Activity Action: Delete the given data from its container.
1238 * <p>Input: {@link #getData} is URI of data to be deleted.
1239 * <p>Output: nothing.
1240 */
1241 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1242 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1243 /**
1244 * Activity Action: Run the data, whatever that means.
1245 * <p>Input: ? (Note: this is currently specific to the test harness.)
1246 * <p>Output: nothing.
1247 */
1248 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1249 public static final String ACTION_RUN = "android.intent.action.RUN";
1250 /**
1251 * Activity Action: Perform a data synchronization.
1252 * <p>Input: ?
1253 * <p>Output: ?
1254 */
1255 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1256 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1257 /**
1258 * Activity Action: Pick an activity given an intent, returning the class
1259 * selected.
1260 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1261 * used with {@link PackageManager#queryIntentActivities} to determine the
1262 * set of activities from which to pick.
1263 * <p>Output: Class name of the activity that was selected.
1264 */
1265 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1266 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1267 /**
1268 * Activity Action: Perform a search.
1269 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1270 * is the text to search for. If empty, simply
1271 * enter your search results Activity with the search UI activated.
1272 * <p>Output: nothing.
1273 */
1274 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1275 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1276 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001277 * Activity Action: Start the platform-defined tutorial
1278 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1279 * is the text to search for. If empty, simply
1280 * enter your search results Activity with the search UI activated.
1281 * <p>Output: nothing.
1282 */
1283 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1284 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1285 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001286 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001287 * <p>
1288 * Input: {@link android.app.SearchManager#QUERY
1289 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1290 * a url starts with http or https, the site will be opened. If it is plain
1291 * text, Google search will be applied.
1292 * <p>
1293 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001294 */
1295 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1296 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001297
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001298 /**
Jim Miller07994402012-05-02 14:22:27 -07001299 * Activity Action: Perform assist action.
1300 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001301 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1302 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001303 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1304 * information.
Jim Miller07994402012-05-02 14:22:27 -07001305 * Output: nothing.
1306 */
1307 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1308 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001309
1310 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001311 * Activity Action: Perform voice assist action.
1312 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001313 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1314 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001315 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001316 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001317 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001318 */
Amith Yamasani16452032017-03-03 10:15:57 -08001319 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001320 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1321 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1322
1323 /**
Adam Skory7140a252013-09-11 12:04:58 +01001324 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1325 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001326 */
1327 public static final String EXTRA_ASSIST_PACKAGE
1328 = "android.intent.extra.ASSIST_PACKAGE";
1329
1330 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001331 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1332 * application package at the time the assist was invoked.
1333 */
1334 public static final String EXTRA_ASSIST_UID
1335 = "android.intent.extra.ASSIST_UID";
1336
1337 /**
Adam Skory7140a252013-09-11 12:04:58 +01001338 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1339 * information supplied by the current foreground app at the time of the assist request.
1340 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001341 */
1342 public static final String EXTRA_ASSIST_CONTEXT
1343 = "android.intent.extra.ASSIST_CONTEXT";
1344
Jim Miller07994402012-05-02 14:22:27 -07001345 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001346 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1347 * keyboard as the primary input device for assistance.
1348 */
1349 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1350 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1351
1352 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001353 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1354 * that was used to invoke the assist.
1355 */
1356 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1357 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1358
1359 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001360 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001361 * <p>Input: Nothing.
1362 * <p>Output: nothing.
1363 */
1364 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1365 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1366 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001367 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001368 * <p>Input: Nothing.
1369 * <p>Output: Nothing.
1370 */
1371 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1372 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1373
1374 /**
1375 * Activity Action: Show activity for reporting a bug.
1376 * <p>Input: Nothing.
1377 * <p>Output: Nothing.
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1381
1382 /**
1383 * Activity Action: Main entry point for factory tests. Only used when
1384 * the device is booting in factory test node. The implementing package
1385 * must be installed in the system image.
1386 * <p>Input: nothing
1387 * <p>Output: nothing
1388 */
1389 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1390
1391 /**
1392 * Activity Action: The user pressed the "call" button to go to the dialer
1393 * or other appropriate UI for placing a call.
1394 * <p>Input: Nothing.
1395 * <p>Output: Nothing.
1396 */
1397 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1398 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1399
1400 /**
1401 * Activity Action: Start Voice Command.
1402 * <p>Input: Nothing.
1403 * <p>Output: Nothing.
1404 */
1405 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1406 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001407
1408 /**
1409 * Activity Action: Start action associated with long pressing on the
1410 * search key.
1411 * <p>Input: Nothing.
1412 * <p>Output: Nothing.
1413 */
1414 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1415 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001416
Jacek Surazski86b6c532009-05-13 14:38:28 +02001417 /**
1418 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1419 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001420 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001421 * <p>Input: No data is specified. The bug report is passed in using
1422 * an {@link #EXTRA_BUG_REPORT} field.
1423 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001424 *
1425 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001426 */
1427 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1428 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001429
1430 /**
1431 * Activity Action: Show power usage information to the user.
1432 * <p>Input: Nothing.
1433 * <p>Output: Nothing.
1434 */
1435 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1436 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001437
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001438 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001439 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1440 * to run.
1441 * <p>Input: Nothing.
1442 * <p>Output: Nothing.
1443 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1444 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1445 * @hide
1446 */
1447 @Deprecated
1448 @SystemApi
1449 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1450 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1451
1452 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001453 * Activity Action: Setup wizard to launch after a platform update. This
1454 * activity should have a string meta-data field associated with it,
1455 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1456 * the platform for setup. The activity will be launched only if
1457 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1458 * same value.
1459 * <p>Input: Nothing.
1460 * <p>Output: Nothing.
1461 * @hide
1462 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001463 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001464 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1465 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001466
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001467 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001468 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1469 * <p>Input: Nothing.
1470 * <p>Output: Nothing.
1471 * @hide
1472 */
1473 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1474 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001475 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001476
1477 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001478 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1479 * <p>Input: Nothing.
1480 * <p>Output: Nothing.
1481 * @hide
1482 */
1483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1484 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001485 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001486
1487 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001488 * Activity Action: Show settings for managing network data usage of a
1489 * specific application. Applications should define an activity that offers
1490 * options to control data usage.
1491 */
1492 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1493 public static final String ACTION_MANAGE_NETWORK_USAGE =
1494 "android.intent.action.MANAGE_NETWORK_USAGE";
1495
1496 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001497 * Activity Action: Launch application installer.
1498 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001499 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001500 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1501 * you can also use "package:<package-name>" to install an application for the
1502 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001503 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1504 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1505 * <p>
1506 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1507 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001508 * <p>
1509 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1510 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1511 * in order to launch the application installer.
1512 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001513 *
1514 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1515 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1516 * @see #EXTRA_RETURN_RESULT
1517 */
1518 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1519 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1520
1521 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001522 * Activity Action: Launch ephemeral installer.
1523 * <p>
1524 * Input: The data must be a http: URI that the ephemeral application is registered
1525 * to handle.
1526 * <p class="note">
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.ACTIVITY_INTENT_ACTION)
1533 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1534 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1535
1536 /**
1537 * Service Action: Resolve ephemeral application.
1538 * <p>
1539 * The system will have a persistent connection to this service.
1540 * This is a protected intent that can only be sent by the system.
1541 * </p>
1542 *
1543 * @hide
1544 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001545 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1546 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1547 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
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 */
2452 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2453 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002454 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002455 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002456 * <p class="note">
2457 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002458 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002459 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2460 * or above, this broadcast will no longer be delivered to any
2461 * {@link BroadcastReceiver} defined in your manifest. Instead,
2462 * apps are strongly encouraged to use the improved
2463 * {@link Context#getCacheDir()} behavior so the system can
2464 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002465 */
2466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002467 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002468 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2469 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002470 * Broadcast Action: Indicates low storage space condition on the device no
2471 * longer exists
2472 * <p class="note">
2473 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002474 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002475 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2476 * or above, this broadcast will no longer be delivered to any
2477 * {@link BroadcastReceiver} defined in your manifest. Instead,
2478 * apps are strongly encouraged to use the improved
2479 * {@link Context#getCacheDir()} behavior so the system can
2480 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002481 */
2482 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002483 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002484 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2485 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002486 * Broadcast Action: A sticky broadcast that indicates a storage space full
2487 * condition on the device. This is intended for activities that want to be
2488 * able to fill the data partition completely, leaving only enough free
2489 * space to prevent system-wide SQLite failures.
2490 * <p class="note">
2491 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002492 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002493 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2494 * or above, this broadcast will no longer be delivered to any
2495 * {@link BroadcastReceiver} defined in your manifest. Instead,
2496 * apps are strongly encouraged to use the improved
2497 * {@link Context#getCacheDir()} behavior so the system can
2498 * automatically free up storage when needed.
2499 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002500 */
2501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002502 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002503 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2504 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002505 * Broadcast Action: Indicates storage space full condition on the device no
2506 * longer exists.
2507 * <p class="note">
2508 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002509 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002510 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2511 * or above, this broadcast will no longer be delivered to any
2512 * {@link BroadcastReceiver} defined in your manifest. Instead,
2513 * apps are strongly encouraged to use the improved
2514 * {@link Context#getCacheDir()} behavior so the system can
2515 * automatically free up storage when needed.
2516 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002517 */
2518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002519 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002520 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2521 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002522 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2523 * and package management should be started.
2524 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2525 * notification.
2526 */
2527 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2528 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2529 /**
2530 * Broadcast Action: The device has entered USB Mass Storage mode.
2531 * This is used mainly for the USB Settings panel.
2532 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2533 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002534 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002535 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002536 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002537 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2538
2539 /**
2540 * Broadcast Action: The device has exited USB Mass Storage mode.
2541 * This is used mainly for the USB Settings panel.
2542 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2543 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002544 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002545 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002546 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002547 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2548
2549 /**
2550 * Broadcast Action: External media has been removed.
2551 * The path to the mount point for the removed media is contained in the Intent.mData field.
2552 */
2553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2554 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2555
2556 /**
2557 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002558 * The path to the mount point for the unmounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002559 */
2560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2561 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2562
2563 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002564 * Broadcast Action: External media is present, and being disk-checked
2565 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002566 */
2567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2568 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2569
2570 /**
2571 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2572 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002573 */
2574 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2575 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2576
2577 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002578 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002579 * The path to the mount point for the mounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002580 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2581 * media was mounted read only.
2582 */
2583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2584 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2585
2586 /**
2587 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002588 * The path to the mount point for the shared media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 */
2590 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2591 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2592
2593 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002594 * Broadcast Action: External media is no longer being shared via USB mass storage.
2595 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2596 *
2597 * @hide
2598 */
2599 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2600
2601 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002602 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2603 * The path to the mount point for the removed media is contained in the Intent.mData field.
2604 */
2605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2606 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2607
2608 /**
2609 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002610 * The path to the mount point for the unmountable media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002611 */
2612 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2613 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2614
2615 /**
2616 * Broadcast Action: User has expressed the desire to remove the external storage media.
2617 * Applications should close all files they have open within the mount point when they receive this intent.
2618 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2622
2623 /**
2624 * Broadcast Action: The media scanner has started scanning a directory.
2625 * The path to the directory being scanned is contained in the Intent.mData field.
2626 */
2627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2628 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2629
2630 /**
2631 * Broadcast Action: The media scanner has finished scanning a directory.
2632 * The path to the scanned directory is contained in the Intent.mData field.
2633 */
2634 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2635 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2636
2637 /**
2638 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2639 * The path to the file is contained in the Intent.mData field.
2640 */
2641 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2642 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2643
2644 /**
2645 * Broadcast Action: The "Media Button" was pressed. Includes a single
2646 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2647 * caused the broadcast.
2648 */
2649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2650 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2651
2652 /**
2653 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2654 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2655 * caused the broadcast.
2656 */
2657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2658 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2659
2660 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2661 // location; they are not general-purpose actions.
2662
2663 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002664 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002665 */
2666 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2667 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2668 "android.intent.action.GTALK_CONNECTED";
2669
2670 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002671 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002672 */
2673 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2674 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2675 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002676
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002677 /**
2678 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002679 */
2680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2681 public static final String ACTION_INPUT_METHOD_CHANGED =
2682 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002683
2684 /**
2685 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2686 * more radios have been turned off or on. The intent will have the following extra value:</p>
2687 * <ul>
2688 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2689 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2690 * turned off</li>
2691 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002692 *
Peng Xua35b5532016-01-20 00:05:45 -08002693 * <p class="note">This is a protected intent that can only be sent by the system.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002694 */
2695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2696 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2697
2698 /**
2699 * Broadcast Action: Some content providers have parts of their namespace
2700 * where they publish new events or items that the user may be especially
2701 * interested in. For these things, they may broadcast this action when the
2702 * set of interesting items change.
2703 *
2704 * For example, GmailProvider sends this notification when the set of unread
2705 * mail in the inbox changes.
2706 *
2707 * <p>The data of the intent identifies which part of which provider
2708 * changed. When queried through the content resolver, the data URI will
2709 * return the data set in question.
2710 *
2711 * <p>The intent will have the following extra values:
2712 * <ul>
2713 * <li><em>count</em> - The number of items in the data set. This is the
2714 * same as the number of items in the cursor returned by querying the
2715 * data URI. </li>
2716 * </ul>
2717 *
2718 * This intent will be sent at boot (if the count is non-zero) and when the
2719 * data set changes. It is possible for the data set to change without the
2720 * count changing (for example, if a new unread message arrives in the same
2721 * sync operation in which a message is archived). The phone should still
2722 * ring/vibrate/etc as normal in this case.
2723 */
2724 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2725 public static final String ACTION_PROVIDER_CHANGED =
2726 "android.intent.action.PROVIDER_CHANGED";
2727
2728 /**
2729 * Broadcast Action: Wired Headset plugged in or unplugged.
2730 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002731 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2732 * and documentation.
2733 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002734 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002735 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 */
2737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002738 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002739
2740 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002741 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2742 * <ul>
2743 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2744 * </ul>
2745 *
2746 * <p class="note">This is a protected intent that can only be sent
2747 * by the system.
2748 *
2749 * @hide
2750 */
2751 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2752 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2753 = "android.intent.action.ADVANCED_SETTINGS";
2754
2755 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002756 * Broadcast Action: Sent after application restrictions are changed.
2757 *
2758 * <p class="note">This is a protected intent that can only be sent
2759 * by the system.</p>
2760 */
2761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2762 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2763 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2764
2765 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002766 * Broadcast Action: An outgoing call is about to be placed.
2767 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002768 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002769 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002770 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002771 * the phone number originally intended to be dialed.</li>
2772 * </ul>
2773 * <p>Once the broadcast is finished, the resultData is used as the actual
2774 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002775 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002776 * outgoing call in turn: for example, a parental control application
2777 * might verify that the user is authorized to place the call at that
2778 * time, then a number-rewriting application might add an area code if
2779 * one was not specified.</p>
2780 * <p>For consistency, any receiver whose purpose is to prohibit phone
2781 * calls should have a priority of 0, to ensure it will see the final
2782 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002783 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002784 * should have a positive priority.
2785 * Negative priorities are reserved for the system for this broadcast;
2786 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002787 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2788 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002789 * <p>Emergency calls cannot be intercepted using this mechanism, and
2790 * other calls cannot be modified to call emergency numbers using this
2791 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002792 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2793 * call to use their own service instead. Those apps should first prevent
2794 * the call from being placed by setting resultData to <code>null</code>
2795 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002796 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002797 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2798 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002799 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002800 * <p class="note">This is a protected intent that can only be sent
2801 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002802 */
2803 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2804 public static final String ACTION_NEW_OUTGOING_CALL =
2805 "android.intent.action.NEW_OUTGOING_CALL";
2806
2807 /**
2808 * Broadcast Action: Have the device reboot. This is only for use by
2809 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002810 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002811 * <p class="note">This is a protected intent that can only be sent
2812 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002813 */
2814 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2815 public static final String ACTION_REBOOT =
2816 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002817
Wei Huang97ecc9c2009-05-11 17:44:20 -07002818 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002819 * Broadcast Action: A sticky broadcast for changes in the physical
2820 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002821 *
2822 * <p>The intent will have the following extra values:
2823 * <ul>
2824 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002825 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002826 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002827 * <p>This is intended for monitoring the current physical dock state.
2828 * See {@link android.app.UiModeManager} for the normal API dealing with
2829 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002830 */
2831 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2832 public static final String ACTION_DOCK_EVENT =
2833 "android.intent.action.DOCK_EVENT";
2834
2835 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002836 * Broadcast Action: A broadcast when idle maintenance can be started.
2837 * This means that the user is not interacting with the device and is
2838 * not expected to do so soon. Typical use of the idle maintenance is
2839 * to perform somehow expensive tasks that can be postponed at a moment
2840 * when they will not degrade user experience.
2841 * <p>
2842 * <p class="note">In order to keep the device responsive in case of an
2843 * unexpected user interaction, implementations of a maintenance task
2844 * should be interruptible. In such a scenario a broadcast with action
2845 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2846 * should not do the maintenance work in
2847 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2848 * maintenance service by {@link Context#startService(Intent)}. Also
2849 * you should hold a wake lock while your maintenance service is running
2850 * to prevent the device going to sleep.
2851 * </p>
2852 * <p>
2853 * <p class="note">This is a protected intent that can only be sent by
2854 * the system.
2855 * </p>
2856 *
2857 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002858 *
2859 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002860 */
2861 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2862 public static final String ACTION_IDLE_MAINTENANCE_START =
2863 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2864
2865 /**
2866 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2867 * This means that the user was not interacting with the device as a result
2868 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2869 * was sent and now the user started interacting with the device. Typical
2870 * use of the idle maintenance is to perform somehow expensive tasks that
2871 * can be postponed at a moment when they will not degrade user experience.
2872 * <p>
2873 * <p class="note">In order to keep the device responsive in case of an
2874 * unexpected user interaction, implementations of a maintenance task
2875 * should be interruptible. Hence, on receiving a broadcast with this
2876 * action, the maintenance task should be interrupted as soon as possible.
2877 * In other words, you should not do the maintenance work in
2878 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2879 * maintenance service that was started on receiving of
2880 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2881 * lock you acquired when your maintenance service started.
2882 * </p>
2883 * <p class="note">This is a protected intent that can only be sent
2884 * by the system.
2885 *
2886 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002887 *
2888 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002889 */
2890 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2891 public static final String ACTION_IDLE_MAINTENANCE_END =
2892 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2893
2894 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002895 * Broadcast Action: a remote intent is to be broadcasted.
2896 *
2897 * A remote intent is used for remote RPC between devices. The remote intent
2898 * is serialized and sent from one device to another device. The receiving
2899 * device parses the remote intent and broadcasts it. Note that anyone can
2900 * broadcast a remote intent. However, if the intent receiver of the remote intent
2901 * does not trust intent broadcasts from arbitrary intent senders, it should require
2902 * the sender to hold certain permissions so only trusted sender's broadcast will be
2903 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002904 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002905 */
2906 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002907 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002908
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002909 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002910 * Broadcast Action: This is broadcast once when the user is booting after a
2911 * system update. It can be used to perform cleanup or upgrades after a
2912 * system update.
2913 * <p>
2914 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2915 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2916 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2917 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002918 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002919 * @hide
2920 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002921 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002922 public static final String ACTION_PRE_BOOT_COMPLETED =
2923 "android.intent.action.PRE_BOOT_COMPLETED";
2924
Amith Yamasani13593602012-03-22 16:16:17 -07002925 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002926 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002927 * on restricted users. The broadcast intent contains an extra
2928 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2929 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2930 * String[] depending on the restriction type.<p/>
2931 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002932 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2933 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2934 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002935 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2936 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002937 * @see RestrictionEntry
2938 */
2939 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2940 "android.intent.action.GET_RESTRICTION_ENTRIES";
2941
2942 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002943 * Sent the first time a user is starting, to allow system apps to
2944 * perform one time initialization. (This will not be seen by third
2945 * party applications because a newly initialized user does not have any
2946 * third party applications installed for it.) This is sent early in
2947 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002948 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2949 * broadcast, since it is part of a visible user interaction; be as quick
2950 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002951 */
2952 public static final String ACTION_USER_INITIALIZE =
2953 "android.intent.action.USER_INITIALIZE";
2954
2955 /**
2956 * Sent when a user switch is happening, causing the process's user to be
2957 * brought to the foreground. This is only sent to receivers registered
2958 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2959 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002960 * foreground. This is sent as a foreground
2961 * broadcast, since it is part of a visible user interaction; be as quick
2962 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002963 */
2964 public static final String ACTION_USER_FOREGROUND =
2965 "android.intent.action.USER_FOREGROUND";
2966
2967 /**
2968 * Sent when a user switch is happening, causing the process's user to be
2969 * sent to the background. This is only sent to receivers registered
2970 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2971 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002972 * background. This is sent as a foreground
2973 * broadcast, since it is part of a visible user interaction; be as quick
2974 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002975 */
2976 public static final String ACTION_USER_BACKGROUND =
2977 "android.intent.action.USER_BACKGROUND";
2978
2979 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002980 * Broadcast sent to the system when a user is added. Carries an extra
2981 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2982 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002983 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002984 * @hide
2985 */
2986 public static final String ACTION_USER_ADDED =
2987 "android.intent.action.USER_ADDED";
2988
2989 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002990 * Broadcast sent by the system when a user is started. Carries an extra
2991 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002992 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002993 * that has been started. This is sent as a foreground
2994 * broadcast, since it is part of a visible user interaction; be as quick
2995 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002996 * @hide
2997 */
2998 public static final String ACTION_USER_STARTED =
2999 "android.intent.action.USER_STARTED";
3000
3001 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003002 * Broadcast sent when a user is in the process of starting. Carries an extra
3003 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3004 * sent to registered receivers, not manifest receivers. It is sent to all
3005 * users (including the one that is being started). You must hold
3006 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3007 * this broadcast. This is sent as a background broadcast, since
3008 * its result is not part of the primary UX flow; to safely keep track of
3009 * started/stopped state of a user you can use this in conjunction with
3010 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3011 * other user state broadcasts since those are foreground broadcasts so can
3012 * execute in a different order.
3013 * @hide
3014 */
3015 public static final String ACTION_USER_STARTING =
3016 "android.intent.action.USER_STARTING";
3017
3018 /**
3019 * Broadcast sent when a user is going to be stopped. Carries an extra
3020 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3021 * sent to registered receivers, not manifest receivers. It is sent to all
3022 * users (including the one that is being stopped). You must hold
3023 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3024 * this broadcast. The user will not stop until all receivers have
3025 * handled the broadcast. This is sent as a background broadcast, since
3026 * its result is not part of the primary UX flow; to safely keep track of
3027 * started/stopped state of a user you can use this in conjunction with
3028 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3029 * other user state broadcasts since those are foreground broadcasts so can
3030 * execute in a different order.
3031 * @hide
3032 */
3033 public static final String ACTION_USER_STOPPING =
3034 "android.intent.action.USER_STOPPING";
3035
3036 /**
3037 * Broadcast sent to the system when a user is stopped. Carries an extra
3038 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3039 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3040 * specific package. This is only sent to registered receivers, not manifest
3041 * receivers. It is sent to all running users <em>except</em> the one that
3042 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003043 * @hide
3044 */
3045 public static final String ACTION_USER_STOPPED =
3046 "android.intent.action.USER_STOPPED";
3047
3048 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003049 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003050 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003051 * one that has been removed. The user will not be completely removed until all receivers have
3052 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003053 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003054 * @hide
3055 */
3056 public static final String ACTION_USER_REMOVED =
3057 "android.intent.action.USER_REMOVED";
3058
3059 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003060 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003061 * the userHandle of the user to become the current one. This is only sent to
3062 * registered receivers, not manifest receivers. It is sent to all running users.
3063 * You must hold
3064 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003065 * @hide
3066 */
3067 public static final String ACTION_USER_SWITCHED =
3068 "android.intent.action.USER_SWITCHED";
3069
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003070 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003071 * Broadcast Action: Sent when the credential-encrypted private storage has
3072 * become unlocked for the target user. This is only sent to registered
3073 * receivers, not manifest receivers.
3074 */
3075 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3076 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3077
3078 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003079 * Broadcast sent to the system when a user's information changes. Carries an extra
3080 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003081 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003082 * @hide
3083 */
3084 public static final String ACTION_USER_INFO_CHANGED =
3085 "android.intent.action.USER_INFO_CHANGED";
3086
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003087 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003088 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3089 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003090 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3091 * that need to display merged content across both primary and managed profiles need to
3092 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003093 * not manifest receivers.
3094 */
3095 public static final String ACTION_MANAGED_PROFILE_ADDED =
3096 "android.intent.action.MANAGED_PROFILE_ADDED";
3097
3098 /**
3099 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003100 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3101 * Only applications (for example Launchers) that need to display merged content across both
3102 * primary and managed profiles need to worry about this broadcast. This is only sent to
3103 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003104 */
3105 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3106 "android.intent.action.MANAGED_PROFILE_REMOVED";
3107
3108 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003109 * Broadcast sent to the primary user when the credential-encrypted private storage for
3110 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3111 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3112 * Launchers) that need to display merged content across both primary and managed profiles
3113 * need to worry about this broadcast. This is only sent to registered receivers,
3114 * not manifest receivers.
3115 */
3116 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3117 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3118
3119 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003120 * Broadcast sent to the primary user when an associated managed profile has become available.
3121 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003122 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3123 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3124 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003125 */
Rubin Xue95057a2016-04-01 16:49:25 +01003126 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3127 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3128
3129 /**
3130 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3131 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3132 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3133 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3134 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3135 */
3136 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3137 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003138
3139 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003140 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3141 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3142 * the device was locked or unlocked.
3143 *
3144 * This is only sent to registered receivers.
3145 *
3146 * @hide
3147 */
3148 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3149 "android.intent.action.DEVICE_LOCKED_CHANGED";
3150
3151 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003152 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3153 */
3154 public static final String ACTION_QUICK_CLOCK =
3155 "android.intent.action.QUICK_CLOCK";
3156
Michael Wright0087a142013-02-05 16:29:39 -08003157 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003158 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003159 * @hide
3160 */
3161 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003162 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003163
Justin Kohd378ad72013-04-01 12:18:26 -07003164 /**
3165 * Broadcast Action: A global button was pressed. Includes a single
3166 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3167 * caused the broadcast.
3168 * @hide
3169 */
3170 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3171
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003172 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003173 * Broadcast Action: Sent when media resource is granted.
3174 * <p>
3175 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3176 * granted.
3177 * </p>
3178 * <p class="note">
3179 * This is a protected intent that can only be sent by the system.
3180 * </p>
3181 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003182 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003183 * </p>
3184 *
3185 * @hide
3186 */
3187 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3188 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3189
3190 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003191 * Broadcast Action: An overlay package has been installed. The data
3192 * contains the name of the added overlay package.
3193 * @hide
3194 */
3195 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3196
3197 /**
3198 * Broadcast Action: An overlay package has changed. The data contains the
3199 * name of the overlay package which has changed. This is broadcast on all
3200 * changes to the OverlayInfo returned by {@link
3201 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3202 * most common change is a state change that will change whether the
3203 * overlay is enabled or not.
3204 * @hide
3205 */
3206 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3207
3208 /**
3209 * Broadcast Action: An overlay package has been removed. The data contains
3210 * the name of the overlay package which has been removed.
3211 * @hide
3212 */
3213 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3214
3215 /**
3216 * Broadcast Action: The order of a package's list of overlay packages has
3217 * changed. The data contains the package name of the overlay package that
3218 * had its position in the list adjusted.
3219 * @hide
3220 */
3221 public static final String
3222 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3223
3224 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003225 * Activity Action: Allow the user to select and return one or more existing
3226 * documents. When invoked, the system will display the various
3227 * {@link DocumentsProvider} instances installed on the device, letting the
3228 * user interactively navigate through them. These documents include local
3229 * media, such as photos and video, and documents provided by installed
3230 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003231 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003232 * Each document is represented as a {@code content://} URI backed by a
3233 * {@link DocumentsProvider}, which can be opened as a stream with
3234 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3235 * {@link android.provider.DocumentsContract.Document} metadata.
3236 * <p>
3237 * All selected documents are returned to the calling application with
3238 * persistable read and write permission grants. If you want to maintain
3239 * access to the documents across device reboots, you need to explicitly
3240 * take the persistable permissions using
3241 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3242 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003243 * Callers must indicate the acceptable document MIME types through
3244 * {@link #setType(String)}. For example, to select photos, use
3245 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3246 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3247 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003248 * <p>
3249 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003250 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3251 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003252 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003253 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3254 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003255 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003256 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003257 * Callers can set a document URI through
3258 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3259 * location of documents navigator. System will do its best to launch the
3260 * navigator in the specified document if it's a folder, or the folder that
3261 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003262 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003263 * Output: The URI of the item that was picked, returned in
3264 * {@link #getData()}. This must be a {@code content://} URI so that any
3265 * receiver can access it. If multiple documents were selected, they are
3266 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003267 *
3268 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003269 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003270 * @see #ACTION_CREATE_DOCUMENT
3271 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003272 */
3273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3274 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3275
3276 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003277 * Activity Action: Allow the user to create a new document. When invoked,
3278 * the system will display the various {@link DocumentsProvider} instances
3279 * installed on the device, letting the user navigate through them. The
3280 * returned document may be a newly created document with no content, or it
3281 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003282 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003283 * Each document is represented as a {@code content://} URI backed by a
3284 * {@link DocumentsProvider}, which can be opened as a stream with
3285 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3286 * {@link android.provider.DocumentsContract.Document} metadata.
3287 * <p>
3288 * Callers must indicate the concrete MIME type of the document being
3289 * created by setting {@link #setType(String)}. This MIME type cannot be
3290 * changed after the document is created.
3291 * <p>
3292 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3293 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003294 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003295 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3296 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003297 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003298 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003299 * Callers can set a document URI through
3300 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3301 * location of documents navigator. System will do its best to launch the
3302 * navigator in the specified document if it's a folder, or the folder that
3303 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003304 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003305 * Output: The URI of the item that was created. This must be a
3306 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003307 *
3308 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003309 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003310 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003311 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003312 */
3313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3314 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3315
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003316 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003317 * Activity Action: Allow the user to pick a directory subtree. When
3318 * invoked, the system will display the various {@link DocumentsProvider}
3319 * instances installed on the device, letting the user navigate through
3320 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003321 * <p>
3322 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003323 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3324 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3325 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003326 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003327 * Callers can set a document URI through
3328 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3329 * location of documents navigator. System will do its best to launch the
3330 * navigator in the specified document if it's a folder, or the folder that
3331 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003332 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003333 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003334 *
3335 * @see DocumentsContract
3336 */
3337 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003338 public static final String
3339 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003340
Felipe Lemec7b1f892016-01-15 15:02:31 -08003341 /**
Peng Xua35b5532016-01-20 00:05:45 -08003342 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3343 * exisiting sensor being disconnected.
3344 *
3345 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3346 *
3347 * {@hide}
3348 */
3349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3350 public static final String
3351 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3352
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003353 /**
3354 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3355 *
3356 * {@hide}
3357 */
3358 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003359 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3360
Christopher Tate6597e342015-02-17 12:15:25 -08003361 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003362 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3363 * is about to be performed.
3364 * @hide
3365 */
3366 @SystemApi
3367 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3368 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3369 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3370
3371 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003372 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3373 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3374 *
3375 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3376 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003377 * @hide
3378 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003379 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003380 public static final String EXTRA_FORCE_MASTER_CLEAR =
3381 "android.intent.extra.FORCE_MASTER_CLEAR";
3382
3383 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003384 * A broadcast action to trigger a factory reset.
3385 *
3386 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3387 *
3388 * <p>Not for use by third-party applications.
3389 *
3390 * @see #EXTRA_FORCE_MASTER_CLEAR
3391 *
3392 * {@hide}
3393 */
3394 @SystemApi
3395 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3396 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3397
3398 /**
3399 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3400 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3401 *
3402 * <p>Not for use by third-party applications.
3403 *
3404 * @hide
3405 */
3406 @SystemApi
3407 public static final String EXTRA_FORCE_FACTORY_RESET =
3408 "android.intent.extra.FORCE_FACTORY_RESET";
3409
3410 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003411 * Broadcast action: report that a settings element is being restored from backup. The intent
3412 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3413 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3414 * is the value of that settings entry prior to the restore operation. All of these values are
3415 * represented as strings.
3416 *
3417 * <p>This broadcast is sent only for settings provider entries known to require special handling
3418 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3419 * the provider's backup agent implementation.
3420 *
3421 * @see #EXTRA_SETTING_NAME
3422 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3423 * @see #EXTRA_SETTING_NEW_VALUE
3424 * {@hide}
3425 */
3426 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3427
3428 /** {@hide} */
3429 public static final String EXTRA_SETTING_NAME = "setting_name";
3430 /** {@hide} */
3431 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3432 /** {@hide} */
3433 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3434
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003435 /**
3436 * Activity Action: Process a piece of text.
3437 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3438 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3439 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3440 */
3441 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3442 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003443
3444 /**
3445 * Broadcast Action: The sim card state has changed.
3446 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3447 * because TelephonyIntents is an internal class.
3448 * @hide
3449 */
3450 @SystemApi
3451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3452 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3453
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003454 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003455 * The name of the extra used to define the text to be processed, as a
3456 * CharSequence. Note that this may be a styled CharSequence, so you must use
3457 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003458 */
3459 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3460 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003461 * 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 +00003462 */
3463 public static final String EXTRA_PROCESS_TEXT_READONLY =
3464 "android.intent.extra.PROCESS_TEXT_READONLY";
3465
Bryce Leebc58f592015-09-25 16:43:01 -07003466 /**
3467 * Broadcast action: reports when a new thermal event has been reached. When the device
3468 * is reaching its maximum temperatue, the thermal level reported
3469 * {@hide}
3470 */
3471 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3472 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3473
3474 /** {@hide} */
3475 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3476
3477 /**
3478 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003479 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003480 * {@hide}
3481 */
3482 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3483
3484 /**
3485 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003486 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003487 * {@hide}
3488 */
3489 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3490
3491 /**
3492 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003493 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003494 * {@hide}
3495 */
3496 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3497
3498
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003499 // ---------------------------------------------------------------------
3500 // ---------------------------------------------------------------------
3501 // Standard intent categories (see addCategory()).
3502
3503 /**
3504 * Set if the activity should be an option for the default action
3505 * (center press) to perform on a piece of data. Setting this will
3506 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003507 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003508 * Intent when initiating an action -- it is for use in intent filters
3509 * specified in packages.
3510 */
3511 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3512 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3513 /**
3514 * Activities that can be safely invoked from a browser must support this
3515 * category. For example, if the user is viewing a web page or an e-mail
3516 * and clicks on a link in the text, the Intent generated execute that
3517 * link will require the BROWSABLE category, so that only activities
3518 * supporting this category will be considered as possible actions. By
3519 * supporting this category, you are promising that there is nothing
3520 * damaging (without user intervention) that can happen by invoking any
3521 * matching Intent.
3522 */
3523 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3524 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3525 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003526 * Categories for activities that can participate in voice interaction.
3527 * An activity that supports this category must be prepared to run with
3528 * no UI shown at all (though in some case it may have a UI shown), and
3529 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3530 */
3531 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3532 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3533 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003534 * Set if the activity should be considered as an alternative action to
3535 * the data the user is currently viewing. See also
3536 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3537 * applies to the selection in a list of items.
3538 *
3539 * <p>Supporting this category means that you would like your activity to be
3540 * displayed in the set of alternative things the user can do, usually as
3541 * part of the current activity's options menu. You will usually want to
3542 * include a specific label in the &lt;intent-filter&gt; of this action
3543 * describing to the user what it does.
3544 *
3545 * <p>The action of IntentFilter with this category is important in that it
3546 * describes the specific action the target will perform. This generally
3547 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3548 * a specific name such as "com.android.camera.action.CROP. Only one
3549 * alternative of any particular action will be shown to the user, so using
3550 * a specific action like this makes sure that your alternative will be
3551 * displayed while also allowing other applications to provide their own
3552 * overrides of that particular action.
3553 */
3554 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3555 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3556 /**
3557 * Set if the activity should be considered as an alternative selection
3558 * action to the data the user has currently selected. This is like
3559 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3560 * of items from which the user can select, giving them alternatives to the
3561 * default action that will be performed on it.
3562 */
3563 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3564 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3565 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003566 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003567 */
3568 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3569 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3570 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003571 * Should be displayed in the top-level launcher.
3572 */
3573 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3574 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3575 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003576 * Indicates an activity optimized for Leanback mode, and that should
3577 * be displayed in the Leanback launcher.
3578 */
3579 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3580 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3581 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003582 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3583 * @hide
3584 */
3585 @SystemApi
3586 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3587 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003588 * Provides information about the package it is in; typically used if
3589 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3590 * a front-door to the user without having to be shown in the all apps list.
3591 */
3592 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3593 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3594 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003595 * This is the home activity, that is the first activity that is displayed
3596 * when the device boots.
3597 */
3598 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3599 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3600 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003601 * This is the home activity that is displayed when the device is finished setting up and ready
3602 * for use.
3603 * @hide
3604 */
3605 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3606 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3607 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003608 * This is the setup wizard activity, that is the first activity that is displayed
3609 * when the user sets up the device for the first time.
3610 * @hide
3611 */
3612 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3613 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3614 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003615 * This activity is a preference panel.
3616 */
3617 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3618 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3619 /**
3620 * This activity is a development preference panel.
3621 */
3622 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3623 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3624 /**
3625 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003626 */
3627 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3628 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3629 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003630 * This activity allows the user to browse and download new applications.
3631 */
3632 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3633 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3634 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003635 * This activity may be exercised by the monkey or other automated test tools.
3636 */
3637 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3638 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3639 /**
3640 * To be used as a test (not part of the normal user experience).
3641 */
3642 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3643 /**
3644 * To be used as a unit test (run through the Test Harness).
3645 */
3646 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3647 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003648 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003649 * experience).
3650 */
3651 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003652
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003653 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003654 * Used to indicate that an intent only wants URIs that can be opened with
3655 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3656 * must support at least the columns defined in {@link OpenableColumns} when
3657 * queried.
3658 *
3659 * @see #ACTION_GET_CONTENT
3660 * @see #ACTION_OPEN_DOCUMENT
3661 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003662 */
3663 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3664 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3665
3666 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003667 * Used to indicate that an intent filter can accept files which are not necessarily
3668 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3669 * at least streamable via
3670 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3671 * using one of the stream types exposed via
3672 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3673 *
3674 * @see #ACTION_SEND
3675 * @see #ACTION_SEND_MULTIPLE
3676 */
3677 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3678 public static final String CATEGORY_TYPED_OPENABLE =
3679 "android.intent.category.TYPED_OPENABLE";
3680
3681 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003682 * To be used as code under test for framework instrumentation tests.
3683 */
3684 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3685 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003686 /**
3687 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003688 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3689 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003690 */
3691 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3692 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3693 /**
3694 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003695 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3696 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003697 */
3698 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3699 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003700 /**
3701 * An activity to run when device is inserted into a analog (low end) dock.
3702 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3703 * information, see {@link android.app.UiModeManager}.
3704 */
3705 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3706 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3707
3708 /**
3709 * An activity to run when device is inserted into a digital (high end) dock.
3710 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3711 * information, see {@link android.app.UiModeManager}.
3712 */
3713 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3714 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003715
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003716 /**
3717 * Used to indicate that the activity can be used in a car environment.
3718 */
3719 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3720 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3721
Zak Cohendb6ca492017-01-26 14:09:00 -08003722 /**
3723 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3724 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3725 * information, see {@link android.app.UiModeManager}.
3726 */
3727 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3728 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003729 // ---------------------------------------------------------------------
3730 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003731 // Application launch intent categories (see addCategory()).
3732
3733 /**
3734 * Used with {@link #ACTION_MAIN} to launch the browser application.
3735 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003736 * <p>NOTE: This should not be used as the primary key of an Intent,
3737 * since it will not result in the app launching with the correct
3738 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003739 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003740 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003741 */
3742 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3743 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3744
3745 /**
3746 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3747 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003748 * <p>NOTE: This should not be used as the primary key of an Intent,
3749 * since it will not result in the app launching with the correct
3750 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003751 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003752 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003753 */
3754 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3755 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3756
3757 /**
3758 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3759 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003760 * <p>NOTE: This should not be used as the primary key of an Intent,
3761 * since it will not result in the app launching with the correct
3762 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003763 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003764 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003765 */
3766 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3767 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3768
3769 /**
3770 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3771 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003772 * <p>NOTE: This should not be used as the primary key of an Intent,
3773 * since it will not result in the app launching with the correct
3774 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003775 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003776 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003777 */
3778 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3779 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3780
3781 /**
3782 * Used with {@link #ACTION_MAIN} to launch the email application.
3783 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003784 * <p>NOTE: This should not be used as the primary key of an Intent,
3785 * since it will not result in the app launching with the correct
3786 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003787 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003788 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003789 */
3790 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3791 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3792
3793 /**
3794 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3795 * The activity should be able to view and manipulate image and video files
3796 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003797 * <p>NOTE: This should not be used as the primary key of an Intent,
3798 * since it will not result in the app launching with the correct
3799 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003800 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003801 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003802 */
3803 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3804 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3805
3806 /**
3807 * Used with {@link #ACTION_MAIN} to launch the maps application.
3808 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003809 * <p>NOTE: This should not be used as the primary key of an Intent,
3810 * since it will not result in the app launching with the correct
3811 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003812 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003813 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003814 */
3815 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3816 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3817
3818 /**
3819 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3820 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003821 * <p>NOTE: This should not be used as the primary key of an Intent,
3822 * since it will not result in the app launching with the correct
3823 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003824 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003825 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003826 */
3827 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3828 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3829
3830 /**
3831 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003832 * The activity should be able to play, browse, or manipulate music files
3833 * stored on the device.
3834 * <p>NOTE: This should not be used as the primary key of an Intent,
3835 * since it will not result in the app launching with the correct
3836 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003837 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003838 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003839 */
3840 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3841 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3842
3843 // ---------------------------------------------------------------------
3844 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003845 // Standard extra data keys.
3846
3847 /**
3848 * The initial data to place in a newly created record. Use with
3849 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3850 * fields as would be given to the underlying ContentProvider.insert()
3851 * call.
3852 */
3853 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3854
3855 /**
3856 * A constant CharSequence that is associated with the Intent, used with
3857 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3858 * this may be a styled CharSequence, so you must use
3859 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3860 * retrieve it.
3861 */
3862 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3863
3864 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003865 * A constant String that is associated with the Intent, used with
3866 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3867 * as HTML formatted text. Note that you <em>must</em> also supply
3868 * {@link #EXTRA_TEXT}.
3869 */
3870 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3871
3872 /**
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003873 * A content: URI holding a stream of data associated with the Intent, used
3874 * with {@link #ACTION_SEND} to supply the data being sent.
3875 * <p>
3876 * Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this value
3877 * will be automatically promoted to {@link Intent#setClipData(ClipData)}
3878 * when that value is not already defined.
3879 * <p>
3880 * Starting in {@link android.os.Build.VERSION_CODES#O} this value will be
3881 * automatically demoted from {@link Intent#getClipData()} when this value
3882 * is not already defined.
3883 *
3884 * @deprecated apps should use {@link Intent#setClipData(ClipData)} and
3885 * {@link Intent#getClipData()} instead of this extra, since
3886 * only those APIs can extend temporary permission grants to the
3887 * underlying resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003888 */
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003889 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003890 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3891
3892 /**
3893 * A String[] holding e-mail addresses that should be delivered to.
3894 */
3895 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3896
3897 /**
3898 * A String[] holding e-mail addresses that should be carbon copied.
3899 */
3900 public static final String EXTRA_CC = "android.intent.extra.CC";
3901
3902 /**
3903 * A String[] holding e-mail addresses that should be blind carbon copied.
3904 */
3905 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3906
3907 /**
3908 * A constant string holding the desired subject line of a message.
3909 */
3910 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3911
3912 /**
3913 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003914 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003915 */
3916 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3917
3918 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003919 * An int representing the user id to be used.
3920 *
3921 * @hide
3922 */
3923 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3924
3925 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003926 * An int representing the task id to be retrieved. This is used when a launch from recents is
3927 * intercepted by another action such as credentials confirmation to remember which task should
3928 * be resumed when complete.
3929 *
3930 * @hide
3931 */
3932 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3933
3934 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003935 * An Intent[] describing additional, alternate choices you would like shown with
3936 * {@link #ACTION_CHOOSER}.
3937 *
3938 * <p>An app may be capable of providing several different payload types to complete a
3939 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3940 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3941 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3942 * photo data or a hosted link where the photos can be viewed.</p>
3943 *
3944 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3945 * first/primary/preferred intent in the set. Additional intents specified in
3946 * this extra are ordered; by default intents that appear earlier in the array will be
3947 * preferred over intents that appear later in the array as matches for the same
3948 * target component. To alter this preference, a calling app may also supply
3949 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3950 */
3951 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3952
3953 /**
Adam Powell52c39212016-04-07 15:14:18 -07003954 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3955 * and omitted from a list of components presented to the user.
3956 *
3957 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3958 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3959 * from your own package or other apps from your organization if the idea of sending to those
3960 * targets would be redundant with other app functionality. Filtered components will not
3961 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3962 */
3963 public static final String EXTRA_EXCLUDE_COMPONENTS
3964 = "android.intent.extra.EXCLUDE_COMPONENTS";
3965
3966 /**
3967 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3968 * describing additional high-priority deep-link targets for the chooser to present to the user.
3969 *
3970 * <p>Targets provided in this way will be presented inline with all other targets provided
3971 * by services from other apps. They will be prioritized before other service targets, but
3972 * after those targets provided by sources that the user has manually pinned to the front.</p>
3973 *
3974 * @see #ACTION_CHOOSER
3975 */
3976 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3977
3978 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003979 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3980 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3981 *
3982 * <p>An app preparing an action for another app to complete may wish to allow the user to
3983 * disambiguate between several options for completing the action based on the chosen target
3984 * or otherwise refine the action before it is invoked.
3985 * </p>
3986 *
3987 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3988 * <ul>
3989 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3990 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3991 * chosen target beyond the first</li>
3992 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3993 * should fill in and send once the disambiguation is complete</li>
3994 * </ul>
3995 */
3996 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3997 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3998
3999 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004000 * An {@code ArrayList} of {@code String} annotations describing content for
4001 * {@link #ACTION_CHOOSER}.
4002 *
4003 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4004 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4005 *
4006 * <p>Annotations should describe the major components or topics of the content. It is up to
4007 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4008 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4009 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4010 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4011 * use the following annotations when applicable:</p>
4012 * <ul>
4013 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4014 * health & beauty, and office supplies.</li>
4015 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4016 * happy, and sad.</li>
4017 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4018 * face, finger, standing, and walking.</li>
4019 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4020 * child, and baby.</li>
4021 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4022 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4023 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4024 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4025 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4026 * flowers.</li>
4027 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4028 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4029 * sunglasses, jewelry, handbags and clothing.</li>
4030 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4031 * paper, and silk.</li>
4032 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4033 * cars, and boats.</li>
4034 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4035 * posters.</li>
4036 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4037 * and designs of houses.</li>
4038 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4039 * Christmas and Thanksgiving.</li>
4040 * </ul>
4041 */
4042 public static final String EXTRA_CONTENT_ANNOTATIONS
4043 = "android.intent.extra.CONTENT_ANNOTATIONS";
4044
4045 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004046 * A {@link ResultReceiver} used to return data back to the sender.
4047 *
4048 * <p>Used to complete an app-specific
4049 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4050 *
4051 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4052 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4053 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4054 * when the user selects a target component from the chooser. It is up to the recipient
4055 * to send a result to this ResultReceiver to signal that disambiguation is complete
4056 * and that the chooser should invoke the user's choice.</p>
4057 *
4058 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4059 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4060 * to match and fill in the final Intent or ChooserTarget before starting it.
4061 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4062 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4063 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4064 *
4065 * <p>The result code passed to the ResultReceiver should be
4066 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4067 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4068 * the chooser should finish without starting a target.</p>
4069 */
4070 public static final String EXTRA_RESULT_RECEIVER
4071 = "android.intent.extra.RESULT_RECEIVER";
4072
4073 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004074 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004075 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004076 */
4077 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4078
4079 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004080 * A Parcelable[] of {@link Intent} or
4081 * {@link android.content.pm.LabeledIntent} objects as set with
4082 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4083 * a the front of the list of choices, when shown to the user with a
4084 * {@link #ACTION_CHOOSER}.
4085 */
4086 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4087
4088 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004089 * A {@link IntentSender} to start after ephemeral installation success.
4090 * @hide
4091 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004092 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4093
4094 /**
4095 * A {@link IntentSender} to start after ephemeral installation failure.
4096 * @hide
4097 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004098 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4099
4100 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004101 * The host name that triggered an ephemeral resolution.
4102 * @hide
4103 */
4104 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4105
4106 /**
4107 * An opaque token to track ephemeral resolution.
4108 * @hide
4109 */
4110 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4111
4112 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004113 * The version code of the app to install components from.
4114 * @hide
4115 */
4116 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4117
4118 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004119 * A Bundle forming a mapping of potential target package names to different extras Bundles
4120 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4121 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4122 * be currently installed on the device.
4123 *
4124 * <p>An application may choose to provide alternate extras for the case where a user
4125 * selects an activity from a predetermined set of target packages. If the activity
4126 * the user selects from the chooser belongs to a package with its package name as
4127 * a key in this bundle, the corresponding extras for that package will be merged with
4128 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4129 * extra has the same key as an extra already present in the intent it will overwrite
4130 * the extra from the intent.</p>
4131 *
4132 * <p><em>Examples:</em>
4133 * <ul>
4134 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4135 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4136 * parameters for that target.</li>
4137 * <li>An application may offer additional metadata for known targets of a given intent
4138 * to pass along information only relevant to that target such as account or content
4139 * identifiers already known to that application.</li>
4140 * </ul></p>
4141 */
4142 public static final String EXTRA_REPLACEMENT_EXTRAS =
4143 "android.intent.extra.REPLACEMENT_EXTRAS";
4144
4145 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004146 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4147 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4148 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4149 * {@link ComponentName} of the chosen component.
4150 *
4151 * <p>In some situations this callback may never come, for example if the user abandons
4152 * the chooser, switches to another task or any number of other reasons. Apps should not
4153 * be written assuming that this callback will always occur.</p>
4154 */
4155 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4156 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4157
4158 /**
4159 * The {@link ComponentName} chosen by the user to complete an action.
4160 *
4161 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4162 */
4163 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4164
4165 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004166 * A {@link android.view.KeyEvent} object containing the event that
4167 * triggered the creation of the Intent it is in.
4168 */
4169 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4170
4171 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004172 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4173 * before shutting down.
4174 *
4175 * {@hide}
4176 */
4177 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4178
4179 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004180 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4181 * requested by the user.
4182 *
4183 * {@hide}
4184 */
4185 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4186 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4187
4188 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004189 * 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 -07004190 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4191 * of restarting the application.
4192 */
4193 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4194
4195 /**
4196 * A String holding the phone number originally entered in
4197 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4198 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4199 */
4200 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004201
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004202 /**
4203 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4204 * intents to supply the uid the package had been assigned. Also an optional
4205 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4206 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4207 * purpose.
4208 */
4209 public static final String EXTRA_UID = "android.intent.extra.UID";
4210
4211 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004212 * @hide String array of package names.
4213 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004214 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004215 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4216
4217 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004218 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4219 * intents to indicate whether this represents a full uninstall (removing
4220 * both the code and its data) or a partial uninstall (leaving its data,
4221 * implying that this is an update).
4222 */
4223 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004224
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004225 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004226 * @hide
4227 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4228 * intents to indicate that at this point the package has been removed for
4229 * all users on the device.
4230 */
4231 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4232 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4233
4234 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004235 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4236 * intents to indicate that this is a replacement of the package, so this
4237 * broadcast will immediately be followed by an add broadcast for a
4238 * different version of the same package.
4239 */
4240 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004241
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004242 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004243 * Used as an int extra field in {@link android.app.AlarmManager} intents
4244 * to tell the application being invoked how many pending alarms are being
4245 * delievered with the intent. For one-shot alarms this will always be 1.
4246 * For recurring alarms, this might be greater than 1 if the device was
4247 * asleep or powered off at the time an earlier alarm would have been
4248 * delivered.
4249 */
4250 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004251
Jacek Surazski86b6c532009-05-13 14:38:28 +02004252 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004253 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4254 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004255 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4256 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004257 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4258 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4259 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004260 */
4261 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4262
4263 /**
4264 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4265 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004266 */
4267 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4268
4269 /**
4270 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4271 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004272 */
4273 public static final int EXTRA_DOCK_STATE_DESK = 1;
4274
4275 /**
4276 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4277 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004278 */
4279 public static final int EXTRA_DOCK_STATE_CAR = 2;
4280
4281 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004282 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4283 * to represent that the phone is in a analog (low end) dock.
4284 */
4285 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4286
4287 /**
4288 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4289 * to represent that the phone is in a digital (high end) dock.
4290 */
4291 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4292
4293 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004294 * Boolean that can be supplied as meta-data with a dock activity, to
4295 * indicate that the dock should take over the home key when it is active.
4296 */
4297 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004298
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004299 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004300 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4301 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004302 */
4303 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4304
4305 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004306 * Used in the extra field in the remote intent. It's astring token passed with the
4307 * remote intent.
4308 */
4309 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4310 "android.intent.extra.remote_intent_token";
4311
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004312 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004313 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004314 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004315 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004316 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004317 "android.intent.extra.changed_component_name";
4318
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004319 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004320 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004321 * and contains a string array of all of the components that have changed. If
4322 * the state of the overall package has changed, then it will contain an entry
4323 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004324 */
4325 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4326 "android.intent.extra.changed_component_name_list";
4327
4328 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004329 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004330 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004331 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4332 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4333 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004334 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004335 */
4336 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4337 "android.intent.extra.changed_package_list";
4338
4339 /**
4340 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004341 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4342 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004343 * and contains an integer array of uids of all of the components
4344 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004345 */
4346 public static final String EXTRA_CHANGED_UID_LIST =
4347 "android.intent.extra.changed_uid_list";
4348
4349 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004350 * @hide
4351 * Magic extra system code can use when binding, to give a label for
4352 * who it is that has bound to a service. This is an integer giving
4353 * a framework string resource that can be displayed to the user.
4354 */
4355 public static final String EXTRA_CLIENT_LABEL =
4356 "android.intent.extra.client_label";
4357
4358 /**
4359 * @hide
4360 * Magic extra system code can use when binding, to give a PendingIntent object
4361 * that can be launched for the user to disable the system's use of this
4362 * service.
4363 */
4364 public static final String EXTRA_CLIENT_INTENT =
4365 "android.intent.extra.client_intent";
4366
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004367 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004368 * Extra used to indicate that an intent should only return data that is on
4369 * the local device. This is a boolean extra; the default is false. If true,
4370 * an implementation should only allow the user to select data that is
4371 * already on the device, not requiring it be downloaded from a remote
4372 * service when opened.
4373 *
4374 * @see #ACTION_GET_CONTENT
4375 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004376 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004377 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004378 */
4379 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004380 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004381
Amith Yamasani13593602012-03-22 16:16:17 -07004382 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004383 * Extra used to indicate that an intent can allow the user to select and
4384 * return multiple items. This is a boolean extra; the default is false. If
4385 * true, an implementation is allowed to present the user with a UI where
4386 * they can pick multiple items that are all returned to the caller. When
4387 * this happens, they should be returned as the {@link #getClipData()} part
4388 * of the result Intent.
4389 *
4390 * @see #ACTION_GET_CONTENT
4391 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004392 */
4393 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004394 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004395
4396 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004397 * The integer userHandle carried with broadcast intents related to addition, removal and
4398 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4399 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4400 *
Amith Yamasani13593602012-03-22 16:16:17 -07004401 * @hide
4402 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004403 public static final String EXTRA_USER_HANDLE =
4404 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004405
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004406 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004407 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4408 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4409 */
4410 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004411 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004412
4413 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004414 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004415 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4416 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004417 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004418 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4419
4420 /**
4421 * Extra sent in the intent to the BroadcastReceiver that handles
4422 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4423 * the restrictions as key/value pairs.
4424 */
4425 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4426 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004427
Amith Yamasani86118ba2013-03-28 14:33:16 -07004428 /**
4429 * Extra used in the response from a BroadcastReceiver that handles
4430 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4431 */
4432 public static final String EXTRA_RESTRICTIONS_INTENT =
4433 "android.intent.extra.restrictions_intent";
4434
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004435 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004436 * Extra used to communicate a set of acceptable MIME types. The type of the
4437 * extra is {@code String[]}. Values may be a combination of concrete MIME
4438 * types (such as "image/png") and/or partial MIME types (such as
4439 * "audio/*").
4440 *
4441 * @see #ACTION_GET_CONTENT
4442 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004443 */
4444 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4445
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004446 /**
4447 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4448 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004449 * When this is true, hardware devices can use this information to determine that
4450 * they shouldn't do a complete shutdown of their device since this is not a
4451 * complete shutdown down to the kernel, but only user space restarting.
4452 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004453 */
4454 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4455 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4456
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004457 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004458 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4459 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4460 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4461 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004462 *
4463 * @hide for internal use only.
4464 */
4465 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4466 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004467 /** @hide */
4468 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4469 /** @hide */
4470 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4471 /** @hide */
4472 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004473
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004474 /** {@hide} */
4475 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4476
Rubin Xue8490f12015-06-25 12:17:48 +01004477 /** {@hide} */
4478 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4479
Santos Cordon15a13782015-03-31 18:32:31 -07004480 /**
4481 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4482 * activation request.
4483 * TODO: Add information about the structure and response data used with the pending intent.
4484 * @hide
4485 */
4486 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4487 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4488
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004489 /**
4490 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004491 *
4492 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004493 * @see ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004494 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004495 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4496
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004497 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004498 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4499 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4500 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004501 *
4502 * <p>The value is boolean. By default false.
4503 * @see ACTION_QUICK_VIEW
4504 */
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004505 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4506 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004507
4508 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004509 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004510 * When a profile goes into quiet mode, all apps in the profile are killed and the
4511 * profile user is stopped. Widgets originating from the profile are masked, and app
4512 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004513 */
4514 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004515
4516 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004517 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004518 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004519 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4520 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004521 *
4522 * @hide
4523 */
4524 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4525 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4526
4527 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004528 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4529 * whether to show the chooser or not when there is only one application available
4530 * to choose from.
4531 *
4532 * @hide
4533 */
4534 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4535 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4536
4537 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004538 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004539 * to represent that a video codec is allowed to use.
4540 *
4541 * @hide
4542 */
4543 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4544
4545 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004546 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004547 * to represent that a audio codec is allowed to use.
4548 *
4549 * @hide
4550 */
4551 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4552
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004553 // ---------------------------------------------------------------------
4554 // ---------------------------------------------------------------------
4555 // Intent flags (see mFlags variable).
4556
Tor Norbyed9273d62013-05-30 15:59:53 -07004557 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004558 @IntDef(flag = true, value = {
4559 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4560 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004561 @Retention(RetentionPolicy.SOURCE)
4562 public @interface GrantUriMode {}
4563
Jeff Sharkey846318a2014-04-04 12:12:41 -07004564 /** @hide */
4565 @IntDef(flag = true, value = {
4566 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4567 @Retention(RetentionPolicy.SOURCE)
4568 public @interface AccessUriMode {}
4569
4570 /**
4571 * Test if given mode flags specify an access mode, which must be at least
4572 * read and/or write.
4573 *
4574 * @hide
4575 */
4576 public static boolean isAccessUriMode(int modeFlags) {
4577 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4578 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4579 }
4580
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004581 /**
4582 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004583 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004584 * specified in its ClipData. When applying to an Intent's ClipData,
4585 * all URIs as well as recursive traversals through data or other ClipData
4586 * in Intent items will be granted; only the grant flags of the top-level
4587 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004588 */
4589 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4590 /**
4591 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004592 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004593 * specified in its ClipData. When applying to an Intent's ClipData,
4594 * all URIs as well as recursive traversals through data or other ClipData
4595 * in Intent items will be granted; only the grant flags of the top-level
4596 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004597 */
4598 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4599 /**
4600 * Can be set by the caller to indicate that this Intent is coming from
4601 * a background operation, not from direct user interaction.
4602 */
4603 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4604 /**
4605 * A flag you can enable for debugging: when set, log messages will be
4606 * printed during the resolution of this intent to show you what has
4607 * been found to create the final resolved list.
4608 */
4609 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004610 /**
4611 * If set, this intent will not match any components in packages that
4612 * are currently stopped. If this is not set, then the default behavior
4613 * is to include such applications in the result.
4614 */
4615 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4616 /**
4617 * If set, this intent will always match any components in packages that
4618 * are currently stopped. This is the default behavior when
4619 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4620 * flags are set, this one wins (it allows overriding of exclude for
4621 * places where the framework may automatically set the exclude flag).
4622 */
4623 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004624
4625 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004626 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004627 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004628 * persisted across device reboots until explicitly revoked with
4629 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4630 * grant for possible persisting; the receiving application must call
4631 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4632 * actually persist.
4633 *
4634 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4635 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4636 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004637 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004638 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004639 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004640
4641 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004642 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4643 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4644 * applies to any URI that is a prefix match against the original granted
4645 * URI. (Without this flag, the URI must match exactly for access to be
4646 * granted.) Another URI is considered a prefix match only when scheme,
4647 * authority, and all path segments defined by the prefix are an exact
4648 * match.
4649 */
4650 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4651
4652 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004653 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004654 * homework and verified that they correctly handle packages and components
4655 * that come and go over time. In particular:
4656 * <ul>
4657 * <li>Apps installed on external storage, which will appear to be
4658 * uninstalled while the the device is ejected.
4659 * <li>Apps with encryption unaware components, which will appear to not
4660 * exist while the device is locked.
4661 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004662 *
4663 * @hide
4664 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004665 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004666
4667 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004668 * Internal flag used to indicate ephemeral applications should not be
4669 * considered when resolving the intent.
4670 *
4671 * @hide
4672 */
4673 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4674
4675 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004676 * If set, the new activity is not kept in the history stack. As soon as
4677 * the user navigates away from it, the activity is finished. This may also
4678 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4679 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004680 *
4681 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4682 * is never invoked when the current activity starts a new activity which
4683 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004684 */
4685 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4686 /**
4687 * If set, the activity will not be launched if it is already running
4688 * at the top of the history stack.
4689 */
4690 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4691 /**
4692 * If set, this activity will become the start of a new task on this
4693 * history stack. A task (from the activity that started it to the
4694 * next task activity) defines an atomic group of activities that the
4695 * user can move to. Tasks can be moved to the foreground and background;
4696 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004697 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004698 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4699 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004700 *
4701 * <p>This flag is generally used by activities that want
4702 * to present a "launcher" style behavior: they give the user a list of
4703 * separate things that can be done, which otherwise run completely
4704 * independently of the activity launching them.
4705 *
4706 * <p>When using this flag, if a task is already running for the activity
4707 * you are now starting, then a new activity will not be started; instead,
4708 * the current task will simply be brought to the front of the screen with
4709 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4710 * to disable this behavior.
4711 *
4712 * <p>This flag can not be used when the caller is requesting a result from
4713 * the activity being launched.
4714 */
4715 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4716 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004717 * This flag is used to create a new task and launch an activity into it.
4718 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4719 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4720 * search through existing tasks for ones matching this Intent. Only if no such
4721 * task is found would a new task be created. When paired with
4722 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4723 * the search for a matching task and unconditionally start a new task.
4724 *
4725 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4726 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004727 * top-level application launcher.</strong> Used in conjunction with
4728 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4729 * behavior of bringing an existing task to the foreground. When set,
4730 * a new task is <em>always</em> started to host the Activity for the
4731 * Intent, regardless of whether there is already an existing task running
4732 * the same thing.
4733 *
4734 * <p><strong>Because the default system does not include graphical task management,
4735 * you should not use this flag unless you provide some way for a user to
4736 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004737 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004738 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4739 * creating new document tasks.
4740 *
4741 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004742 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004743 *
Scott Main7aee61f2011-02-08 11:25:01 -08004744 * <p>See
4745 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4746 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004747 *
4748 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4749 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004750 */
4751 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4752 /**
4753 * If set, and the activity being launched is already running in the
4754 * current task, then instead of launching a new instance of that activity,
4755 * all of the other activities on top of it will be closed and this Intent
4756 * will be delivered to the (now on top) old activity as a new Intent.
4757 *
4758 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4759 * If D calls startActivity() with an Intent that resolves to the component
4760 * of activity B, then C and D will be finished and B receive the given
4761 * Intent, resulting in the stack now being: A, B.
4762 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004763 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004764 * either receive the new intent you are starting here in its
4765 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004766 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004767 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4768 * the same intent, then it will be finished and re-created; for all other
4769 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4770 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004771 *
4772 * <p>This launch mode can also be used to good effect in conjunction with
4773 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4774 * of a task, it will bring any currently running instance of that task
4775 * to the foreground, and then clear it to its root state. This is
4776 * especially useful, for example, when launching an activity from the
4777 * notification manager.
4778 *
Scott Main7aee61f2011-02-08 11:25:01 -08004779 * <p>See
4780 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4781 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004782 */
4783 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4784 /**
4785 * If set and this intent is being used to launch a new activity from an
4786 * existing one, then the reply target of the existing activity will be
4787 * transfered to the new activity. This way the new activity can call
4788 * {@link android.app.Activity#setResult} and have that result sent back to
4789 * the reply target of the original activity.
4790 */
4791 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4792 /**
4793 * If set and this intent is being used to launch a new activity from an
4794 * existing one, the current activity will not be counted as the top
4795 * activity for deciding whether the new intent should be delivered to
4796 * the top instead of starting a new one. The previous activity will
4797 * be used as the top, with the assumption being that the current activity
4798 * will finish itself immediately.
4799 */
4800 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4801 /**
4802 * If set, the new activity is not kept in the list of recently launched
4803 * activities.
4804 */
4805 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4806 /**
4807 * This flag is not normally set by application code, but set for you by
4808 * the system as described in the
4809 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4810 * launchMode} documentation for the singleTask mode.
4811 */
4812 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4813 /**
4814 * If set, and this activity is either being started in a new task or
4815 * bringing to the top an existing task, then it will be launched as
4816 * the front door of the task. This will result in the application of
4817 * any affinities needed to have that task in the proper state (either
4818 * moving activities to or from it), or simply resetting that task to
4819 * its initial state if needed.
4820 */
4821 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4822 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004823 * This flag is not normally set by application code, but set for you by
4824 * the system if this activity is being launched from history
4825 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004826 */
4827 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004828 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004829 * @deprecated As of API 21 this performs identically to
4830 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004831 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004832 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004833 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004834 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004835 * This flag is used to open a document into a new task rooted at the activity launched
4836 * by this Intent. Through the use of this flag, or its equivalent attribute,
4837 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004838 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004839 *
Craig Mautner026596b2014-05-21 15:35:44 -07004840 * <p>The use of the activity attribute form of this,
4841 * {@link android.R.attr#documentLaunchMode}, is
4842 * preferred over the Intent flag described here. The attribute form allows the
4843 * Activity to specify multiple document behavior for all launchers of the Activity
4844 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004845 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004846 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4847 * it is kept after the activity is finished is different than the use of
4848 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4849 * this flag is being used to create a new recents entry, then by default that entry
4850 * will be removed once the activity is finished. You can modify this behavior with
4851 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4852 *
Craig Mautner026596b2014-05-21 15:35:44 -07004853 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4854 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4855 * equivalent of the Activity manifest specifying {@link
4856 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4857 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4858 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004859 *
Craig Mautner026596b2014-05-21 15:35:44 -07004860 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004861 *
Craig Mautner026596b2014-05-21 15:35:44 -07004862 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004863 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4864 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004865 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004866 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004867 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004868 * callback from occurring on the current frontmost activity before it is
4869 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004870 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004871 * <p>Typically, an activity can rely on that callback to indicate that an
4872 * explicit user action has caused their activity to be moved out of the
4873 * foreground. The callback marks an appropriate point in the activity's
4874 * lifecycle for it to dismiss any notifications that it intends to display
4875 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004876 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004877 * <p>If an activity is ever started via any non-user-driven events such as
4878 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4879 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004880 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004881 */
4882 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004883 /**
4884 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4885 * this flag will cause the launched activity to be brought to the front of its
4886 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004887 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004888 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4889 * If D calls startActivity() with an Intent that resolves to the component
4890 * of activity B, then B will be brought to the front of the history stack,
4891 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004892 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004893 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004894 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004895 */
4896 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004897 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004898 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4899 * this flag will prevent the system from applying an activity transition
4900 * animation to go to the next activity state. This doesn't mean an
4901 * animation will never run -- if another activity change happens that doesn't
4902 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004903 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004904 * when you are going to do a series of activity operations but the
4905 * animation seen by the user shouldn't be driven by the first activity
4906 * change but rather a later one.
4907 */
4908 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4909 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004910 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4911 * this flag will cause any existing task that would be associated with the
4912 * activity to be cleared before the activity is started. That is, the activity
4913 * becomes the new root of an otherwise empty task, and any old activities
4914 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4915 */
4916 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4917 /**
4918 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4919 * this flag will cause a newly launching task to be placed on top of the current
4920 * home activity task (if there is one). That is, pressing back from the task
4921 * will always return the user to home even if that was not the last activity they
4922 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4923 */
4924 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4925 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004926 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4927 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004928 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004929 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004930 * this flag. When set and the task's activity is finished, the recents
4931 * entry will remain in the interface for the user to re-launch it, like a
4932 * recents entry for a top-level application.
4933 * <p>
4934 * The receiving activity can override this request with
4935 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4936 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004937 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004938 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004939 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004940
4941 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004942 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4943 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004944 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4945 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004946 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004947 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004948
4949 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004950 * If set, when sending a broadcast only registered receivers will be
4951 * called -- no BroadcastReceiver components will be launched.
4952 */
4953 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004954 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004955 * If set, when sending a broadcast the new broadcast will replace
4956 * any existing pending broadcast that matches it. Matching is defined
4957 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4958 * true for the intents of the two broadcasts. When a match is found,
4959 * the new broadcast (and receivers associated with it) will replace the
4960 * existing one in the pending broadcast list, remaining at the same
4961 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004962 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004963 * <p>This flag is most typically used with sticky broadcasts, which
4964 * only care about delivering the most recent values of the broadcast
4965 * to their receivers.
4966 */
4967 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4968 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004969 * If set, when sending a broadcast the recipient is allowed to run at
4970 * foreground priority, with a shorter timeout interval. During normal
4971 * broadcasts the receivers are not automatically hoisted out of the
4972 * background priority class.
4973 */
4974 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4975 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004976 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4977 * They can still propagate results through to later receivers, but they can not prevent
4978 * later receivers from seeing the broadcast.
4979 */
4980 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4981 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004982 * If set, when sending a broadcast <i>before boot has completed</i> only
4983 * registered receivers will be called -- no BroadcastReceiver components
4984 * will be launched. Sticky intent state will be recorded properly even
4985 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4986 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004987 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004988 * <p>This flag is only for use by system sevices as a convenience to
4989 * avoid having to implement a more complex mechanism around detection
4990 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004991 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004992 * @hide
4993 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004994 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004995 /**
4996 * Set when this broadcast is for a boot upgrade, a special mode that
4997 * allows the broadcast to be sent before the system is ready and launches
4998 * the app process with no providers running in it.
4999 * @hide
5000 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005001 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005002 /**
5003 * If set, the broadcast will always go to manifest receivers in background (cached
5004 * or not running) apps, regardless of whether that would be done by default. By
5005 * default they will only receive broadcasts if the broadcast has specified an
5006 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005007 *
5008 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5009 * the broadcast code there must also be changed to match.
5010 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005011 * @hide
5012 */
5013 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5014 /**
5015 * If set, the broadcast will never go to manifest receivers in background (cached
5016 * or not running) apps, regardless of whether that would be done by default. By
5017 * default they will receive broadcasts if the broadcast has specified an
5018 * explicit component or package name.
5019 * @hide
5020 */
5021 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005022 /**
5023 * If set, this broadcast is being sent from the shell.
5024 * @hide
5025 */
5026 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005027
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005028 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005029 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5030 * will not receive broadcasts.
5031 *
5032 * <em>This flag has no effect when used by an Instant App.</em>
5033 */
5034 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5035
5036 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005037 * @hide Flags that can't be changed with PendingIntent.
5038 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005039 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5040 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5041 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005042
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005043 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005044 // ---------------------------------------------------------------------
5045 // toUri() and parseUri() options.
5046
5047 /**
5048 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5049 * always has the "intent:" scheme. This syntax can be used when you want
5050 * to later disambiguate between URIs that are intended to describe an
5051 * Intent vs. all others that should be treated as raw URIs. When used
5052 * with {@link #parseUri}, any other scheme will result in a generic
5053 * VIEW action for that raw URI.
5054 */
5055 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005056
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005057 /**
5058 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5059 * always has the "android-app:" scheme. This is a variation of
5060 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5061 * http/https URI being delivered to a specific package name. The format
5062 * is:
5063 *
5064 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005065 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005066 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005067 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5068 * you must also include a scheme; including a path also requires both a host and a scheme.
5069 * The final #Intent; fragment can be used without a scheme, host, or path.
5070 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005071 * used with intents that have a {@link #setSelector}, since the base intent
5072 * will always have an explicit package name.</p>
5073 *
5074 * <p>Some examples of how this scheme maps to Intent objects:</p>
5075 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5076 * <colgroup align="left" />
5077 * <colgroup align="left" />
5078 * <thead>
5079 * <tr><th>URI</th> <th>Intent</th></tr>
5080 * </thead>
5081 *
5082 * <tbody>
5083 * <tr><td><code>android-app://com.example.app</code></td>
5084 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5085 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5086 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5087 * </table></td>
5088 * </tr>
5089 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5090 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5091 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5092 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5093 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5094 * </table></td>
5095 * </tr>
5096 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5097 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5098 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5099 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5100 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5101 * </table></td>
5102 * </tr>
5103 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5104 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5105 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5106 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5107 * </table></td>
5108 * </tr>
5109 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5110 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5111 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5112 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5113 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5114 * </table></td>
5115 * </tr>
5116 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
5117 * <td><table border="" style="margin:0" >
5118 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5119 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5120 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5121 * </table></td>
5122 * </tr>
5123 * </tbody>
5124 * </table>
5125 */
5126 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5127
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005128 /**
5129 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5130 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5131 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5132 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5133 * generated Intent can not cause unexpected data access to happen.
5134 *
5135 * <p>If you do not trust the source of the URI being parsed, you should still do further
5136 * processing to protect yourself from it. In particular, when using it to start an
5137 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5138 * that can handle it.</p>
5139 */
5140 public static final int URI_ALLOW_UNSAFE = 1<<2;
5141
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005142 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005143
5144 private String mAction;
5145 private Uri mData;
5146 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005147 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005148 private ComponentName mComponent;
5149 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005150 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005151 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005152 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005153 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005154 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005155 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005156 /** Token to track instant app launches. Local only; do not copy cross-process. */
5157 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005158
5159 // ---------------------------------------------------------------------
5160
5161 /**
5162 * Create an empty intent.
5163 */
5164 public Intent() {
5165 }
5166
5167 /**
5168 * Copy constructor.
5169 */
5170 public Intent(Intent o) {
5171 this.mAction = o.mAction;
5172 this.mData = o.mData;
5173 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005174 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005175 this.mComponent = o.mComponent;
5176 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005177 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005178 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005179 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005180 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005181 }
5182 if (o.mExtras != null) {
5183 this.mExtras = new Bundle(o.mExtras);
5184 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005185 if (o.mSourceBounds != null) {
5186 this.mSourceBounds = new Rect(o.mSourceBounds);
5187 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005188 if (o.mSelector != null) {
5189 this.mSelector = new Intent(o.mSelector);
5190 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005191 if (o.mClipData != null) {
5192 this.mClipData = new ClipData(o.mClipData);
5193 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005194 }
5195
5196 @Override
5197 public Object clone() {
5198 return new Intent(this);
5199 }
5200
5201 private Intent(Intent o, boolean all) {
5202 this.mAction = o.mAction;
5203 this.mData = o.mData;
5204 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005205 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005206 this.mComponent = o.mComponent;
5207 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 }
5211
5212 /**
5213 * Make a clone of only the parts of the Intent that are relevant for
5214 * filter matching: the action, data, type, component, and categories.
5215 */
5216 public Intent cloneFilter() {
5217 return new Intent(this, false);
5218 }
5219
5220 /**
5221 * Create an intent with a given action. All other fields (data, type,
5222 * class) are null. Note that the action <em>must</em> be in a
5223 * namespace because Intents are used globally in the system -- for
5224 * example the system VIEW action is android.intent.action.VIEW; an
5225 * application's custom action would be something like
5226 * com.google.app.myapp.CUSTOM_ACTION.
5227 *
5228 * @param action The Intent action, such as ACTION_VIEW.
5229 */
5230 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005231 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005232 }
5233
5234 /**
5235 * Create an intent with a given action and for a given data url. Note
5236 * that the action <em>must</em> be in a namespace because Intents are
5237 * used globally in the system -- for example the system VIEW action is
5238 * android.intent.action.VIEW; an application's custom action would be
5239 * something like com.google.app.myapp.CUSTOM_ACTION.
5240 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005241 * <p><em>Note: scheme and host name matching in the Android framework is
5242 * case-sensitive, unlike the formal RFC. As a result,
5243 * you should always ensure that you write your Uri with these elements
5244 * using lower case letters, and normalize any Uris you receive from
5245 * outside of Android to ensure the scheme and host is lower case.</em></p>
5246 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005247 * @param action The Intent action, such as ACTION_VIEW.
5248 * @param uri The Intent data URI.
5249 */
5250 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005251 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005252 mData = uri;
5253 }
5254
5255 /**
5256 * Create an intent for a specific component. All other fields (action, data,
5257 * type, class) are null, though they can be modified later with explicit
5258 * calls. This provides a convenient way to create an intent that is
5259 * intended to execute a hard-coded class name, rather than relying on the
5260 * system to find an appropriate class for you; see {@link #setComponent}
5261 * for more information on the repercussions of this.
5262 *
5263 * @param packageContext A Context of the application package implementing
5264 * this class.
5265 * @param cls The component class that is to be used for the intent.
5266 *
5267 * @see #setClass
5268 * @see #setComponent
5269 * @see #Intent(String, android.net.Uri , Context, Class)
5270 */
5271 public Intent(Context packageContext, Class<?> cls) {
5272 mComponent = new ComponentName(packageContext, cls);
5273 }
5274
5275 /**
5276 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005277 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005278 * construct the Intent and then calling {@link #setClass} to set its
5279 * class.
5280 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005281 * <p><em>Note: scheme and host name matching in the Android framework is
5282 * case-sensitive, unlike the formal RFC. As a result,
5283 * you should always ensure that you write your Uri with these elements
5284 * using lower case letters, and normalize any Uris you receive from
5285 * outside of Android to ensure the scheme and host is lower case.</em></p>
5286 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005287 * @param action The Intent action, such as ACTION_VIEW.
5288 * @param uri The Intent data URI.
5289 * @param packageContext A Context of the application package implementing
5290 * this class.
5291 * @param cls The component class that is to be used for the intent.
5292 *
5293 * @see #Intent(String, android.net.Uri)
5294 * @see #Intent(Context, Class)
5295 * @see #setClass
5296 * @see #setComponent
5297 */
5298 public Intent(String action, Uri uri,
5299 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005300 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005301 mData = uri;
5302 mComponent = new ComponentName(packageContext, cls);
5303 }
5304
5305 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005306 * Create an intent to launch the main (root) activity of a task. This
5307 * is the Intent that is started when the application's is launched from
5308 * Home. For anything else that wants to launch an application in the
5309 * same way, it is important that they use an Intent structured the same
5310 * way, and can use this function to ensure this is the case.
5311 *
5312 * <p>The returned Intent has the given Activity component as its explicit
5313 * component, {@link #ACTION_MAIN} as its action, and includes the
5314 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5315 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5316 * to do that through {@link #addFlags(int)} on the returned Intent.
5317 *
5318 * @param mainActivity The main activity component that this Intent will
5319 * launch.
5320 * @return Returns a newly created Intent that can be used to launch the
5321 * activity as a main application entry.
5322 *
5323 * @see #setClass
5324 * @see #setComponent
5325 */
5326 public static Intent makeMainActivity(ComponentName mainActivity) {
5327 Intent intent = new Intent(ACTION_MAIN);
5328 intent.setComponent(mainActivity);
5329 intent.addCategory(CATEGORY_LAUNCHER);
5330 return intent;
5331 }
5332
5333 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005334 * Make an Intent for the main activity of an application, without
5335 * specifying a specific activity to run but giving a selector to find
5336 * the activity. This results in a final Intent that is structured
5337 * the same as when the application is launched from
5338 * Home. For anything else that wants to launch an application in the
5339 * same way, it is important that they use an Intent structured the same
5340 * way, and can use this function to ensure this is the case.
5341 *
5342 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5343 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5344 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5345 * to do that through {@link #addFlags(int)} on the returned Intent.
5346 *
5347 * @param selectorAction The action name of the Intent's selector.
5348 * @param selectorCategory The name of a category to add to the Intent's
5349 * selector.
5350 * @return Returns a newly created Intent that can be used to launch the
5351 * activity as a main application entry.
5352 *
5353 * @see #setSelector(Intent)
5354 */
5355 public static Intent makeMainSelectorActivity(String selectorAction,
5356 String selectorCategory) {
5357 Intent intent = new Intent(ACTION_MAIN);
5358 intent.addCategory(CATEGORY_LAUNCHER);
5359 Intent selector = new Intent();
5360 selector.setAction(selectorAction);
5361 selector.addCategory(selectorCategory);
5362 intent.setSelector(selector);
5363 return intent;
5364 }
5365
5366 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005367 * Make an Intent that can be used to re-launch an application's task
5368 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5369 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5370 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5371 *
5372 * @param mainActivity The activity component that is the root of the
5373 * task; this is the activity that has been published in the application's
5374 * manifest as the main launcher icon.
5375 *
5376 * @return Returns a newly created Intent that can be used to relaunch the
5377 * activity's task in its root state.
5378 */
5379 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5380 Intent intent = makeMainActivity(mainActivity);
5381 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5382 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5383 return intent;
5384 }
5385
5386 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005387 * Call {@link #parseUri} with 0 flags.
5388 * @deprecated Use {@link #parseUri} instead.
5389 */
5390 @Deprecated
5391 public static Intent getIntent(String uri) throws URISyntaxException {
5392 return parseUri(uri, 0);
5393 }
Tom Taylord4a47292009-12-21 13:59:18 -08005394
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005395 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005396 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005397 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005398 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005399 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005400 *
5401 * <p>The URI given here must not be relative -- that is, it must include
5402 * the scheme and full path.
5403 *
5404 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005405 * @param flags Additional processing flags. Either 0,
5406 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005407 *
5408 * @return Intent The newly created Intent object.
5409 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005410 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5411 * it bad (as parsed by the Uri class) or the Intent data within the
5412 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005413 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005414 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005415 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005416 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005417 int i = 0;
5418 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005419 final boolean androidApp = uri.startsWith("android-app:");
5420
5421 // Validate intent scheme if requested.
5422 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5423 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005424 Intent intent = new Intent(ACTION_VIEW);
5425 try {
5426 intent.setData(Uri.parse(uri));
5427 } catch (IllegalArgumentException e) {
5428 throw new URISyntaxException(uri, e.getMessage());
5429 }
5430 return intent;
5431 }
5432 }
Tom Taylord4a47292009-12-21 13:59:18 -08005433
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005434 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005435 // simple case
5436 if (i == -1) {
5437 if (!androidApp) {
5438 return new Intent(ACTION_VIEW, Uri.parse(uri));
5439 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005440
5441 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005442 } else if (!uri.startsWith("#Intent;", i)) {
5443 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005444 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005445 } else {
5446 i = -1;
5447 }
5448 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005449
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005450 // new format
5451 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005452 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005453 boolean explicitAction = false;
5454 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005455
5456 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005457 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005458 String data;
5459 if (i >= 0) {
5460 data = uri.substring(0, i);
5461 i += 8; // length of "#Intent;"
5462 } else {
5463 data = uri;
5464 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005465
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005467 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005468 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005469 if (eq < 0) eq = i-1;
5470 int semi = uri.indexOf(';', i);
5471 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005472
5473 // action
5474 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005475 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005476 if (!inSelector) {
5477 explicitAction = true;
5478 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005479 }
5480
5481 // categories
5482 else if (uri.startsWith("category=", i)) {
5483 intent.addCategory(value);
5484 }
5485
5486 // type
5487 else if (uri.startsWith("type=", i)) {
5488 intent.mType = value;
5489 }
5490
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005491 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005492 else if (uri.startsWith("launchFlags=", i)) {
5493 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005494 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5495 intent.mFlags &= ~IMMUTABLE_FLAGS;
5496 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005497 }
5498
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005499 // package
5500 else if (uri.startsWith("package=", i)) {
5501 intent.mPackage = value;
5502 }
5503
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005504 // component
5505 else if (uri.startsWith("component=", i)) {
5506 intent.mComponent = ComponentName.unflattenFromString(value);
5507 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005508
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005509 // scheme
5510 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005511 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005512 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005513 } else {
5514 scheme = value;
5515 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005516 }
5517
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005518 // source bounds
5519 else if (uri.startsWith("sourceBounds=", i)) {
5520 intent.mSourceBounds = Rect.unflattenFromString(value);
5521 }
5522
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005523 // selector
5524 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5525 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005526 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005527 }
5528
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005529 // extra
5530 else {
5531 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005532 // create Bundle if it doesn't already exist
5533 if (intent.mExtras == null) intent.mExtras = new Bundle();
5534 Bundle b = intent.mExtras;
5535 // add EXTRA
5536 if (uri.startsWith("S.", i)) b.putString(key, value);
5537 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5538 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5539 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5540 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5541 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5542 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5543 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5544 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5545 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5546 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005547
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005548 // move to the next item
5549 i = semi + 1;
5550 }
5551
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005552 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005553 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005554 if (baseIntent.mPackage == null) {
5555 baseIntent.setSelector(intent);
5556 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005557 intent = baseIntent;
5558 }
5559
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005560 if (data != null) {
5561 if (data.startsWith("intent:")) {
5562 data = data.substring(7);
5563 if (scheme != null) {
5564 data = scheme + ':' + data;
5565 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005566 } else if (data.startsWith("android-app:")) {
5567 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5568 // Correctly formed android-app, first part is package name.
5569 int end = data.indexOf('/', 14);
5570 if (end < 0) {
5571 // All we have is a package name.
5572 intent.mPackage = data.substring(14);
5573 if (!explicitAction) {
5574 intent.setAction(ACTION_MAIN);
5575 }
5576 data = "";
5577 } else {
5578 // Target the Intent at the given package name always.
5579 String authority = null;
5580 intent.mPackage = data.substring(14, end);
5581 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005582 if ((end+1) < data.length()) {
5583 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5584 // Found a scheme, remember it.
5585 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005586 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005587 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5588 // Found a authority, remember it.
5589 authority = data.substring(end+1, newEnd);
5590 end = newEnd;
5591 }
5592 } else {
5593 // All we have is a scheme.
5594 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005595 }
5596 }
5597 if (scheme == null) {
5598 // If there was no scheme, then this just targets the package.
5599 if (!explicitAction) {
5600 intent.setAction(ACTION_MAIN);
5601 }
5602 data = "";
5603 } else if (authority == null) {
5604 data = scheme + ":";
5605 } else {
5606 data = scheme + "://" + authority + data.substring(end);
5607 }
5608 }
5609 } else {
5610 data = "";
5611 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005612 }
Tom Taylord4a47292009-12-21 13:59:18 -08005613
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005614 if (data.length() > 0) {
5615 try {
5616 intent.mData = Uri.parse(data);
5617 } catch (IllegalArgumentException e) {
5618 throw new URISyntaxException(uri, e.getMessage());
5619 }
5620 }
5621 }
Tom Taylord4a47292009-12-21 13:59:18 -08005622
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005623 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005624
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005625 } catch (IndexOutOfBoundsException e) {
5626 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5627 }
5628 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005629
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005630 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005631 return getIntentOld(uri, 0);
5632 }
5633
5634 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005635 Intent intent;
5636
5637 int i = uri.lastIndexOf('#');
5638 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005639 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005640 final int intentFragmentStart = i;
5641 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005642
5643 i++;
5644
5645 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005646 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005647 i += 7;
5648 int j = uri.indexOf(')', i);
5649 action = uri.substring(i, j);
5650 i = j + 1;
5651 }
5652
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005653 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005654
5655 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005656 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005657 i += 11;
5658 int j = uri.indexOf(')', i);
5659 while (i < j) {
5660 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005661 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005662 if (i < sep) {
5663 intent.addCategory(uri.substring(i, sep));
5664 }
5665 i = sep + 1;
5666 }
5667 i = j + 1;
5668 }
5669
5670 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005671 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005672 i += 5;
5673 int j = uri.indexOf(')', i);
5674 intent.mType = uri.substring(i, j);
5675 i = j + 1;
5676 }
5677
5678 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005679 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005680 i += 12;
5681 int j = uri.indexOf(')', i);
5682 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005683 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5684 intent.mFlags &= ~IMMUTABLE_FLAGS;
5685 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005686 i = j + 1;
5687 }
5688
5689 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005690 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005691 i += 10;
5692 int j = uri.indexOf(')', i);
5693 int sep = uri.indexOf('!', i);
5694 if (sep >= 0 && sep < j) {
5695 String pkg = uri.substring(i, sep);
5696 String cls = uri.substring(sep + 1, j);
5697 intent.mComponent = new ComponentName(pkg, cls);
5698 }
5699 i = j + 1;
5700 }
5701
5702 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005703 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005704 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005706 final int closeParen = uri.indexOf(')', i);
5707 if (closeParen == -1) throw new URISyntaxException(uri,
5708 "EXTRA missing trailing ')'", i);
5709
5710 while (i < closeParen) {
5711 // fetch the key value
5712 int j = uri.indexOf('=', i);
5713 if (j <= i + 1 || i >= closeParen) {
5714 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5715 }
5716 char type = uri.charAt(i);
5717 i++;
5718 String key = uri.substring(i, j);
5719 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005720
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005721 // get type-value
5722 j = uri.indexOf('!', i);
5723 if (j == -1 || j >= closeParen) j = closeParen;
5724 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5725 String value = uri.substring(i, j);
5726 i = j;
5727
5728 // create Bundle if it doesn't already exist
5729 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005730
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005731 // add item to bundle
5732 try {
5733 switch (type) {
5734 case 'S':
5735 intent.mExtras.putString(key, Uri.decode(value));
5736 break;
5737 case 'B':
5738 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5739 break;
5740 case 'b':
5741 intent.mExtras.putByte(key, Byte.parseByte(value));
5742 break;
5743 case 'c':
5744 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5745 break;
5746 case 'd':
5747 intent.mExtras.putDouble(key, Double.parseDouble(value));
5748 break;
5749 case 'f':
5750 intent.mExtras.putFloat(key, Float.parseFloat(value));
5751 break;
5752 case 'i':
5753 intent.mExtras.putInt(key, Integer.parseInt(value));
5754 break;
5755 case 'l':
5756 intent.mExtras.putLong(key, Long.parseLong(value));
5757 break;
5758 case 's':
5759 intent.mExtras.putShort(key, Short.parseShort(value));
5760 break;
5761 default:
5762 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5763 }
5764 } catch (NumberFormatException e) {
5765 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5766 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005767
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005768 char ch = uri.charAt(i);
5769 if (ch == ')') break;
5770 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5771 i++;
5772 }
5773 }
5774
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005775 if (isIntentFragment) {
5776 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5777 } else {
5778 intent.mData = Uri.parse(uri);
5779 }
Tom Taylord4a47292009-12-21 13:59:18 -08005780
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005781 if (intent.mAction == null) {
5782 // By default, if no action is specified, then use VIEW.
5783 intent.mAction = ACTION_VIEW;
5784 }
5785
5786 } else {
5787 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5788 }
5789
5790 return intent;
5791 }
5792
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005793 /** @hide */
5794 public interface CommandOptionHandler {
5795 boolean handleOption(String opt, ShellCommand cmd);
5796 }
5797
5798 /** @hide */
5799 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5800 throws URISyntaxException {
5801 Intent intent = new Intent();
5802 Intent baseIntent = intent;
5803 boolean hasIntentInfo = false;
5804
5805 Uri data = null;
5806 String type = null;
5807
5808 String opt;
5809 while ((opt=cmd.getNextOption()) != null) {
5810 switch (opt) {
5811 case "-a":
5812 intent.setAction(cmd.getNextArgRequired());
5813 if (intent == baseIntent) {
5814 hasIntentInfo = true;
5815 }
5816 break;
5817 case "-d":
5818 data = Uri.parse(cmd.getNextArgRequired());
5819 if (intent == baseIntent) {
5820 hasIntentInfo = true;
5821 }
5822 break;
5823 case "-t":
5824 type = cmd.getNextArgRequired();
5825 if (intent == baseIntent) {
5826 hasIntentInfo = true;
5827 }
5828 break;
5829 case "-c":
5830 intent.addCategory(cmd.getNextArgRequired());
5831 if (intent == baseIntent) {
5832 hasIntentInfo = true;
5833 }
5834 break;
5835 case "-e":
5836 case "--es": {
5837 String key = cmd.getNextArgRequired();
5838 String value = cmd.getNextArgRequired();
5839 intent.putExtra(key, value);
5840 }
5841 break;
5842 case "--esn": {
5843 String key = cmd.getNextArgRequired();
5844 intent.putExtra(key, (String) null);
5845 }
5846 break;
5847 case "--ei": {
5848 String key = cmd.getNextArgRequired();
5849 String value = cmd.getNextArgRequired();
5850 intent.putExtra(key, Integer.decode(value));
5851 }
5852 break;
5853 case "--eu": {
5854 String key = cmd.getNextArgRequired();
5855 String value = cmd.getNextArgRequired();
5856 intent.putExtra(key, Uri.parse(value));
5857 }
5858 break;
5859 case "--ecn": {
5860 String key = cmd.getNextArgRequired();
5861 String value = cmd.getNextArgRequired();
5862 ComponentName cn = ComponentName.unflattenFromString(value);
5863 if (cn == null)
5864 throw new IllegalArgumentException("Bad component name: " + value);
5865 intent.putExtra(key, cn);
5866 }
5867 break;
5868 case "--eia": {
5869 String key = cmd.getNextArgRequired();
5870 String value = cmd.getNextArgRequired();
5871 String[] strings = value.split(",");
5872 int[] list = new int[strings.length];
5873 for (int i = 0; i < strings.length; i++) {
5874 list[i] = Integer.decode(strings[i]);
5875 }
5876 intent.putExtra(key, list);
5877 }
5878 break;
5879 case "--eial": {
5880 String key = cmd.getNextArgRequired();
5881 String value = cmd.getNextArgRequired();
5882 String[] strings = value.split(",");
5883 ArrayList<Integer> list = new ArrayList<>(strings.length);
5884 for (int i = 0; i < strings.length; i++) {
5885 list.add(Integer.decode(strings[i]));
5886 }
5887 intent.putExtra(key, list);
5888 }
5889 break;
5890 case "--el": {
5891 String key = cmd.getNextArgRequired();
5892 String value = cmd.getNextArgRequired();
5893 intent.putExtra(key, Long.valueOf(value));
5894 }
5895 break;
5896 case "--ela": {
5897 String key = cmd.getNextArgRequired();
5898 String value = cmd.getNextArgRequired();
5899 String[] strings = value.split(",");
5900 long[] list = new long[strings.length];
5901 for (int i = 0; i < strings.length; i++) {
5902 list[i] = Long.valueOf(strings[i]);
5903 }
5904 intent.putExtra(key, list);
5905 hasIntentInfo = true;
5906 }
5907 break;
5908 case "--elal": {
5909 String key = cmd.getNextArgRequired();
5910 String value = cmd.getNextArgRequired();
5911 String[] strings = value.split(",");
5912 ArrayList<Long> list = new ArrayList<>(strings.length);
5913 for (int i = 0; i < strings.length; i++) {
5914 list.add(Long.valueOf(strings[i]));
5915 }
5916 intent.putExtra(key, list);
5917 hasIntentInfo = true;
5918 }
5919 break;
5920 case "--ef": {
5921 String key = cmd.getNextArgRequired();
5922 String value = cmd.getNextArgRequired();
5923 intent.putExtra(key, Float.valueOf(value));
5924 hasIntentInfo = true;
5925 }
5926 break;
5927 case "--efa": {
5928 String key = cmd.getNextArgRequired();
5929 String value = cmd.getNextArgRequired();
5930 String[] strings = value.split(",");
5931 float[] list = new float[strings.length];
5932 for (int i = 0; i < strings.length; i++) {
5933 list[i] = Float.valueOf(strings[i]);
5934 }
5935 intent.putExtra(key, list);
5936 hasIntentInfo = true;
5937 }
5938 break;
5939 case "--efal": {
5940 String key = cmd.getNextArgRequired();
5941 String value = cmd.getNextArgRequired();
5942 String[] strings = value.split(",");
5943 ArrayList<Float> list = new ArrayList<>(strings.length);
5944 for (int i = 0; i < strings.length; i++) {
5945 list.add(Float.valueOf(strings[i]));
5946 }
5947 intent.putExtra(key, list);
5948 hasIntentInfo = true;
5949 }
5950 break;
5951 case "--esa": {
5952 String key = cmd.getNextArgRequired();
5953 String value = cmd.getNextArgRequired();
5954 // Split on commas unless they are preceeded by an escape.
5955 // The escape character must be escaped for the string and
5956 // again for the regex, thus four escape characters become one.
5957 String[] strings = value.split("(?<!\\\\),");
5958 intent.putExtra(key, strings);
5959 hasIntentInfo = true;
5960 }
5961 break;
5962 case "--esal": {
5963 String key = cmd.getNextArgRequired();
5964 String value = cmd.getNextArgRequired();
5965 // Split on commas unless they are preceeded by an escape.
5966 // The escape character must be escaped for the string and
5967 // again for the regex, thus four escape characters become one.
5968 String[] strings = value.split("(?<!\\\\),");
5969 ArrayList<String> list = new ArrayList<>(strings.length);
5970 for (int i = 0; i < strings.length; i++) {
5971 list.add(strings[i]);
5972 }
5973 intent.putExtra(key, list);
5974 hasIntentInfo = true;
5975 }
5976 break;
5977 case "--ez": {
5978 String key = cmd.getNextArgRequired();
5979 String value = cmd.getNextArgRequired().toLowerCase();
5980 // Boolean.valueOf() results in false for anything that is not "true", which is
5981 // error-prone in shell commands
5982 boolean arg;
5983 if ("true".equals(value) || "t".equals(value)) {
5984 arg = true;
5985 } else if ("false".equals(value) || "f".equals(value)) {
5986 arg = false;
5987 } else {
5988 try {
5989 arg = Integer.decode(value) != 0;
5990 } catch (NumberFormatException ex) {
5991 throw new IllegalArgumentException("Invalid boolean value: " + value);
5992 }
5993 }
5994
5995 intent.putExtra(key, arg);
5996 }
5997 break;
5998 case "-n": {
5999 String str = cmd.getNextArgRequired();
6000 ComponentName cn = ComponentName.unflattenFromString(str);
6001 if (cn == null)
6002 throw new IllegalArgumentException("Bad component name: " + str);
6003 intent.setComponent(cn);
6004 if (intent == baseIntent) {
6005 hasIntentInfo = true;
6006 }
6007 }
6008 break;
6009 case "-p": {
6010 String str = cmd.getNextArgRequired();
6011 intent.setPackage(str);
6012 if (intent == baseIntent) {
6013 hasIntentInfo = true;
6014 }
6015 }
6016 break;
6017 case "-f":
6018 String str = cmd.getNextArgRequired();
6019 intent.setFlags(Integer.decode(str).intValue());
6020 break;
6021 case "--grant-read-uri-permission":
6022 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6023 break;
6024 case "--grant-write-uri-permission":
6025 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6026 break;
6027 case "--grant-persistable-uri-permission":
6028 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6029 break;
6030 case "--grant-prefix-uri-permission":
6031 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6032 break;
6033 case "--exclude-stopped-packages":
6034 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6035 break;
6036 case "--include-stopped-packages":
6037 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6038 break;
6039 case "--debug-log-resolution":
6040 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6041 break;
6042 case "--activity-brought-to-front":
6043 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6044 break;
6045 case "--activity-clear-top":
6046 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6047 break;
6048 case "--activity-clear-when-task-reset":
6049 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6050 break;
6051 case "--activity-exclude-from-recents":
6052 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6053 break;
6054 case "--activity-launched-from-history":
6055 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6056 break;
6057 case "--activity-multiple-task":
6058 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6059 break;
6060 case "--activity-no-animation":
6061 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6062 break;
6063 case "--activity-no-history":
6064 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6065 break;
6066 case "--activity-no-user-action":
6067 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6068 break;
6069 case "--activity-previous-is-top":
6070 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6071 break;
6072 case "--activity-reorder-to-front":
6073 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6074 break;
6075 case "--activity-reset-task-if-needed":
6076 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6077 break;
6078 case "--activity-single-top":
6079 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6080 break;
6081 case "--activity-clear-task":
6082 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6083 break;
6084 case "--activity-task-on-home":
6085 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6086 break;
6087 case "--receiver-registered-only":
6088 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6089 break;
6090 case "--receiver-replace-pending":
6091 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6092 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006093 case "--receiver-foreground":
6094 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6095 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006096 case "--receiver-no-abort":
6097 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6098 break;
6099 case "--receiver-include-background":
6100 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6101 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006102 case "--selector":
6103 intent.setDataAndType(data, type);
6104 intent = new Intent();
6105 break;
6106 default:
6107 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6108 // Okay, caller handled this option.
6109 } else {
6110 throw new IllegalArgumentException("Unknown option: " + opt);
6111 }
6112 break;
6113 }
6114 }
6115 intent.setDataAndType(data, type);
6116
6117 final boolean hasSelector = intent != baseIntent;
6118 if (hasSelector) {
6119 // A selector was specified; fix up.
6120 baseIntent.setSelector(intent);
6121 intent = baseIntent;
6122 }
6123
6124 String arg = cmd.getNextArg();
6125 baseIntent = null;
6126 if (arg == null) {
6127 if (hasSelector) {
6128 // If a selector has been specified, and no arguments
6129 // have been supplied for the main Intent, then we can
6130 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6131 // need to have a component name specified yet, the
6132 // selector will take care of that.
6133 baseIntent = new Intent(Intent.ACTION_MAIN);
6134 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6135 }
6136 } else if (arg.indexOf(':') >= 0) {
6137 // The argument is a URI. Fully parse it, and use that result
6138 // to fill in any data not specified so far.
6139 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6140 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6141 } else if (arg.indexOf('/') >= 0) {
6142 // The argument is a component name. Build an Intent to launch
6143 // it.
6144 baseIntent = new Intent(Intent.ACTION_MAIN);
6145 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6146 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6147 } else {
6148 // Assume the argument is a package name.
6149 baseIntent = new Intent(Intent.ACTION_MAIN);
6150 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6151 baseIntent.setPackage(arg);
6152 }
6153 if (baseIntent != null) {
6154 Bundle extras = intent.getExtras();
6155 intent.replaceExtras((Bundle)null);
6156 Bundle uriExtras = baseIntent.getExtras();
6157 baseIntent.replaceExtras((Bundle)null);
6158 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6159 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6160 for (String c : cats) {
6161 baseIntent.removeCategory(c);
6162 }
6163 }
6164 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6165 if (extras == null) {
6166 extras = uriExtras;
6167 } else if (uriExtras != null) {
6168 uriExtras.putAll(extras);
6169 extras = uriExtras;
6170 }
6171 intent.replaceExtras(extras);
6172 hasIntentInfo = true;
6173 }
6174
6175 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6176 return intent;
6177 }
6178
6179 /** @hide */
6180 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6181 final String[] lines = new String[] {
6182 "<INTENT> specifications include these flags and arguments:",
6183 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6184 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6185 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6186 " [--esn <EXTRA_KEY> ...]",
6187 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6188 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6189 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6190 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6191 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6192 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6193 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6194 " (mutiple extras passed as Integer[])",
6195 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6196 " (mutiple extras passed as List<Integer>)",
6197 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6198 " (mutiple extras passed as Long[])",
6199 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6200 " (mutiple extras passed as List<Long>)",
6201 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6202 " (mutiple extras passed as Float[])",
6203 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6204 " (mutiple extras passed as List<Float>)",
6205 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6206 " (mutiple extras passed as String[]; to embed a comma into a string,",
6207 " escape it using \"\\,\")",
6208 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6209 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6210 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006211 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006212 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6213 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6214 " [--debug-log-resolution] [--exclude-stopped-packages]",
6215 " [--include-stopped-packages]",
6216 " [--activity-brought-to-front] [--activity-clear-top]",
6217 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6218 " [--activity-launched-from-history] [--activity-multiple-task]",
6219 " [--activity-no-animation] [--activity-no-history]",
6220 " [--activity-no-user-action] [--activity-previous-is-top]",
6221 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6222 " [--activity-single-top] [--activity-clear-task]",
6223 " [--activity-task-on-home]",
6224 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006225 " [--receiver-foreground] [--receiver-no-abort]",
6226 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006227 " [--selector]",
6228 " [<URI> | <PACKAGE> | <COMPONENT>]"
6229 };
6230 for (String line : lines) {
6231 pw.print(prefix);
6232 pw.println(line);
6233 }
6234 }
6235
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006236 /**
6237 * Retrieve the general action to be performed, such as
6238 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6239 * the information in the intent should be interpreted -- most importantly,
6240 * what to do with the data returned by {@link #getData}.
6241 *
6242 * @return The action of this intent or null if none is specified.
6243 *
6244 * @see #setAction
6245 */
6246 public String getAction() {
6247 return mAction;
6248 }
6249
6250 /**
6251 * Retrieve data this intent is operating on. This URI specifies the name
6252 * of the data; often it uses the content: scheme, specifying data in a
6253 * content provider. Other schemes may be handled by specific activities,
6254 * such as http: by the web browser.
6255 *
6256 * @return The URI of the data this intent is targeting or null.
6257 *
6258 * @see #getScheme
6259 * @see #setData
6260 */
6261 public Uri getData() {
6262 return mData;
6263 }
6264
6265 /**
6266 * The same as {@link #getData()}, but returns the URI as an encoded
6267 * String.
6268 */
6269 public String getDataString() {
6270 return mData != null ? mData.toString() : null;
6271 }
6272
6273 /**
6274 * Return the scheme portion of the intent's data. If the data is null or
6275 * does not include a scheme, null is returned. Otherwise, the scheme
6276 * prefix without the final ':' is returned, i.e. "http".
6277 *
6278 * <p>This is the same as calling getData().getScheme() (and checking for
6279 * null data).
6280 *
6281 * @return The scheme of this intent.
6282 *
6283 * @see #getData
6284 */
6285 public String getScheme() {
6286 return mData != null ? mData.getScheme() : null;
6287 }
6288
6289 /**
6290 * Retrieve any explicit MIME type included in the intent. This is usually
6291 * null, as the type is determined by the intent data.
6292 *
6293 * @return If a type was manually set, it is returned; else null is
6294 * returned.
6295 *
6296 * @see #resolveType(ContentResolver)
6297 * @see #setType
6298 */
6299 public String getType() {
6300 return mType;
6301 }
6302
6303 /**
6304 * Return the MIME data type of this intent. If the type field is
6305 * explicitly set, that is simply returned. Otherwise, if the data is set,
6306 * the type of that data is returned. If neither fields are set, a null is
6307 * returned.
6308 *
6309 * @return The MIME type of this intent.
6310 *
6311 * @see #getType
6312 * @see #resolveType(ContentResolver)
6313 */
6314 public String resolveType(Context context) {
6315 return resolveType(context.getContentResolver());
6316 }
6317
6318 /**
6319 * Return the MIME data type of this intent. If the type field is
6320 * explicitly set, that is simply returned. Otherwise, if the data is set,
6321 * the type of that data is returned. If neither fields are set, a null is
6322 * returned.
6323 *
6324 * @param resolver A ContentResolver that can be used to determine the MIME
6325 * type of the intent's data.
6326 *
6327 * @return The MIME type of this intent.
6328 *
6329 * @see #getType
6330 * @see #resolveType(Context)
6331 */
6332 public String resolveType(ContentResolver resolver) {
6333 if (mType != null) {
6334 return mType;
6335 }
6336 if (mData != null) {
6337 if ("content".equals(mData.getScheme())) {
6338 return resolver.getType(mData);
6339 }
6340 }
6341 return null;
6342 }
6343
6344 /**
6345 * Return the MIME data type of this intent, only if it will be needed for
6346 * intent resolution. This is not generally useful for application code;
6347 * it is used by the frameworks for communicating with back-end system
6348 * services.
6349 *
6350 * @param resolver A ContentResolver that can be used to determine the MIME
6351 * type of the intent's data.
6352 *
6353 * @return The MIME type of this intent, or null if it is unknown or not
6354 * needed.
6355 */
6356 public String resolveTypeIfNeeded(ContentResolver resolver) {
6357 if (mComponent != null) {
6358 return mType;
6359 }
6360 return resolveType(resolver);
6361 }
6362
6363 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006364 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006365 *
6366 * @param category The category to check.
6367 *
6368 * @return boolean True if the intent contains the category, else false.
6369 *
6370 * @see #getCategories
6371 * @see #addCategory
6372 */
6373 public boolean hasCategory(String category) {
6374 return mCategories != null && mCategories.contains(category);
6375 }
6376
6377 /**
6378 * Return the set of all categories in the intent. If there are no categories,
6379 * returns NULL.
6380 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006381 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006382 *
6383 * @see #hasCategory
6384 * @see #addCategory
6385 */
6386 public Set<String> getCategories() {
6387 return mCategories;
6388 }
6389
6390 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006391 * Return the specific selector associated with this Intent. If there is
6392 * none, returns null. See {@link #setSelector} for more information.
6393 *
6394 * @see #setSelector
6395 */
6396 public Intent getSelector() {
6397 return mSelector;
6398 }
6399
6400 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006401 * Return the {@link ClipData} associated with this Intent. If there is
6402 * none, returns null. See {@link #setClipData} for more information.
6403 *
John Spurlock125d1332013-11-25 11:58:37 -05006404 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006405 */
6406 public ClipData getClipData() {
6407 return mClipData;
6408 }
6409
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006410 /** @hide */
6411 public int getContentUserHint() {
6412 return mContentUserHint;
6413 }
6414
Todd Kennedyb3b431302017-03-20 16:05:48 -07006415 /** @hide */
6416 public String getLaunchToken() {
6417 return mLaunchToken;
6418 }
6419
6420 /** @hide */
6421 public void setLaunchToken(String launchToken) {
6422 mLaunchToken = launchToken;
6423 }
6424
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006425 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006426 * Sets the ClassLoader that will be used when unmarshalling
6427 * any Parcelable values from the extras of this Intent.
6428 *
6429 * @param loader a ClassLoader, or null to use the default loader
6430 * at the time of unmarshalling.
6431 */
6432 public void setExtrasClassLoader(ClassLoader loader) {
6433 if (mExtras != null) {
6434 mExtras.setClassLoader(loader);
6435 }
6436 }
6437
6438 /**
6439 * Returns true if an extra value is associated with the given name.
6440 * @param name the extra's name
6441 * @return true if the given extra is present.
6442 */
6443 public boolean hasExtra(String name) {
6444 return mExtras != null && mExtras.containsKey(name);
6445 }
6446
6447 /**
6448 * Returns true if the Intent's extras contain a parcelled file descriptor.
6449 * @return true if the Intent contains a parcelled file descriptor.
6450 */
6451 public boolean hasFileDescriptors() {
6452 return mExtras != null && mExtras.hasFileDescriptors();
6453 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006454
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006455 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006456 public void setAllowFds(boolean allowFds) {
6457 if (mExtras != null) {
6458 mExtras.setAllowFds(allowFds);
6459 }
6460 }
6461
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006462 /** {@hide} */
6463 public void setDefusable(boolean defusable) {
6464 if (mExtras != null) {
6465 mExtras.setDefusable(defusable);
6466 }
6467 }
6468
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006469 /**
6470 * Retrieve extended data from the intent.
6471 *
6472 * @param name The name of the desired item.
6473 *
6474 * @return the value of an item that previously added with putExtra()
6475 * or null if none was found.
6476 *
6477 * @deprecated
6478 * @hide
6479 */
6480 @Deprecated
6481 public Object getExtra(String name) {
6482 return getExtra(name, null);
6483 }
6484
6485 /**
6486 * Retrieve extended data from the intent.
6487 *
6488 * @param name The name of the desired item.
6489 * @param defaultValue the value to be returned if no value of the desired
6490 * type is stored with the given name.
6491 *
6492 * @return the value of an item that previously added with putExtra()
6493 * or the default value if none was found.
6494 *
6495 * @see #putExtra(String, boolean)
6496 */
6497 public boolean getBooleanExtra(String name, boolean defaultValue) {
6498 return mExtras == null ? defaultValue :
6499 mExtras.getBoolean(name, defaultValue);
6500 }
6501
6502 /**
6503 * Retrieve extended data from the intent.
6504 *
6505 * @param name The name of the desired item.
6506 * @param defaultValue the value to be returned if no value of the desired
6507 * type is stored with the given name.
6508 *
6509 * @return the value of an item that previously added with putExtra()
6510 * or the default value if none was found.
6511 *
6512 * @see #putExtra(String, byte)
6513 */
6514 public byte getByteExtra(String name, byte defaultValue) {
6515 return mExtras == null ? defaultValue :
6516 mExtras.getByte(name, defaultValue);
6517 }
6518
6519 /**
6520 * Retrieve extended data from the intent.
6521 *
6522 * @param name The name of the desired item.
6523 * @param defaultValue the value to be returned if no value of the desired
6524 * type is stored with the given name.
6525 *
6526 * @return the value of an item that previously added with putExtra()
6527 * or the default value if none was found.
6528 *
6529 * @see #putExtra(String, short)
6530 */
6531 public short getShortExtra(String name, short defaultValue) {
6532 return mExtras == null ? defaultValue :
6533 mExtras.getShort(name, defaultValue);
6534 }
6535
6536 /**
6537 * Retrieve extended data from the intent.
6538 *
6539 * @param name The name of the desired item.
6540 * @param defaultValue the value to be returned if no value of the desired
6541 * type is stored with the given name.
6542 *
6543 * @return the value of an item that previously added with putExtra()
6544 * or the default value if none was found.
6545 *
6546 * @see #putExtra(String, char)
6547 */
6548 public char getCharExtra(String name, char defaultValue) {
6549 return mExtras == null ? defaultValue :
6550 mExtras.getChar(name, defaultValue);
6551 }
6552
6553 /**
6554 * Retrieve extended data from the intent.
6555 *
6556 * @param name The name of the desired item.
6557 * @param defaultValue the value to be returned if no value of the desired
6558 * type is stored with the given name.
6559 *
6560 * @return the value of an item that previously added with putExtra()
6561 * or the default value if none was found.
6562 *
6563 * @see #putExtra(String, int)
6564 */
6565 public int getIntExtra(String name, int defaultValue) {
6566 return mExtras == null ? defaultValue :
6567 mExtras.getInt(name, defaultValue);
6568 }
6569
6570 /**
6571 * Retrieve extended data from the intent.
6572 *
6573 * @param name The name of the desired item.
6574 * @param defaultValue the value to be returned if no value of the desired
6575 * type is stored with the given name.
6576 *
6577 * @return the value of an item that previously added with putExtra()
6578 * or the default value if none was found.
6579 *
6580 * @see #putExtra(String, long)
6581 */
6582 public long getLongExtra(String name, long defaultValue) {
6583 return mExtras == null ? defaultValue :
6584 mExtras.getLong(name, defaultValue);
6585 }
6586
6587 /**
6588 * Retrieve extended data from the intent.
6589 *
6590 * @param name The name of the desired item.
6591 * @param defaultValue the value to be returned if no value of the desired
6592 * type is stored with the given name.
6593 *
6594 * @return the value of an item that previously added with putExtra(),
6595 * or the default value if no such item is present
6596 *
6597 * @see #putExtra(String, float)
6598 */
6599 public float getFloatExtra(String name, float defaultValue) {
6600 return mExtras == null ? defaultValue :
6601 mExtras.getFloat(name, defaultValue);
6602 }
6603
6604 /**
6605 * Retrieve extended data from the intent.
6606 *
6607 * @param name The name of the desired item.
6608 * @param defaultValue the value to be returned if no value of the desired
6609 * type is stored with the given name.
6610 *
6611 * @return the value of an item that previously added with putExtra()
6612 * or the default value if none was found.
6613 *
6614 * @see #putExtra(String, double)
6615 */
6616 public double getDoubleExtra(String name, double defaultValue) {
6617 return mExtras == null ? defaultValue :
6618 mExtras.getDouble(name, defaultValue);
6619 }
6620
6621 /**
6622 * Retrieve extended data from the intent.
6623 *
6624 * @param name The name of the desired item.
6625 *
6626 * @return the value of an item that previously added with putExtra()
6627 * or null if no String value was found.
6628 *
6629 * @see #putExtra(String, String)
6630 */
6631 public String getStringExtra(String name) {
6632 return mExtras == null ? null : mExtras.getString(name);
6633 }
6634
6635 /**
6636 * Retrieve extended data from the intent.
6637 *
6638 * @param name The name of the desired item.
6639 *
6640 * @return the value of an item that previously added with putExtra()
6641 * or null if no CharSequence value was found.
6642 *
6643 * @see #putExtra(String, CharSequence)
6644 */
6645 public CharSequence getCharSequenceExtra(String name) {
6646 return mExtras == null ? null : mExtras.getCharSequence(name);
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 Parcelable value was found.
6656 *
6657 * @see #putExtra(String, Parcelable)
6658 */
6659 public <T extends Parcelable> T getParcelableExtra(String name) {
6660 return mExtras == null ? null : mExtras.<T>getParcelable(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 Parcelable[] value was found.
6670 *
6671 * @see #putExtra(String, Parcelable[])
6672 */
6673 public Parcelable[] getParcelableArrayExtra(String name) {
6674 return mExtras == null ? null : mExtras.getParcelableArray(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 ArrayList<Parcelable> value was found.
6684 *
6685 * @see #putParcelableArrayListExtra(String, ArrayList)
6686 */
6687 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6688 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(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 Serializable value was found.
6698 *
6699 * @see #putExtra(String, Serializable)
6700 */
6701 public Serializable getSerializableExtra(String name) {
6702 return mExtras == null ? null : mExtras.getSerializable(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<Integer> value was found.
6712 *
6713 * @see #putIntegerArrayListExtra(String, ArrayList)
6714 */
6715 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6716 return mExtras == null ? null : mExtras.getIntegerArrayList(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 ArrayList<String> value was found.
6726 *
6727 * @see #putStringArrayListExtra(String, ArrayList)
6728 */
6729 public ArrayList<String> getStringArrayListExtra(String name) {
6730 return mExtras == null ? null : mExtras.getStringArrayList(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()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006739 * or null if no ArrayList<CharSequence> value was found.
6740 *
6741 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6742 */
6743 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6744 return mExtras == null ? null : mExtras.getCharSequenceArrayList(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()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006753 * or null if no boolean array value was found.
6754 *
6755 * @see #putExtra(String, boolean[])
6756 */
6757 public boolean[] getBooleanArrayExtra(String name) {
6758 return mExtras == null ? null : mExtras.getBooleanArray(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()
6767 * or null if no byte array value was found.
6768 *
6769 * @see #putExtra(String, byte[])
6770 */
6771 public byte[] getByteArrayExtra(String name) {
6772 return mExtras == null ? null : mExtras.getByteArray(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()
6781 * or null if no short array value was found.
6782 *
6783 * @see #putExtra(String, short[])
6784 */
6785 public short[] getShortArrayExtra(String name) {
6786 return mExtras == null ? null : mExtras.getShortArray(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 char array value was found.
6796 *
6797 * @see #putExtra(String, char[])
6798 */
6799 public char[] getCharArrayExtra(String name) {
6800 return mExtras == null ? null : mExtras.getCharArray(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 int array value was found.
6810 *
6811 * @see #putExtra(String, int[])
6812 */
6813 public int[] getIntArrayExtra(String name) {
6814 return mExtras == null ? null : mExtras.getIntArray(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 long array value was found.
6824 *
6825 * @see #putExtra(String, long[])
6826 */
6827 public long[] getLongArrayExtra(String name) {
6828 return mExtras == null ? null : mExtras.getLongArray(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 float array value was found.
6838 *
6839 * @see #putExtra(String, float[])
6840 */
6841 public float[] getFloatArrayExtra(String name) {
6842 return mExtras == null ? null : mExtras.getFloatArray(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 double array value was found.
6852 *
6853 * @see #putExtra(String, double[])
6854 */
6855 public double[] getDoubleArrayExtra(String name) {
6856 return mExtras == null ? null : mExtras.getDoubleArray(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 String array value was found.
6866 *
6867 * @see #putExtra(String, String[])
6868 */
6869 public String[] getStringArrayExtra(String name) {
6870 return mExtras == null ? null : mExtras.getStringArray(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()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006879 * or null if no CharSequence array value was found.
6880 *
6881 * @see #putExtra(String, CharSequence[])
6882 */
6883 public CharSequence[] getCharSequenceArrayExtra(String name) {
6884 return mExtras == null ? null : mExtras.getCharSequenceArray(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()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006893 * or null if no Bundle value was found.
6894 *
6895 * @see #putExtra(String, Bundle)
6896 */
6897 public Bundle getBundleExtra(String name) {
6898 return mExtras == null ? null : mExtras.getBundle(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()
6907 * or null if no IBinder value was found.
6908 *
6909 * @see #putExtra(String, IBinder)
6910 *
6911 * @deprecated
6912 * @hide
6913 */
6914 @Deprecated
6915 public IBinder getIBinderExtra(String name) {
6916 return mExtras == null ? null : mExtras.getIBinder(name);
6917 }
6918
6919 /**
6920 * Retrieve extended data from the intent.
6921 *
6922 * @param name The name of the desired item.
6923 * @param defaultValue The default value to return in case no item is
6924 * associated with the key 'name'
6925 *
6926 * @return the value of an item that previously added with putExtra()
6927 * or defaultValue if none was found.
6928 *
6929 * @see #putExtra
6930 *
6931 * @deprecated
6932 * @hide
6933 */
6934 @Deprecated
6935 public Object getExtra(String name, Object defaultValue) {
6936 Object result = defaultValue;
6937 if (mExtras != null) {
6938 Object result2 = mExtras.get(name);
6939 if (result2 != null) {
6940 result = result2;
6941 }
6942 }
6943
6944 return result;
6945 }
6946
6947 /**
6948 * Retrieves a map of extended data from the intent.
6949 *
6950 * @return the map of all extras previously added with putExtra(),
6951 * or null if none have been added.
6952 */
6953 public Bundle getExtras() {
6954 return (mExtras != null)
6955 ? new Bundle(mExtras)
6956 : null;
6957 }
6958
6959 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006960 * Filter extras to only basic types.
6961 * @hide
6962 */
6963 public void removeUnsafeExtras() {
6964 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006965 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006966 }
6967 }
6968
6969 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006970 * Retrieve any special flags associated with this intent. You will
6971 * normally just set them with {@link #setFlags} and let the system
6972 * take the appropriate action with them.
6973 *
6974 * @return int The currently set flags.
6975 *
6976 * @see #setFlags
6977 */
6978 public int getFlags() {
6979 return mFlags;
6980 }
6981
Dianne Hackborne7f97212011-02-24 14:40:20 -08006982 /** @hide */
6983 public boolean isExcludingStopped() {
6984 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6985 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6986 }
6987
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006988 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006989 * Retrieve the application package name this Intent is limited to. When
6990 * resolving an Intent, if non-null this limits the resolution to only
6991 * components in the given application package.
6992 *
6993 * @return The name of the application package for the Intent.
6994 *
6995 * @see #resolveActivity
6996 * @see #setPackage
6997 */
6998 public String getPackage() {
6999 return mPackage;
7000 }
7001
7002 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007003 * Retrieve the concrete component associated with the intent. When receiving
7004 * an intent, this is the component that was found to best handle it (that is,
7005 * yourself) and will always be non-null; in all other cases it will be
7006 * null unless explicitly set.
7007 *
7008 * @return The name of the application component to handle the intent.
7009 *
7010 * @see #resolveActivity
7011 * @see #setComponent
7012 */
7013 public ComponentName getComponent() {
7014 return mComponent;
7015 }
7016
7017 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007018 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7019 * used as a hint to the receiver for animations and the like. Null means that there
7020 * is no source bounds.
7021 */
7022 public Rect getSourceBounds() {
7023 return mSourceBounds;
7024 }
7025
7026 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007027 * Return the Activity component that should be used to handle this intent.
7028 * The appropriate component is determined based on the information in the
7029 * intent, evaluated as follows:
7030 *
7031 * <p>If {@link #getComponent} returns an explicit class, that is returned
7032 * without any further consideration.
7033 *
7034 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7035 * category to be considered.
7036 *
7037 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7038 * action.
7039 *
7040 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7041 * this type.
7042 *
7043 * <p>If {@link #addCategory} has added any categories, the activity must
7044 * handle ALL of the categories specified.
7045 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007046 * <p>If {@link #getPackage} is non-NULL, only activity components in
7047 * that application package will be considered.
7048 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007049 * <p>If there are no activities that satisfy all of these conditions, a
7050 * null string is returned.
7051 *
7052 * <p>If multiple activities are found to satisfy the intent, the one with
7053 * the highest priority will be used. If there are multiple activities
7054 * with the same priority, the system will either pick the best activity
7055 * based on user preference, or resolve to a system class that will allow
7056 * the user to pick an activity and forward from there.
7057 *
7058 * <p>This method is implemented simply by calling
7059 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7060 * true.</p>
7061 * <p> This API is called for you as part of starting an activity from an
7062 * intent. You do not normally need to call it yourself.</p>
7063 *
7064 * @param pm The package manager with which to resolve the Intent.
7065 *
7066 * @return Name of the component implementing an activity that can
7067 * display the intent.
7068 *
7069 * @see #setComponent
7070 * @see #getComponent
7071 * @see #resolveActivityInfo
7072 */
7073 public ComponentName resolveActivity(PackageManager pm) {
7074 if (mComponent != null) {
7075 return mComponent;
7076 }
7077
7078 ResolveInfo info = pm.resolveActivity(
7079 this, PackageManager.MATCH_DEFAULT_ONLY);
7080 if (info != null) {
7081 return new ComponentName(
7082 info.activityInfo.applicationInfo.packageName,
7083 info.activityInfo.name);
7084 }
7085
7086 return null;
7087 }
7088
7089 /**
7090 * Resolve the Intent into an {@link ActivityInfo}
7091 * describing the activity that should execute the intent. Resolution
7092 * follows the same rules as described for {@link #resolveActivity}, but
7093 * you get back the completely information about the resolved activity
7094 * instead of just its class name.
7095 *
7096 * @param pm The package manager with which to resolve the Intent.
7097 * @param flags Addition information to retrieve as per
7098 * {@link PackageManager#getActivityInfo(ComponentName, int)
7099 * PackageManager.getActivityInfo()}.
7100 *
7101 * @return PackageManager.ActivityInfo
7102 *
7103 * @see #resolveActivity
7104 */
7105 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7106 ActivityInfo ai = null;
7107 if (mComponent != null) {
7108 try {
7109 ai = pm.getActivityInfo(mComponent, flags);
7110 } catch (PackageManager.NameNotFoundException e) {
7111 // ignore
7112 }
7113 } else {
7114 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007115 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007116 if (info != null) {
7117 ai = info.activityInfo;
7118 }
7119 }
7120
7121 return ai;
7122 }
7123
7124 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007125 * Special function for use by the system to resolve service
7126 * intents to system apps. Throws an exception if there are
7127 * multiple potential matches to the Intent. Returns null if
7128 * there are no matches.
7129 * @hide
7130 */
7131 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7132 if (mComponent != null) {
7133 return mComponent;
7134 }
7135
7136 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7137 if (results == null) {
7138 return null;
7139 }
7140 ComponentName comp = null;
7141 for (int i=0; i<results.size(); i++) {
7142 ResolveInfo ri = results.get(i);
7143 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7144 continue;
7145 }
7146 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7147 ri.serviceInfo.name);
7148 if (comp != null) {
7149 throw new IllegalStateException("Multiple system services handle " + this
7150 + ": " + comp + ", " + foundComp);
7151 }
7152 comp = foundComp;
7153 }
7154 return comp;
7155 }
7156
7157 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007158 * Set the general action to be performed.
7159 *
7160 * @param action An action name, such as ACTION_VIEW. Application-specific
7161 * actions should be prefixed with the vendor's package name.
7162 *
7163 * @return Returns the same Intent object, for chaining multiple calls
7164 * into a single statement.
7165 *
7166 * @see #getAction
7167 */
7168 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007169 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007170 return this;
7171 }
7172
7173 /**
7174 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007175 * clears any type that was previously set by {@link #setType} or
7176 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007177 *
Nick Pellyccae4122012-01-09 14:12:58 -08007178 * <p><em>Note: scheme matching in the Android framework is
7179 * case-sensitive, unlike the formal RFC. As a result,
7180 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007181 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007182 * {@link #setDataAndNormalize}
7183 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007184 *
Nick Pellyccae4122012-01-09 14:12:58 -08007185 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007186 *
7187 * @return Returns the same Intent object, for chaining multiple calls
7188 * into a single statement.
7189 *
7190 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007191 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007192 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007193 */
7194 public Intent setData(Uri data) {
7195 mData = data;
7196 mType = null;
7197 return this;
7198 }
7199
7200 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007201 * Normalize and set the data this intent is operating on.
7202 *
7203 * <p>This method automatically clears any type that was
7204 * previously set (for example, by {@link #setType}).
7205 *
7206 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007207 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007208 * so really this is just a convenience method for
7209 * <pre>
7210 * setData(data.normalize())
7211 * </pre>
7212 *
7213 * @param data The Uri of the data this intent is now targeting.
7214 *
7215 * @return Returns the same Intent object, for chaining multiple calls
7216 * into a single statement.
7217 *
7218 * @see #getData
7219 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007220 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007221 */
7222 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007223 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007224 }
7225
7226 /**
7227 * Set an explicit MIME data type.
7228 *
7229 * <p>This is used to create intents that only specify a type and not data,
7230 * for example to indicate the type of data to return.
7231 *
7232 * <p>This method automatically clears any data that was
7233 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007234 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007235 * <p><em>Note: MIME type matching in the Android framework is
7236 * case-sensitive, unlike formal RFC MIME types. As a result,
7237 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007238 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7239 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007240 *
7241 * @param type The MIME type of the data being handled by this intent.
7242 *
7243 * @return Returns the same Intent object, for chaining multiple calls
7244 * into a single statement.
7245 *
7246 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007247 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007248 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007249 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007250 */
7251 public Intent setType(String type) {
7252 mData = null;
7253 mType = type;
7254 return this;
7255 }
7256
7257 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007258 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007259 *
Nick Pellyccae4122012-01-09 14:12:58 -08007260 * <p>This is used to create intents that only specify a type and not data,
7261 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007262 *
Nick Pellyccae4122012-01-09 14:12:58 -08007263 * <p>This method automatically clears any data that was
7264 * previously set (for example by {@link #setData}).
7265 *
7266 * <p>The MIME type is normalized using
7267 * {@link #normalizeMimeType} before it is set,
7268 * so really this is just a convenience method for
7269 * <pre>
7270 * setType(Intent.normalizeMimeType(type))
7271 * </pre>
7272 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007273 * @param type The MIME type of the data being handled by this intent.
7274 *
7275 * @return Returns the same Intent object, for chaining multiple calls
7276 * into a single statement.
7277 *
Nick Pellyccae4122012-01-09 14:12:58 -08007278 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007279 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007280 * @see #normalizeMimeType
7281 */
7282 public Intent setTypeAndNormalize(String type) {
7283 return setType(normalizeMimeType(type));
7284 }
7285
7286 /**
7287 * (Usually optional) Set the data for the intent along with an explicit
7288 * MIME data type. This method should very rarely be used -- it allows you
7289 * to override the MIME type that would ordinarily be inferred from the
7290 * data with your own type given here.
7291 *
7292 * <p><em>Note: MIME type and Uri scheme matching in the
7293 * Android framework is case-sensitive, unlike the formal RFC definitions.
7294 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007295 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007296 * {@link #setDataAndTypeAndNormalize}
7297 * to ensure that they are converted to lower case.</em>
7298 *
7299 * @param data The Uri of the data this intent is now targeting.
7300 * @param type The MIME type of the data being handled by this intent.
7301 *
7302 * @return Returns the same Intent object, for chaining multiple calls
7303 * into a single statement.
7304 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007305 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007306 * @see #setData
7307 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007308 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007309 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007310 */
7311 public Intent setDataAndType(Uri data, String type) {
7312 mData = data;
7313 mType = type;
7314 return this;
7315 }
7316
7317 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007318 * (Usually optional) Normalize and set both the data Uri and an explicit
7319 * MIME data type. This method should very rarely be used -- it allows you
7320 * to override the MIME type that would ordinarily be inferred from the
7321 * data with your own type given here.
7322 *
7323 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007324 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007325 * before they are set, so really this is just a convenience method for
7326 * <pre>
7327 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7328 * </pre>
7329 *
7330 * @param data The Uri of the data this intent is now targeting.
7331 * @param type The MIME type of the data being handled by this intent.
7332 *
7333 * @return Returns the same Intent object, for chaining multiple calls
7334 * into a single statement.
7335 *
7336 * @see #setType
7337 * @see #setData
7338 * @see #setDataAndType
7339 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007340 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007341 */
7342 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007343 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007344 }
7345
7346 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007347 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007348 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007349 * activities that provide <em>all</em> of the requested categories will be
7350 * used.
7351 *
7352 * @param category The desired category. This can be either one of the
7353 * predefined Intent categories, or a custom category in your own
7354 * namespace.
7355 *
7356 * @return Returns the same Intent object, for chaining multiple calls
7357 * into a single statement.
7358 *
7359 * @see #hasCategory
7360 * @see #removeCategory
7361 */
7362 public Intent addCategory(String category) {
7363 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007364 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007365 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007366 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007367 return this;
7368 }
7369
7370 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007371 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007372 *
7373 * @param category The category to remove.
7374 *
7375 * @see #addCategory
7376 */
7377 public void removeCategory(String category) {
7378 if (mCategories != null) {
7379 mCategories.remove(category);
7380 if (mCategories.size() == 0) {
7381 mCategories = null;
7382 }
7383 }
7384 }
7385
7386 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007387 * Set a selector for this Intent. This is a modification to the kinds of
7388 * things the Intent will match. If the selector is set, it will be used
7389 * when trying to find entities that can handle the Intent, instead of the
7390 * main contents of the Intent. This allows you build an Intent containing
7391 * a generic protocol while targeting it more specifically.
7392 *
7393 * <p>An example of where this may be used is with things like
7394 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7395 * Intent that will launch the Browser application. However, the correct
7396 * main entry point of an application is actually {@link #ACTION_MAIN}
7397 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7398 * used to specify the actual Activity to launch. If you launch the browser
7399 * with something different, undesired behavior may happen if the user has
7400 * previously or later launches it the normal way, since they do not match.
7401 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7402 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7403 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7404 *
7405 * <p>Setting a selector does not impact the behavior of
7406 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7407 * desired behavior of a selector -- it does not impact the base meaning
7408 * of the Intent, just what kinds of things will be matched against it
7409 * when determining who can handle it.</p>
7410 *
7411 * <p>You can not use both a selector and {@link #setPackage(String)} on
7412 * the same base Intent.</p>
7413 *
7414 * @param selector The desired selector Intent; set to null to not use
7415 * a special selector.
7416 */
7417 public void setSelector(Intent selector) {
7418 if (selector == this) {
7419 throw new IllegalArgumentException(
7420 "Intent being set as a selector of itself");
7421 }
7422 if (selector != null && mPackage != null) {
7423 throw new IllegalArgumentException(
7424 "Can't set selector when package name is already set");
7425 }
7426 mSelector = selector;
7427 }
7428
7429 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007430 * Set a {@link ClipData} associated with this Intent. This replaces any
7431 * previously set ClipData.
7432 *
7433 * <p>The ClipData in an intent is not used for Intent matching or other
7434 * such operations. Semantically it is like extras, used to transmit
7435 * additional data with the Intent. The main feature of using this over
7436 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7437 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7438 * items included in the clip data. This is useful, in particular, if
7439 * you want to transmit an Intent containing multiple <code>content:</code>
7440 * URIs for which the recipient may not have global permission to access the
7441 * content provider.
7442 *
7443 * <p>If the ClipData contains items that are themselves Intents, any
7444 * grant flags in those Intents will be ignored. Only the top-level flags
7445 * of the main Intent are respected, and will be applied to all Uri or
7446 * Intent items in the clip (or sub-items of the clip).
7447 *
7448 * <p>The MIME type, label, and icon in the ClipData object are not
7449 * directly used by Intent. Applications should generally rely on the
7450 * MIME type of the Intent itself, not what it may find in the ClipData.
7451 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007452 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007453 *
7454 * @param clip The new clip to set. May be null to clear the current clip.
7455 */
7456 public void setClipData(ClipData clip) {
7457 mClipData = clip;
7458 }
7459
7460 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007461 * This is NOT a secure mechanism to identify the user who sent the intent.
7462 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7463 * who sent the intent.
7464 * @hide
7465 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007466 public void prepareToLeaveUser(int userId) {
7467 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7468 // We want mContentUserHint to refer to the original user, so don't do anything.
7469 if (mContentUserHint == UserHandle.USER_CURRENT) {
7470 mContentUserHint = userId;
7471 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007472 }
7473
7474 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007475 * Add extended data to the intent. The name must include a package
7476 * prefix, for example the app com.android.contacts would use names
7477 * like "com.android.contacts.ShowAll".
7478 *
7479 * @param name The name of the extra data, with package prefix.
7480 * @param value The boolean data value.
7481 *
7482 * @return Returns the same Intent object, for chaining multiple calls
7483 * into a single statement.
7484 *
7485 * @see #putExtras
7486 * @see #removeExtra
7487 * @see #getBooleanExtra(String, boolean)
7488 */
7489 public Intent putExtra(String name, boolean value) {
7490 if (mExtras == null) {
7491 mExtras = new Bundle();
7492 }
7493 mExtras.putBoolean(name, value);
7494 return this;
7495 }
7496
7497 /**
7498 * Add extended data to the intent. The name must include a package
7499 * prefix, for example the app com.android.contacts would use names
7500 * like "com.android.contacts.ShowAll".
7501 *
7502 * @param name The name of the extra data, with package prefix.
7503 * @param value The byte data value.
7504 *
7505 * @return Returns the same Intent object, for chaining multiple calls
7506 * into a single statement.
7507 *
7508 * @see #putExtras
7509 * @see #removeExtra
7510 * @see #getByteExtra(String, byte)
7511 */
7512 public Intent putExtra(String name, byte value) {
7513 if (mExtras == null) {
7514 mExtras = new Bundle();
7515 }
7516 mExtras.putByte(name, value);
7517 return this;
7518 }
7519
7520 /**
7521 * Add extended data to the intent. The name must include a package
7522 * prefix, for example the app com.android.contacts would use names
7523 * like "com.android.contacts.ShowAll".
7524 *
7525 * @param name The name of the extra data, with package prefix.
7526 * @param value The char data value.
7527 *
7528 * @return Returns the same Intent object, for chaining multiple calls
7529 * into a single statement.
7530 *
7531 * @see #putExtras
7532 * @see #removeExtra
7533 * @see #getCharExtra(String, char)
7534 */
7535 public Intent putExtra(String name, char value) {
7536 if (mExtras == null) {
7537 mExtras = new Bundle();
7538 }
7539 mExtras.putChar(name, value);
7540 return this;
7541 }
7542
7543 /**
7544 * Add extended data to the intent. The name must include a package
7545 * prefix, for example the app com.android.contacts would use names
7546 * like "com.android.contacts.ShowAll".
7547 *
7548 * @param name The name of the extra data, with package prefix.
7549 * @param value The short data value.
7550 *
7551 * @return Returns the same Intent object, for chaining multiple calls
7552 * into a single statement.
7553 *
7554 * @see #putExtras
7555 * @see #removeExtra
7556 * @see #getShortExtra(String, short)
7557 */
7558 public Intent putExtra(String name, short value) {
7559 if (mExtras == null) {
7560 mExtras = new Bundle();
7561 }
7562 mExtras.putShort(name, value);
7563 return this;
7564 }
7565
7566 /**
7567 * Add extended data to the intent. The name must include a package
7568 * prefix, for example the app com.android.contacts would use names
7569 * like "com.android.contacts.ShowAll".
7570 *
7571 * @param name The name of the extra data, with package prefix.
7572 * @param value The integer data value.
7573 *
7574 * @return Returns the same Intent object, for chaining multiple calls
7575 * into a single statement.
7576 *
7577 * @see #putExtras
7578 * @see #removeExtra
7579 * @see #getIntExtra(String, int)
7580 */
7581 public Intent putExtra(String name, int value) {
7582 if (mExtras == null) {
7583 mExtras = new Bundle();
7584 }
7585 mExtras.putInt(name, value);
7586 return this;
7587 }
7588
7589 /**
7590 * Add extended data to the intent. The name must include a package
7591 * prefix, for example the app com.android.contacts would use names
7592 * like "com.android.contacts.ShowAll".
7593 *
7594 * @param name The name of the extra data, with package prefix.
7595 * @param value The long data value.
7596 *
7597 * @return Returns the same Intent object, for chaining multiple calls
7598 * into a single statement.
7599 *
7600 * @see #putExtras
7601 * @see #removeExtra
7602 * @see #getLongExtra(String, long)
7603 */
7604 public Intent putExtra(String name, long value) {
7605 if (mExtras == null) {
7606 mExtras = new Bundle();
7607 }
7608 mExtras.putLong(name, value);
7609 return this;
7610 }
7611
7612 /**
7613 * Add extended data to the intent. The name must include a package
7614 * prefix, for example the app com.android.contacts would use names
7615 * like "com.android.contacts.ShowAll".
7616 *
7617 * @param name The name of the extra data, with package prefix.
7618 * @param value The float data value.
7619 *
7620 * @return Returns the same Intent object, for chaining multiple calls
7621 * into a single statement.
7622 *
7623 * @see #putExtras
7624 * @see #removeExtra
7625 * @see #getFloatExtra(String, float)
7626 */
7627 public Intent putExtra(String name, float value) {
7628 if (mExtras == null) {
7629 mExtras = new Bundle();
7630 }
7631 mExtras.putFloat(name, value);
7632 return this;
7633 }
7634
7635 /**
7636 * Add extended data to the intent. The name must include a package
7637 * prefix, for example the app com.android.contacts would use names
7638 * like "com.android.contacts.ShowAll".
7639 *
7640 * @param name The name of the extra data, with package prefix.
7641 * @param value The double data value.
7642 *
7643 * @return Returns the same Intent object, for chaining multiple calls
7644 * into a single statement.
7645 *
7646 * @see #putExtras
7647 * @see #removeExtra
7648 * @see #getDoubleExtra(String, double)
7649 */
7650 public Intent putExtra(String name, double value) {
7651 if (mExtras == null) {
7652 mExtras = new Bundle();
7653 }
7654 mExtras.putDouble(name, value);
7655 return this;
7656 }
7657
7658 /**
7659 * Add extended data to the intent. The name must include a package
7660 * prefix, for example the app com.android.contacts would use names
7661 * like "com.android.contacts.ShowAll".
7662 *
7663 * @param name The name of the extra data, with package prefix.
7664 * @param value The String data value.
7665 *
7666 * @return Returns the same Intent object, for chaining multiple calls
7667 * into a single statement.
7668 *
7669 * @see #putExtras
7670 * @see #removeExtra
7671 * @see #getStringExtra(String)
7672 */
7673 public Intent putExtra(String name, String value) {
7674 if (mExtras == null) {
7675 mExtras = new Bundle();
7676 }
7677 mExtras.putString(name, value);
7678 return this;
7679 }
7680
7681 /**
7682 * Add extended data to the intent. The name must include a package
7683 * prefix, for example the app com.android.contacts would use names
7684 * like "com.android.contacts.ShowAll".
7685 *
7686 * @param name The name of the extra data, with package prefix.
7687 * @param value The CharSequence data value.
7688 *
7689 * @return Returns the same Intent object, for chaining multiple calls
7690 * into a single statement.
7691 *
7692 * @see #putExtras
7693 * @see #removeExtra
7694 * @see #getCharSequenceExtra(String)
7695 */
7696 public Intent putExtra(String name, CharSequence value) {
7697 if (mExtras == null) {
7698 mExtras = new Bundle();
7699 }
7700 mExtras.putCharSequence(name, value);
7701 return this;
7702 }
7703
7704 /**
7705 * Add extended data to the intent. The name must include a package
7706 * prefix, for example the app com.android.contacts would use names
7707 * like "com.android.contacts.ShowAll".
7708 *
7709 * @param name The name of the extra data, with package prefix.
7710 * @param value The Parcelable data value.
7711 *
7712 * @return Returns the same Intent object, for chaining multiple calls
7713 * into a single statement.
7714 *
7715 * @see #putExtras
7716 * @see #removeExtra
7717 * @see #getParcelableExtra(String)
7718 */
7719 public Intent putExtra(String name, Parcelable value) {
7720 if (mExtras == null) {
7721 mExtras = new Bundle();
7722 }
7723 mExtras.putParcelable(name, value);
7724 return this;
7725 }
7726
7727 /**
7728 * Add extended data to the intent. The name must include a package
7729 * prefix, for example the app com.android.contacts would use names
7730 * like "com.android.contacts.ShowAll".
7731 *
7732 * @param name The name of the extra data, with package prefix.
7733 * @param value The Parcelable[] data value.
7734 *
7735 * @return Returns the same Intent object, for chaining multiple calls
7736 * into a single statement.
7737 *
7738 * @see #putExtras
7739 * @see #removeExtra
7740 * @see #getParcelableArrayExtra(String)
7741 */
7742 public Intent putExtra(String name, Parcelable[] value) {
7743 if (mExtras == null) {
7744 mExtras = new Bundle();
7745 }
7746 mExtras.putParcelableArray(name, value);
7747 return this;
7748 }
7749
7750 /**
7751 * Add extended data to the intent. The name must include a package
7752 * prefix, for example the app com.android.contacts would use names
7753 * like "com.android.contacts.ShowAll".
7754 *
7755 * @param name The name of the extra data, with package prefix.
7756 * @param value The ArrayList<Parcelable> data value.
7757 *
7758 * @return Returns the same Intent object, for chaining multiple calls
7759 * into a single statement.
7760 *
7761 * @see #putExtras
7762 * @see #removeExtra
7763 * @see #getParcelableArrayListExtra(String)
7764 */
7765 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7766 if (mExtras == null) {
7767 mExtras = new Bundle();
7768 }
7769 mExtras.putParcelableArrayList(name, value);
7770 return this;
7771 }
7772
7773 /**
7774 * Add extended data to the intent. The name must include a package
7775 * prefix, for example the app com.android.contacts would use names
7776 * like "com.android.contacts.ShowAll".
7777 *
7778 * @param name The name of the extra data, with package prefix.
7779 * @param value The ArrayList<Integer> data value.
7780 *
7781 * @return Returns the same Intent object, for chaining multiple calls
7782 * into a single statement.
7783 *
7784 * @see #putExtras
7785 * @see #removeExtra
7786 * @see #getIntegerArrayListExtra(String)
7787 */
7788 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7789 if (mExtras == null) {
7790 mExtras = new Bundle();
7791 }
7792 mExtras.putIntegerArrayList(name, value);
7793 return this;
7794 }
7795
7796 /**
7797 * Add extended data to the intent. The name must include a package
7798 * prefix, for example the app com.android.contacts would use names
7799 * like "com.android.contacts.ShowAll".
7800 *
7801 * @param name The name of the extra data, with package prefix.
7802 * @param value The ArrayList<String> data value.
7803 *
7804 * @return Returns the same Intent object, for chaining multiple calls
7805 * into a single statement.
7806 *
7807 * @see #putExtras
7808 * @see #removeExtra
7809 * @see #getStringArrayListExtra(String)
7810 */
7811 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7812 if (mExtras == null) {
7813 mExtras = new Bundle();
7814 }
7815 mExtras.putStringArrayList(name, value);
7816 return this;
7817 }
7818
7819 /**
7820 * Add extended data to the intent. The name must include a package
7821 * prefix, for example the app com.android.contacts would use names
7822 * like "com.android.contacts.ShowAll".
7823 *
7824 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007825 * @param value The ArrayList<CharSequence> data value.
7826 *
7827 * @return Returns the same Intent object, for chaining multiple calls
7828 * into a single statement.
7829 *
7830 * @see #putExtras
7831 * @see #removeExtra
7832 * @see #getCharSequenceArrayListExtra(String)
7833 */
7834 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7835 if (mExtras == null) {
7836 mExtras = new Bundle();
7837 }
7838 mExtras.putCharSequenceArrayList(name, value);
7839 return this;
7840 }
7841
7842 /**
7843 * Add extended data to the intent. The name must include a package
7844 * prefix, for example the app com.android.contacts would use names
7845 * like "com.android.contacts.ShowAll".
7846 *
7847 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007848 * @param value The Serializable data value.
7849 *
7850 * @return Returns the same Intent object, for chaining multiple calls
7851 * into a single statement.
7852 *
7853 * @see #putExtras
7854 * @see #removeExtra
7855 * @see #getSerializableExtra(String)
7856 */
7857 public Intent putExtra(String name, Serializable value) {
7858 if (mExtras == null) {
7859 mExtras = new Bundle();
7860 }
7861 mExtras.putSerializable(name, value);
7862 return this;
7863 }
7864
7865 /**
7866 * Add extended data to the intent. The name must include a package
7867 * prefix, for example the app com.android.contacts would use names
7868 * like "com.android.contacts.ShowAll".
7869 *
7870 * @param name The name of the extra data, with package prefix.
7871 * @param value The boolean array data value.
7872 *
7873 * @return Returns the same Intent object, for chaining multiple calls
7874 * into a single statement.
7875 *
7876 * @see #putExtras
7877 * @see #removeExtra
7878 * @see #getBooleanArrayExtra(String)
7879 */
7880 public Intent putExtra(String name, boolean[] value) {
7881 if (mExtras == null) {
7882 mExtras = new Bundle();
7883 }
7884 mExtras.putBooleanArray(name, value);
7885 return this;
7886 }
7887
7888 /**
7889 * Add extended data to the intent. The name must include a package
7890 * prefix, for example the app com.android.contacts would use names
7891 * like "com.android.contacts.ShowAll".
7892 *
7893 * @param name The name of the extra data, with package prefix.
7894 * @param value The byte array data value.
7895 *
7896 * @return Returns the same Intent object, for chaining multiple calls
7897 * into a single statement.
7898 *
7899 * @see #putExtras
7900 * @see #removeExtra
7901 * @see #getByteArrayExtra(String)
7902 */
7903 public Intent putExtra(String name, byte[] value) {
7904 if (mExtras == null) {
7905 mExtras = new Bundle();
7906 }
7907 mExtras.putByteArray(name, value);
7908 return this;
7909 }
7910
7911 /**
7912 * Add extended data to the intent. The name must include a package
7913 * prefix, for example the app com.android.contacts would use names
7914 * like "com.android.contacts.ShowAll".
7915 *
7916 * @param name The name of the extra data, with package prefix.
7917 * @param value The short array data value.
7918 *
7919 * @return Returns the same Intent object, for chaining multiple calls
7920 * into a single statement.
7921 *
7922 * @see #putExtras
7923 * @see #removeExtra
7924 * @see #getShortArrayExtra(String)
7925 */
7926 public Intent putExtra(String name, short[] value) {
7927 if (mExtras == null) {
7928 mExtras = new Bundle();
7929 }
7930 mExtras.putShortArray(name, value);
7931 return this;
7932 }
7933
7934 /**
7935 * Add extended data to the intent. The name must include a package
7936 * prefix, for example the app com.android.contacts would use names
7937 * like "com.android.contacts.ShowAll".
7938 *
7939 * @param name The name of the extra data, with package prefix.
7940 * @param value The char array data value.
7941 *
7942 * @return Returns the same Intent object, for chaining multiple calls
7943 * into a single statement.
7944 *
7945 * @see #putExtras
7946 * @see #removeExtra
7947 * @see #getCharArrayExtra(String)
7948 */
7949 public Intent putExtra(String name, char[] value) {
7950 if (mExtras == null) {
7951 mExtras = new Bundle();
7952 }
7953 mExtras.putCharArray(name, value);
7954 return this;
7955 }
7956
7957 /**
7958 * Add extended data to the intent. The name must include a package
7959 * prefix, for example the app com.android.contacts would use names
7960 * like "com.android.contacts.ShowAll".
7961 *
7962 * @param name The name of the extra data, with package prefix.
7963 * @param value The int array data value.
7964 *
7965 * @return Returns the same Intent object, for chaining multiple calls
7966 * into a single statement.
7967 *
7968 * @see #putExtras
7969 * @see #removeExtra
7970 * @see #getIntArrayExtra(String)
7971 */
7972 public Intent putExtra(String name, int[] value) {
7973 if (mExtras == null) {
7974 mExtras = new Bundle();
7975 }
7976 mExtras.putIntArray(name, value);
7977 return this;
7978 }
7979
7980 /**
7981 * Add extended data to the intent. The name must include a package
7982 * prefix, for example the app com.android.contacts would use names
7983 * like "com.android.contacts.ShowAll".
7984 *
7985 * @param name The name of the extra data, with package prefix.
7986 * @param value The byte array data value.
7987 *
7988 * @return Returns the same Intent object, for chaining multiple calls
7989 * into a single statement.
7990 *
7991 * @see #putExtras
7992 * @see #removeExtra
7993 * @see #getLongArrayExtra(String)
7994 */
7995 public Intent putExtra(String name, long[] value) {
7996 if (mExtras == null) {
7997 mExtras = new Bundle();
7998 }
7999 mExtras.putLongArray(name, value);
8000 return this;
8001 }
8002
8003 /**
8004 * Add extended data to the intent. The name must include a package
8005 * prefix, for example the app com.android.contacts would use names
8006 * like "com.android.contacts.ShowAll".
8007 *
8008 * @param name The name of the extra data, with package prefix.
8009 * @param value The float array data value.
8010 *
8011 * @return Returns the same Intent object, for chaining multiple calls
8012 * into a single statement.
8013 *
8014 * @see #putExtras
8015 * @see #removeExtra
8016 * @see #getFloatArrayExtra(String)
8017 */
8018 public Intent putExtra(String name, float[] value) {
8019 if (mExtras == null) {
8020 mExtras = new Bundle();
8021 }
8022 mExtras.putFloatArray(name, value);
8023 return this;
8024 }
8025
8026 /**
8027 * Add extended data to the intent. The name must include a package
8028 * prefix, for example the app com.android.contacts would use names
8029 * like "com.android.contacts.ShowAll".
8030 *
8031 * @param name The name of the extra data, with package prefix.
8032 * @param value The double array data value.
8033 *
8034 * @return Returns the same Intent object, for chaining multiple calls
8035 * into a single statement.
8036 *
8037 * @see #putExtras
8038 * @see #removeExtra
8039 * @see #getDoubleArrayExtra(String)
8040 */
8041 public Intent putExtra(String name, double[] value) {
8042 if (mExtras == null) {
8043 mExtras = new Bundle();
8044 }
8045 mExtras.putDoubleArray(name, value);
8046 return this;
8047 }
8048
8049 /**
8050 * Add extended data to the intent. The name must include a package
8051 * prefix, for example the app com.android.contacts would use names
8052 * like "com.android.contacts.ShowAll".
8053 *
8054 * @param name The name of the extra data, with package prefix.
8055 * @param value The String array data value.
8056 *
8057 * @return Returns the same Intent object, for chaining multiple calls
8058 * into a single statement.
8059 *
8060 * @see #putExtras
8061 * @see #removeExtra
8062 * @see #getStringArrayExtra(String)
8063 */
8064 public Intent putExtra(String name, String[] value) {
8065 if (mExtras == null) {
8066 mExtras = new Bundle();
8067 }
8068 mExtras.putStringArray(name, value);
8069 return this;
8070 }
8071
8072 /**
8073 * Add extended data to the intent. The name must include a package
8074 * prefix, for example the app com.android.contacts would use names
8075 * like "com.android.contacts.ShowAll".
8076 *
8077 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008078 * @param value The CharSequence array data value.
8079 *
8080 * @return Returns the same Intent object, for chaining multiple calls
8081 * into a single statement.
8082 *
8083 * @see #putExtras
8084 * @see #removeExtra
8085 * @see #getCharSequenceArrayExtra(String)
8086 */
8087 public Intent putExtra(String name, CharSequence[] value) {
8088 if (mExtras == null) {
8089 mExtras = new Bundle();
8090 }
8091 mExtras.putCharSequenceArray(name, value);
8092 return this;
8093 }
8094
8095 /**
8096 * Add extended data to the intent. The name must include a package
8097 * prefix, for example the app com.android.contacts would use names
8098 * like "com.android.contacts.ShowAll".
8099 *
8100 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008101 * @param value The Bundle data value.
8102 *
8103 * @return Returns the same Intent object, for chaining multiple calls
8104 * into a single statement.
8105 *
8106 * @see #putExtras
8107 * @see #removeExtra
8108 * @see #getBundleExtra(String)
8109 */
8110 public Intent putExtra(String name, Bundle value) {
8111 if (mExtras == null) {
8112 mExtras = new Bundle();
8113 }
8114 mExtras.putBundle(name, value);
8115 return this;
8116 }
8117
8118 /**
8119 * Add extended data to the intent. The name must include a package
8120 * prefix, for example the app com.android.contacts would use names
8121 * like "com.android.contacts.ShowAll".
8122 *
8123 * @param name The name of the extra data, with package prefix.
8124 * @param value The IBinder data value.
8125 *
8126 * @return Returns the same Intent object, for chaining multiple calls
8127 * into a single statement.
8128 *
8129 * @see #putExtras
8130 * @see #removeExtra
8131 * @see #getIBinderExtra(String)
8132 *
8133 * @deprecated
8134 * @hide
8135 */
8136 @Deprecated
8137 public Intent putExtra(String name, IBinder value) {
8138 if (mExtras == null) {
8139 mExtras = new Bundle();
8140 }
8141 mExtras.putIBinder(name, value);
8142 return this;
8143 }
8144
8145 /**
8146 * Copy all extras in 'src' in to this intent.
8147 *
8148 * @param src Contains the extras to copy.
8149 *
8150 * @see #putExtra
8151 */
8152 public Intent putExtras(Intent src) {
8153 if (src.mExtras != null) {
8154 if (mExtras == null) {
8155 mExtras = new Bundle(src.mExtras);
8156 } else {
8157 mExtras.putAll(src.mExtras);
8158 }
8159 }
8160 return this;
8161 }
8162
8163 /**
8164 * Add a set of extended data to the intent. The keys must include a package
8165 * prefix, for example the app com.android.contacts would use names
8166 * like "com.android.contacts.ShowAll".
8167 *
8168 * @param extras The Bundle of extras to add to this intent.
8169 *
8170 * @see #putExtra
8171 * @see #removeExtra
8172 */
8173 public Intent putExtras(Bundle extras) {
8174 if (mExtras == null) {
8175 mExtras = new Bundle();
8176 }
8177 mExtras.putAll(extras);
8178 return this;
8179 }
8180
8181 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008182 * Completely replace the extras in the Intent with the extras in the
8183 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008184 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008185 * @param src The exact extras contained in this Intent are copied
8186 * into the target intent, replacing any that were previously there.
8187 */
8188 public Intent replaceExtras(Intent src) {
8189 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8190 return this;
8191 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008192
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008193 /**
8194 * Completely replace the extras in the Intent with the given Bundle of
8195 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008196 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008197 * @param extras The new set of extras in the Intent, or null to erase
8198 * all extras.
8199 */
8200 public Intent replaceExtras(Bundle extras) {
8201 mExtras = extras != null ? new Bundle(extras) : null;
8202 return this;
8203 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008204
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008205 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008206 * Remove extended data from the intent.
8207 *
8208 * @see #putExtra
8209 */
8210 public void removeExtra(String name) {
8211 if (mExtras != null) {
8212 mExtras.remove(name);
8213 if (mExtras.size() == 0) {
8214 mExtras = null;
8215 }
8216 }
8217 }
8218
8219 /**
8220 * Set special flags controlling how this intent is handled. Most values
8221 * here depend on the type of component being executed by the Intent,
8222 * specifically the FLAG_ACTIVITY_* flags are all for use with
8223 * {@link Context#startActivity Context.startActivity()} and the
8224 * FLAG_RECEIVER_* flags are all for use with
8225 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8226 *
Scott Main7aee61f2011-02-08 11:25:01 -08008227 * <p>See the
8228 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8229 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008230 * the behavior of your application.
8231 *
8232 * @param flags The desired flags.
8233 *
8234 * @return Returns the same Intent object, for chaining multiple calls
8235 * into a single statement.
8236 *
8237 * @see #getFlags
8238 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008239 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008240 *
8241 * @see #FLAG_GRANT_READ_URI_PERMISSION
8242 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008243 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8244 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008245 * @see #FLAG_DEBUG_LOG_RESOLUTION
8246 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008247 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008248 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008249 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008250 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008251 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8252 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008253 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008254 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008255 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008256 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008257 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008258 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008259 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008260 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8261 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008262 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008263 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008264 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008265 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8266 */
8267 public Intent setFlags(int flags) {
8268 mFlags = flags;
8269 return this;
8270 }
8271
8272 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008273 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008274 *
8275 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008276 * @return Returns the same Intent object, for chaining multiple calls into
8277 * a single statement.
8278 * @see #setFlags(int)
8279 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008280 */
8281 public Intent addFlags(int flags) {
8282 mFlags |= flags;
8283 return this;
8284 }
8285
8286 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008287 * Remove these flags from the intent.
8288 *
8289 * @param flags The flags to remove.
8290 * @see #setFlags(int)
8291 * @see #addFlags(int)
8292 */
8293 public void removeFlags(int flags) {
8294 mFlags &= ~flags;
8295 }
8296
8297 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008298 * (Usually optional) Set an explicit application package name that limits
8299 * the components this Intent will resolve to. If left to the default
8300 * value of null, all components in all applications will considered.
8301 * If non-null, the Intent can only match the components in the given
8302 * application package.
8303 *
8304 * @param packageName The name of the application package to handle the
8305 * intent, or null to allow any application package.
8306 *
8307 * @return Returns the same Intent object, for chaining multiple calls
8308 * into a single statement.
8309 *
8310 * @see #getPackage
8311 * @see #resolveActivity
8312 */
8313 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008314 if (packageName != null && mSelector != null) {
8315 throw new IllegalArgumentException(
8316 "Can't set package name when selector is already set");
8317 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008318 mPackage = packageName;
8319 return this;
8320 }
8321
8322 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008323 * (Usually optional) Explicitly set the component to handle the intent.
8324 * If left with the default value of null, the system will determine the
8325 * appropriate class to use based on the other fields (action, data,
8326 * type, categories) in the Intent. If this class is defined, the
8327 * specified class will always be used regardless of the other fields. You
8328 * should only set this value when you know you absolutely want a specific
8329 * class to be used; otherwise it is better to let the system find the
8330 * appropriate class so that you will respect the installed applications
8331 * and user preferences.
8332 *
8333 * @param component The name of the application component to handle the
8334 * intent, or null to let the system find one for you.
8335 *
8336 * @return Returns the same Intent object, for chaining multiple calls
8337 * into a single statement.
8338 *
8339 * @see #setClass
8340 * @see #setClassName(Context, String)
8341 * @see #setClassName(String, String)
8342 * @see #getComponent
8343 * @see #resolveActivity
8344 */
8345 public Intent setComponent(ComponentName component) {
8346 mComponent = component;
8347 return this;
8348 }
8349
8350 /**
8351 * Convenience for calling {@link #setComponent} with an
8352 * explicit class name.
8353 *
8354 * @param packageContext A Context of the application package implementing
8355 * this class.
8356 * @param className The name of a class inside of the application package
8357 * that will be used as the component for this Intent.
8358 *
8359 * @return Returns the same Intent object, for chaining multiple calls
8360 * into a single statement.
8361 *
8362 * @see #setComponent
8363 * @see #setClass
8364 */
8365 public Intent setClassName(Context packageContext, String className) {
8366 mComponent = new ComponentName(packageContext, className);
8367 return this;
8368 }
8369
8370 /**
8371 * Convenience for calling {@link #setComponent} with an
8372 * explicit application package name and class name.
8373 *
8374 * @param packageName The name of the package implementing the desired
8375 * component.
8376 * @param className The name of a class inside of the application package
8377 * that will be used as the component for this Intent.
8378 *
8379 * @return Returns the same Intent object, for chaining multiple calls
8380 * into a single statement.
8381 *
8382 * @see #setComponent
8383 * @see #setClass
8384 */
8385 public Intent setClassName(String packageName, String className) {
8386 mComponent = new ComponentName(packageName, className);
8387 return this;
8388 }
8389
8390 /**
8391 * Convenience for calling {@link #setComponent(ComponentName)} with the
8392 * name returned by a {@link Class} object.
8393 *
8394 * @param packageContext A Context of the application package implementing
8395 * this class.
8396 * @param cls The class name to set, equivalent to
8397 * <code>setClassName(context, cls.getName())</code>.
8398 *
8399 * @return Returns the same Intent object, for chaining multiple calls
8400 * into a single statement.
8401 *
8402 * @see #setComponent
8403 */
8404 public Intent setClass(Context packageContext, Class<?> cls) {
8405 mComponent = new ComponentName(packageContext, cls);
8406 return this;
8407 }
8408
8409 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008410 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8411 * used as a hint to the receiver for animations and the like. Null means that there
8412 * is no source bounds.
8413 */
8414 public void setSourceBounds(Rect r) {
8415 if (r != null) {
8416 mSourceBounds = new Rect(r);
8417 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008418 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008419 }
8420 }
8421
Tor Norbyed9273d62013-05-30 15:59:53 -07008422 /** @hide */
8423 @IntDef(flag = true,
8424 value = {
8425 FILL_IN_ACTION,
8426 FILL_IN_DATA,
8427 FILL_IN_CATEGORIES,
8428 FILL_IN_COMPONENT,
8429 FILL_IN_PACKAGE,
8430 FILL_IN_SOURCE_BOUNDS,
8431 FILL_IN_SELECTOR,
8432 FILL_IN_CLIP_DATA
8433 })
8434 @Retention(RetentionPolicy.SOURCE)
8435 public @interface FillInFlags {}
8436
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008437 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008438 * Use with {@link #fillIn} to allow the current action value to be
8439 * overwritten, even if it is already set.
8440 */
8441 public static final int FILL_IN_ACTION = 1<<0;
8442
8443 /**
8444 * Use with {@link #fillIn} to allow the current data or type value
8445 * overwritten, even if it is already set.
8446 */
8447 public static final int FILL_IN_DATA = 1<<1;
8448
8449 /**
8450 * Use with {@link #fillIn} to allow the current categories to be
8451 * overwritten, even if they are already set.
8452 */
8453 public static final int FILL_IN_CATEGORIES = 1<<2;
8454
8455 /**
8456 * Use with {@link #fillIn} to allow the current component value to be
8457 * overwritten, even if it is already set.
8458 */
8459 public static final int FILL_IN_COMPONENT = 1<<3;
8460
8461 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008462 * Use with {@link #fillIn} to allow the current package value to be
8463 * overwritten, even if it is already set.
8464 */
8465 public static final int FILL_IN_PACKAGE = 1<<4;
8466
8467 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008468 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008469 * overwritten, even if it is already set.
8470 */
8471 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8472
8473 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008474 * Use with {@link #fillIn} to allow the current selector to be
8475 * overwritten, even if it is already set.
8476 */
8477 public static final int FILL_IN_SELECTOR = 1<<6;
8478
8479 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008480 * Use with {@link #fillIn} to allow the current ClipData to be
8481 * overwritten, even if it is already set.
8482 */
8483 public static final int FILL_IN_CLIP_DATA = 1<<7;
8484
8485 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008486 * Copy the contents of <var>other</var> in to this object, but only
8487 * where fields are not defined by this object. For purposes of a field
8488 * being defined, the following pieces of data in the Intent are
8489 * considered to be separate fields:
8490 *
8491 * <ul>
8492 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008493 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008494 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8495 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008496 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008497 * <li> component, as set by {@link #setComponent(ComponentName)} or
8498 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008499 * <li> source bounds, as set by {@link #setSourceBounds}.
8500 * <li> selector, as set by {@link #setSelector(Intent)}.
8501 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008502 * <li> each top-level name in the associated extras.
8503 * </ul>
8504 *
8505 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008506 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008507 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8508 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8509 * the restriction where the corresponding field will not be replaced if
8510 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008511 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008512 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8513 * is explicitly specified. The selector will only be copied if
8514 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008515 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008516 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8517 * and Intent B with {action="gotit", data-type="some/thing",
8518 * categories="one","two"}.
8519 *
8520 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8521 * containing: {action="gotit", data-type="some/thing",
8522 * categories="bar"}.
8523 *
8524 * @param other Another Intent whose values are to be used to fill in
8525 * the current one.
8526 * @param flags Options to control which fields can be filled in.
8527 *
8528 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008529 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008530 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008531 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008532 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008533 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008534 @FillInFlags
8535 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008536 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008537 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008538 if (other.mAction != null
8539 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008540 mAction = other.mAction;
8541 changes |= FILL_IN_ACTION;
8542 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008543 if ((other.mData != null || other.mType != null)
8544 && ((mData == null && mType == null)
8545 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008546 mData = other.mData;
8547 mType = other.mType;
8548 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008549 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008550 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008551 if (other.mCategories != null
8552 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008553 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008554 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 }
8556 changes |= FILL_IN_CATEGORIES;
8557 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008558 if (other.mPackage != null
8559 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008560 // Only do this if mSelector is not set.
8561 if (mSelector == null) {
8562 mPackage = other.mPackage;
8563 changes |= FILL_IN_PACKAGE;
8564 }
8565 }
8566 // Selector is special: it can only be set if explicitly allowed,
8567 // for the same reason as the component name.
8568 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8569 if (mPackage == null) {
8570 mSelector = new Intent(other.mSelector);
8571 mPackage = null;
8572 changes |= FILL_IN_SELECTOR;
8573 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008574 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008575 if (other.mClipData != null
8576 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8577 mClipData = other.mClipData;
8578 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008579 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008580 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008581 // Component is special: it can -only- be set if explicitly allowed,
8582 // since otherwise the sender could force the intent somewhere the
8583 // originator didn't intend.
8584 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008585 mComponent = other.mComponent;
8586 changes |= FILL_IN_COMPONENT;
8587 }
8588 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008589 if (other.mSourceBounds != null
8590 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8591 mSourceBounds = new Rect(other.mSourceBounds);
8592 changes |= FILL_IN_SOURCE_BOUNDS;
8593 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008594 if (mExtras == null) {
8595 if (other.mExtras != null) {
8596 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008597 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008598 }
8599 } else if (other.mExtras != null) {
8600 try {
8601 Bundle newb = new Bundle(other.mExtras);
8602 newb.putAll(mExtras);
8603 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008604 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008605 } catch (RuntimeException e) {
8606 // Modifying the extras can cause us to unparcel the contents
8607 // of the bundle, and if we do this in the system process that
8608 // may fail. We really should handle this (i.e., the Bundle
8609 // impl shouldn't be on top of a plain map), but for now just
8610 // ignore it and keep the original contents. :(
8611 Log.w("Intent", "Failure filling in extras", e);
8612 }
8613 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008614 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8615 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8616 mContentUserHint = other.mContentUserHint;
8617 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008618 return changes;
8619 }
8620
8621 /**
8622 * Wrapper class holding an Intent and implementing comparisons on it for
8623 * the purpose of filtering. The class implements its
8624 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8625 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8626 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8627 * on the wrapped Intent.
8628 */
8629 public static final class FilterComparison {
8630 private final Intent mIntent;
8631 private final int mHashCode;
8632
8633 public FilterComparison(Intent intent) {
8634 mIntent = intent;
8635 mHashCode = intent.filterHashCode();
8636 }
8637
8638 /**
8639 * Return the Intent that this FilterComparison represents.
8640 * @return Returns the Intent held by the FilterComparison. Do
8641 * not modify!
8642 */
8643 public Intent getIntent() {
8644 return mIntent;
8645 }
8646
8647 @Override
8648 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008649 if (obj instanceof FilterComparison) {
8650 Intent other = ((FilterComparison)obj).mIntent;
8651 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008652 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008653 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008654 }
8655
8656 @Override
8657 public int hashCode() {
8658 return mHashCode;
8659 }
8660 }
8661
8662 /**
8663 * Determine if two intents are the same for the purposes of intent
8664 * resolution (filtering). That is, if their action, data, type,
8665 * class, and categories are the same. This does <em>not</em> compare
8666 * any extra data included in the intents.
8667 *
8668 * @param other The other Intent to compare against.
8669 *
8670 * @return Returns true if action, data, type, class, and categories
8671 * are the same.
8672 */
8673 public boolean filterEquals(Intent other) {
8674 if (other == null) {
8675 return false;
8676 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008677 if (!Objects.equals(this.mAction, other.mAction)) return false;
8678 if (!Objects.equals(this.mData, other.mData)) return false;
8679 if (!Objects.equals(this.mType, other.mType)) return false;
8680 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8681 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8682 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008683
8684 return true;
8685 }
8686
8687 /**
8688 * Generate hash code that matches semantics of filterEquals().
8689 *
8690 * @return Returns the hash value of the action, data, type, class, and
8691 * categories.
8692 *
8693 * @see #filterEquals
8694 */
8695 public int filterHashCode() {
8696 int code = 0;
8697 if (mAction != null) {
8698 code += mAction.hashCode();
8699 }
8700 if (mData != null) {
8701 code += mData.hashCode();
8702 }
8703 if (mType != null) {
8704 code += mType.hashCode();
8705 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008706 if (mPackage != null) {
8707 code += mPackage.hashCode();
8708 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008709 if (mComponent != null) {
8710 code += mComponent.hashCode();
8711 }
8712 if (mCategories != null) {
8713 code += mCategories.hashCode();
8714 }
8715 return code;
8716 }
8717
8718 @Override
8719 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008720 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008721
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008722 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008723 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008724 b.append(" }");
8725
8726 return b.toString();
8727 }
8728
8729 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008730 public String toInsecureString() {
8731 StringBuilder b = new StringBuilder(128);
8732
8733 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008734 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008735 b.append(" }");
8736
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008737 return b.toString();
8738 }
Romain Guy4969af72009-06-17 10:53:19 -07008739
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008740 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008741 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008742 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008743
8744 b.append("Intent { ");
8745 toShortString(b, false, true, true, true);
8746 b.append(" }");
8747
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008748 return b.toString();
8749 }
8750
8751 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008752 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8753 StringBuilder b = new StringBuilder(128);
8754 toShortString(b, secure, comp, extras, clip);
8755 return b.toString();
8756 }
8757
8758 /** @hide */
8759 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8760 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008761 boolean first = true;
8762 if (mAction != null) {
8763 b.append("act=").append(mAction);
8764 first = false;
8765 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008766 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008767 if (!first) {
8768 b.append(' ');
8769 }
8770 first = false;
8771 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008772 for (int i=0; i<mCategories.size(); i++) {
8773 if (i > 0) b.append(',');
8774 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008775 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008776 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008777 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008778 if (mData != null) {
8779 if (!first) {
8780 b.append(' ');
8781 }
8782 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008783 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008784 if (secure) {
8785 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008786 } else {
8787 b.append(mData);
8788 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008789 }
8790 if (mType != null) {
8791 if (!first) {
8792 b.append(' ');
8793 }
8794 first = false;
8795 b.append("typ=").append(mType);
8796 }
8797 if (mFlags != 0) {
8798 if (!first) {
8799 b.append(' ');
8800 }
8801 first = false;
8802 b.append("flg=0x").append(Integer.toHexString(mFlags));
8803 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008804 if (mPackage != null) {
8805 if (!first) {
8806 b.append(' ');
8807 }
8808 first = false;
8809 b.append("pkg=").append(mPackage);
8810 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008811 if (comp && mComponent != null) {
8812 if (!first) {
8813 b.append(' ');
8814 }
8815 first = false;
8816 b.append("cmp=").append(mComponent.flattenToShortString());
8817 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008818 if (mSourceBounds != null) {
8819 if (!first) {
8820 b.append(' ');
8821 }
8822 first = false;
8823 b.append("bnds=").append(mSourceBounds.toShortString());
8824 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008825 if (mClipData != null) {
8826 if (!first) {
8827 b.append(' ');
8828 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008829 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008830 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008831 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008832 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008833 if (mClipData.getDescription() != null) {
8834 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8835 } else {
8836 first = true;
8837 }
8838 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008839 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008840 first = false;
8841 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008842 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008843 if (extras && mExtras != null) {
8844 if (!first) {
8845 b.append(' ');
8846 }
8847 first = false;
8848 b.append("(has extras)");
8849 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008850 if (mContentUserHint != UserHandle.USER_CURRENT) {
8851 if (!first) {
8852 b.append(' ');
8853 }
8854 first = false;
8855 b.append("u=").append(mContentUserHint);
8856 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008857 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008858 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008859 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008860 b.append("}");
8861 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008862 }
8863
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008864 /**
8865 * Call {@link #toUri} with 0 flags.
8866 * @deprecated Use {@link #toUri} instead.
8867 */
8868 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008869 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008870 return toUri(0);
8871 }
8872
8873 /**
8874 * Convert this Intent into a String holding a URI representation of it.
8875 * The returned URI string has been properly URI encoded, so it can be
8876 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8877 * Intent's data as the base URI, with an additional fragment describing
8878 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008879 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008880 * <p>You can convert the returned string back to an Intent with
8881 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008882 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008883 * @param flags Additional operating flags. Either 0,
8884 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008885 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008886 * @return Returns a URI encoding URI string describing the entire contents
8887 * of the Intent.
8888 */
8889 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008890 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008891 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8892 if (mPackage == null) {
8893 throw new IllegalArgumentException(
8894 "Intent must include an explicit package name to build an android-app: "
8895 + this);
8896 }
8897 uri.append("android-app://");
8898 uri.append(mPackage);
8899 String scheme = null;
8900 if (mData != null) {
8901 scheme = mData.getScheme();
8902 if (scheme != null) {
8903 uri.append('/');
8904 uri.append(scheme);
8905 String authority = mData.getEncodedAuthority();
8906 if (authority != null) {
8907 uri.append('/');
8908 uri.append(authority);
8909 String path = mData.getEncodedPath();
8910 if (path != null) {
8911 uri.append(path);
8912 }
8913 String queryParams = mData.getEncodedQuery();
8914 if (queryParams != null) {
8915 uri.append('?');
8916 uri.append(queryParams);
8917 }
8918 String fragment = mData.getEncodedFragment();
8919 if (fragment != null) {
8920 uri.append('#');
8921 uri.append(fragment);
8922 }
8923 }
8924 }
8925 }
8926 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8927 mPackage, flags);
8928 return uri.toString();
8929 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008930 String scheme = null;
8931 if (mData != null) {
8932 String data = mData.toString();
8933 if ((flags&URI_INTENT_SCHEME) != 0) {
8934 final int N = data.length();
8935 for (int i=0; i<N; i++) {
8936 char c = data.charAt(i);
8937 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8938 || c == '.' || c == '-') {
8939 continue;
8940 }
8941 if (c == ':' && i > 0) {
8942 // Valid scheme.
8943 scheme = data.substring(0, i);
8944 uri.append("intent:");
8945 data = data.substring(i+1);
8946 break;
8947 }
Tom Taylord4a47292009-12-21 13:59:18 -08008948
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008949 // No scheme.
8950 break;
8951 }
8952 }
8953 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008954
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008955 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8956 uri.append("intent:");
8957 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008958
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008959 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008960
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008961 return uri.toString();
8962 }
8963
8964 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8965 String defPackage, int flags) {
8966 StringBuilder frag = new StringBuilder(128);
8967
8968 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008969 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008970 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008971 // Note that for now we are not going to try to handle the
8972 // data part; not clear how to represent this as a URI, and
8973 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008974 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8975 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008976 }
8977
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008978 if (frag.length() > 0) {
8979 uri.append("#Intent;");
8980 uri.append(frag);
8981 uri.append("end");
8982 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008983 }
8984
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008985 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8986 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008987 if (scheme != null) {
8988 uri.append("scheme=").append(scheme).append(';');
8989 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008990 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008991 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008992 }
8993 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008994 for (int i=0; i<mCategories.size(); i++) {
8995 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008996 }
8997 }
8998 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008999 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009000 }
9001 if (mFlags != 0) {
9002 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9003 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009004 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009005 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9006 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009007 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009008 uri.append("component=").append(Uri.encode(
9009 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009010 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009011 if (mSourceBounds != null) {
9012 uri.append("sourceBounds=")
9013 .append(Uri.encode(mSourceBounds.flattenToString()))
9014 .append(';');
9015 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009016 if (mExtras != null) {
9017 for (String key : mExtras.keySet()) {
9018 final Object value = mExtras.get(key);
9019 char entryType =
9020 value instanceof String ? 'S' :
9021 value instanceof Boolean ? 'B' :
9022 value instanceof Byte ? 'b' :
9023 value instanceof Character ? 'c' :
9024 value instanceof Double ? 'd' :
9025 value instanceof Float ? 'f' :
9026 value instanceof Integer ? 'i' :
9027 value instanceof Long ? 'l' :
9028 value instanceof Short ? 's' :
9029 '\0';
9030
9031 if (entryType != '\0') {
9032 uri.append(entryType);
9033 uri.append('.');
9034 uri.append(Uri.encode(key));
9035 uri.append('=');
9036 uri.append(Uri.encode(value.toString()));
9037 uri.append(';');
9038 }
9039 }
9040 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009041 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009042
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009043 public int describeContents() {
9044 return (mExtras != null) ? mExtras.describeContents() : 0;
9045 }
9046
9047 public void writeToParcel(Parcel out, int flags) {
9048 out.writeString(mAction);
9049 Uri.writeToParcel(out, mData);
9050 out.writeString(mType);
9051 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009052 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009053 ComponentName.writeToParcel(mComponent, out);
9054
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009055 if (mSourceBounds != null) {
9056 out.writeInt(1);
9057 mSourceBounds.writeToParcel(out, flags);
9058 } else {
9059 out.writeInt(0);
9060 }
9061
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009062 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009063 final int N = mCategories.size();
9064 out.writeInt(N);
9065 for (int i=0; i<N; i++) {
9066 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009067 }
9068 } else {
9069 out.writeInt(0);
9070 }
9071
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009072 if (mSelector != null) {
9073 out.writeInt(1);
9074 mSelector.writeToParcel(out, flags);
9075 } else {
9076 out.writeInt(0);
9077 }
9078
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009079 if (mClipData != null) {
9080 out.writeInt(1);
9081 mClipData.writeToParcel(out, flags);
9082 } else {
9083 out.writeInt(0);
9084 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009085 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009086 out.writeBundle(mExtras);
9087 }
9088
9089 public static final Parcelable.Creator<Intent> CREATOR
9090 = new Parcelable.Creator<Intent>() {
9091 public Intent createFromParcel(Parcel in) {
9092 return new Intent(in);
9093 }
9094 public Intent[] newArray(int size) {
9095 return new Intent[size];
9096 }
9097 };
9098
Dianne Hackborneb034652009-09-07 00:49:58 -07009099 /** @hide */
9100 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009101 readFromParcel(in);
9102 }
9103
9104 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009105 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009106 mData = Uri.CREATOR.createFromParcel(in);
9107 mType = in.readString();
9108 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009109 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009110 mComponent = ComponentName.readFromParcel(in);
9111
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009112 if (in.readInt() != 0) {
9113 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9114 }
9115
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009116 int N = in.readInt();
9117 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009118 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009119 int i;
9120 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009121 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009122 }
9123 } else {
9124 mCategories = null;
9125 }
9126
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009127 if (in.readInt() != 0) {
9128 mSelector = new Intent(in);
9129 }
9130
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009131 if (in.readInt() != 0) {
9132 mClipData = new ClipData(in);
9133 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009134 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009135 mExtras = in.readBundle();
9136 }
9137
9138 /**
9139 * Parses the "intent" element (and its children) from XML and instantiates
9140 * an Intent object. The given XML parser should be located at the tag
9141 * where parsing should start (often named "intent"), from which the
9142 * basic action, data, type, and package and class name will be
9143 * retrieved. The function will then parse in to any child elements,
9144 * looking for <category android:name="xxx"> tags to add categories and
9145 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9146 * to the intent.
9147 *
9148 * @param resources The Resources to use when inflating resources.
9149 * @param parser The XML parser pointing at an "intent" tag.
9150 * @param attrs The AttributeSet interface for retrieving extended
9151 * attribute data at the current <var>parser</var> location.
9152 * @return An Intent object matching the XML data.
9153 * @throws XmlPullParserException If there was an XML parsing error.
9154 * @throws IOException If there was an I/O error.
9155 */
9156 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9157 throws XmlPullParserException, IOException {
9158 Intent intent = new Intent();
9159
9160 TypedArray sa = resources.obtainAttributes(attrs,
9161 com.android.internal.R.styleable.Intent);
9162
9163 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9164
9165 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9166 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9167 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9168
9169 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9170 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9171 if (packageName != null && className != null) {
9172 intent.setComponent(new ComponentName(packageName, className));
9173 }
9174
9175 sa.recycle();
9176
9177 int outerDepth = parser.getDepth();
9178 int type;
9179 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9180 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9181 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9182 continue;
9183 }
9184
9185 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009186 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009187 sa = resources.obtainAttributes(attrs,
9188 com.android.internal.R.styleable.IntentCategory);
9189 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9190 sa.recycle();
9191
9192 if (cat != null) {
9193 intent.addCategory(cat);
9194 }
9195 XmlUtils.skipCurrentTag(parser);
9196
Craig Mautner21d24a22014-04-23 11:45:37 -07009197 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009198 if (intent.mExtras == null) {
9199 intent.mExtras = new Bundle();
9200 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009201 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009202 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009203
9204 } else {
9205 XmlUtils.skipCurrentTag(parser);
9206 }
9207 }
9208
9209 return intent;
9210 }
Nick Pellyccae4122012-01-09 14:12:58 -08009211
Craig Mautner21d24a22014-04-23 11:45:37 -07009212 /** @hide */
9213 public void saveToXml(XmlSerializer out) throws IOException {
9214 if (mAction != null) {
9215 out.attribute(null, ATTR_ACTION, mAction);
9216 }
9217 if (mData != null) {
9218 out.attribute(null, ATTR_DATA, mData.toString());
9219 }
9220 if (mType != null) {
9221 out.attribute(null, ATTR_TYPE, mType);
9222 }
9223 if (mComponent != null) {
9224 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9225 }
9226 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9227
9228 if (mCategories != null) {
9229 out.startTag(null, TAG_CATEGORIES);
9230 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9231 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9232 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009233 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009234 }
9235 }
9236
9237 /** @hide */
9238 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9239 XmlPullParserException {
9240 Intent intent = new Intent();
9241 final int outerDepth = in.getDepth();
9242
9243 int attrCount = in.getAttributeCount();
9244 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9245 final String attrName = in.getAttributeName(attrNdx);
9246 final String attrValue = in.getAttributeValue(attrNdx);
9247 if (ATTR_ACTION.equals(attrName)) {
9248 intent.setAction(attrValue);
9249 } else if (ATTR_DATA.equals(attrName)) {
9250 intent.setData(Uri.parse(attrValue));
9251 } else if (ATTR_TYPE.equals(attrName)) {
9252 intent.setType(attrValue);
9253 } else if (ATTR_COMPONENT.equals(attrName)) {
9254 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9255 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009256 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009257 } else {
9258 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9259 }
9260 }
9261
9262 int event;
9263 String name;
9264 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9265 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9266 if (event == XmlPullParser.START_TAG) {
9267 name = in.getName();
9268 if (TAG_CATEGORIES.equals(name)) {
9269 attrCount = in.getAttributeCount();
9270 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9271 intent.addCategory(in.getAttributeValue(attrNdx));
9272 }
9273 } else {
9274 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9275 XmlUtils.skipCurrentTag(in);
9276 }
9277 }
9278 }
9279
9280 return intent;
9281 }
9282
Nick Pellyccae4122012-01-09 14:12:58 -08009283 /**
9284 * Normalize a MIME data type.
9285 *
9286 * <p>A normalized MIME type has white-space trimmed,
9287 * content-type parameters removed, and is lower-case.
9288 * This aligns the type with Android best practices for
9289 * intent filtering.
9290 *
9291 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9292 * "text/x-vCard" becomes "text/x-vcard".
9293 *
9294 * <p>All MIME types received from outside Android (such as user input,
9295 * or external sources like Bluetooth, NFC, or the Internet) should
9296 * be normalized before they are used to create an Intent.
9297 *
9298 * @param type MIME data type to normalize
9299 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009300 * @see #setType
9301 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009302 */
9303 public static String normalizeMimeType(String type) {
9304 if (type == null) {
9305 return null;
9306 }
9307
Elliott Hughescb64d432013-08-02 10:00:44 -07009308 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009309
9310 final int semicolonIndex = type.indexOf(';');
9311 if (semicolonIndex != -1) {
9312 type = type.substring(0, semicolonIndex);
9313 }
9314 return type;
9315 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009316
9317 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009318 * Prepare this {@link Intent} to leave an app process.
9319 *
9320 * @hide
9321 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009322 public void prepareToLeaveProcess(Context context) {
9323 final boolean leavingPackage = (mComponent == null)
9324 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9325 prepareToLeaveProcess(leavingPackage);
9326 }
9327
9328 /**
9329 * Prepare this {@link Intent} to leave an app process.
9330 *
9331 * @hide
9332 */
9333 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009334 setAllowFds(false);
9335
9336 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009337 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009338 }
9339 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009340 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009341 }
9342
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009343 if (mExtras != null && !mExtras.isParcelled()) {
9344 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9345 if (intent instanceof Intent) {
9346 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9347 }
9348 }
9349
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009350 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9351 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009352 switch (mAction) {
9353 case ACTION_MEDIA_REMOVED:
9354 case ACTION_MEDIA_UNMOUNTED:
9355 case ACTION_MEDIA_CHECKING:
9356 case ACTION_MEDIA_NOFS:
9357 case ACTION_MEDIA_MOUNTED:
9358 case ACTION_MEDIA_SHARED:
9359 case ACTION_MEDIA_UNSHARED:
9360 case ACTION_MEDIA_BAD_REMOVAL:
9361 case ACTION_MEDIA_UNMOUNTABLE:
9362 case ACTION_MEDIA_EJECT:
9363 case ACTION_MEDIA_SCANNER_STARTED:
9364 case ACTION_MEDIA_SCANNER_FINISHED:
9365 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009366 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9367 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009368 // Ignore legacy actions
9369 break;
9370 default:
9371 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009372 }
9373 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009374
9375 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9376 && leavingPackage) {
9377 switch (mAction) {
9378 case ACTION_PROVIDER_CHANGED:
9379 // Ignore actions that don't need to grant
9380 break;
9381 default:
9382 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9383 }
9384 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009385 }
9386
9387 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009388 * @hide
9389 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009390 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009391 // We just entered destination process, so we should be able to read all
9392 // parcelables inside.
9393 setDefusable(true);
9394
9395 if (mSelector != null) {
9396 mSelector.prepareToEnterProcess();
9397 }
9398 if (mClipData != null) {
9399 mClipData.prepareToEnterProcess();
9400 }
9401
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009402 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009403 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9404 fixUris(mContentUserHint);
9405 mContentUserHint = UserHandle.USER_CURRENT;
9406 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009407 }
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06009408
9409 // If someone is sending us ClipData, but not EXTRA_STREAM, offer to
9410 // downgrade that content for older apps to find
9411 if (mClipData != null && mClipData.getItemCount() > 0 && !hasExtra(EXTRA_STREAM)) {
9412 final String action = getAction();
9413 if (ACTION_SEND.equals(action)) {
9414 putExtra(EXTRA_STREAM, mClipData.getItemAt(0).getUri());
9415 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
9416 final ArrayList<Uri> list = new ArrayList<>();
9417 for (int i = 0; i < mClipData.getItemCount(); i++) {
9418 list.add(mClipData.getItemAt(i).getUri());
9419 }
9420 putExtra(EXTRA_STREAM, list);
9421 }
9422 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009423 }
9424
9425 /**
9426 * @hide
9427 */
9428 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009429 Uri data = getData();
9430 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009431 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009432 }
9433 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009434 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009435 }
9436 String action = getAction();
9437 if (ACTION_SEND.equals(action)) {
9438 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9439 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009440 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009441 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009442 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009443 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9444 if (streams != null) {
9445 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9446 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009447 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009448 }
9449 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9450 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009451 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9452 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9453 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9454 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9455 if (output != null) {
9456 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9457 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009458 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009459 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009460
9461 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009462 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009463 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9464 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009465 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009466 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009467 * @hide
9468 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009469 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009470 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009471 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009472
9473 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009474 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009475
9476 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009477 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009478 // Inspect contained intents to see if we need to migrate extras. We
9479 // don't promote ClipData to the parent, since ChooserActivity will
9480 // already start the picked item as the caller, and we can't combine
9481 // the flags in a safe way.
9482
9483 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009484 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009485 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9486 if (intent != null) {
9487 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009488 }
9489 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009490 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009491 try {
9492 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9493 if (intents != null) {
9494 for (int i = 0; i < intents.length; i++) {
9495 final Intent intent = (Intent) intents[i];
9496 if (intent != null) {
9497 migrated |= intent.migrateExtraStreamToClipData();
9498 }
9499 }
9500 }
9501 } catch (ClassCastException e) {
9502 }
9503 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009504
9505 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009506 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009507 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9508 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9509 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9510 if (stream != null || text != null || htmlText != null) {
9511 final ClipData clipData = new ClipData(
9512 null, new String[] { getType() },
9513 new ClipData.Item(text, htmlText, null, stream));
9514 setClipData(clipData);
9515 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009516 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009517 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009518 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009519 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009520
9521 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009522 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009523 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9524 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9525 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9526 int num = -1;
9527 if (streams != null) {
9528 num = streams.size();
9529 }
9530 if (texts != null) {
9531 if (num >= 0 && num != texts.size()) {
9532 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009533 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009534 }
9535 num = texts.size();
9536 }
9537 if (htmlTexts != null) {
9538 if (num >= 0 && num != htmlTexts.size()) {
9539 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009540 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009541 }
9542 num = htmlTexts.size();
9543 }
9544 if (num > 0) {
9545 final ClipData clipData = new ClipData(
9546 null, new String[] { getType() },
9547 makeClipItem(streams, texts, htmlTexts, 0));
9548
9549 for (int i = 1; i < num; i++) {
9550 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9551 }
9552
9553 setClipData(clipData);
9554 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009555 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009556 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009557 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009558 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009559 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9560 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9561 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9562 final Uri output;
9563 try {
9564 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9565 } catch (ClassCastException e) {
9566 return false;
9567 }
9568 if (output != null) {
9569 setClipData(ClipData.newRawUri("", output));
9570 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9571 return true;
9572 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009573 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009574
9575 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009576 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009577
9578 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9579 ArrayList<String> htmlTexts, int which) {
9580 Uri uri = streams != null ? streams.get(which) : null;
9581 CharSequence text = texts != null ? texts.get(which) : null;
9582 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9583 return new ClipData.Item(text, htmlText, null, uri);
9584 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009585
9586 /** @hide */
9587 public boolean isDocument() {
9588 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9589 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009590}