blob: 7890a9607932487f30d27a62b757a0436ec4d3b1 [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 /**
1439 * Activity Action: Setup wizard to launch after a platform update. This
1440 * activity should have a string meta-data field associated with it,
1441 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1442 * the platform for setup. The activity will be launched only if
1443 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1444 * same value.
1445 * <p>Input: Nothing.
1446 * <p>Output: Nothing.
1447 * @hide
1448 */
1449 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1450 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001451
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001452 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001453 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1454 * <p>Input: Nothing.
1455 * <p>Output: Nothing.
1456 * @hide
1457 */
1458 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1459 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001460 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001461
1462 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001463 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1464 * <p>Input: Nothing.
1465 * <p>Output: Nothing.
1466 * @hide
1467 */
1468 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1469 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001470 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001471
1472 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001473 * Activity Action: Show settings for managing network data usage of a
1474 * specific application. Applications should define an activity that offers
1475 * options to control data usage.
1476 */
1477 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1478 public static final String ACTION_MANAGE_NETWORK_USAGE =
1479 "android.intent.action.MANAGE_NETWORK_USAGE";
1480
1481 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001482 * Activity Action: Launch application installer.
1483 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001484 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001485 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1486 * you can also use "package:<package-name>" to install an application for the
1487 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001488 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1489 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1490 * <p>
1491 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1492 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001493 * <p>
1494 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1495 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1496 * in order to launch the application installer.
1497 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001498 *
1499 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1500 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1501 * @see #EXTRA_RETURN_RESULT
1502 */
1503 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1504 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1505
1506 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001507 * Activity Action: Launch ephemeral installer.
1508 * <p>
1509 * Input: The data must be a http: URI that the ephemeral application is registered
1510 * to handle.
1511 * <p class="note">
1512 * This is a protected intent that can only be sent by the system.
1513 * </p>
1514 *
1515 * @hide
1516 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1518 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1519 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1520
1521 /**
1522 * Service Action: Resolve ephemeral application.
1523 * <p>
1524 * The system will have a persistent connection to this service.
1525 * This is a protected intent that can only be sent by the system.
1526 * </p>
1527 *
1528 * @hide
1529 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001530 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1531 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1532 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1533
1534 /**
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001535 * Activity Action: Launch ephemeral settings.
1536 *
1537 * <p class="note">
1538 * This is a protected intent that can only be sent by the system.
1539 * </p>
1540 *
1541 * @hide
1542 */
1543 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1544 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1545 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1546
1547 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001548 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1549 * package. Specifies the installer package name; this package will receive the
1550 * {@link #ACTION_APP_ERROR} intent.
1551 */
1552 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1553 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1554
1555 /**
1556 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1557 * package. Specifies that the application being installed should not be
1558 * treated as coming from an unknown source, but as coming from the app
1559 * invoking the Intent. For this to work you must start the installer with
1560 * startActivityForResult().
1561 */
1562 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1563 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1564
1565 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001566 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1567 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001568 * data field originated from.
1569 */
rich cannings706e8ba2012-08-20 13:20:14 -07001570 public static final String EXTRA_ORIGINATING_URI
1571 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001572
1573 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001574 * This extra can be used with any Intent used to launch an activity, supplying information
1575 * about who is launching that activity. This field contains a {@link android.net.Uri}
1576 * object, typically an http: or https: URI of the web site that the referral came from;
1577 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1578 * a native application that it came from.
1579 *
1580 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1581 * instead of directly retrieving the extra. It is also valid for applications to
1582 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1583 * a string, not a Uri; the field here, if supplied, will always take precedence,
1584 * however.</p>
1585 *
1586 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001587 */
1588 public static final String EXTRA_REFERRER
1589 = "android.intent.extra.REFERRER";
1590
1591 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001592 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1593 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1594 * not be created, in particular when Intent extras are supplied through the
1595 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1596 * schemes.
1597 *
1598 * @see #EXTRA_REFERRER
1599 */
1600 public static final String EXTRA_REFERRER_NAME
1601 = "android.intent.extra.REFERRER_NAME";
1602
1603 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001604 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001605 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001606 * @hide
1607 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001608 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001609 public static final String EXTRA_ORIGINATING_UID
1610 = "android.intent.extra.ORIGINATING_UID";
1611
1612 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001613 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1614 * package. Tells the installer UI to skip the confirmation with the user
1615 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001616 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1617 * will no longer show an interstitial message about updating existing
1618 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001619 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001620 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001621 public static final String EXTRA_ALLOW_REPLACE
1622 = "android.intent.extra.ALLOW_REPLACE";
1623
1624 /**
1625 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1626 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1627 * return to the application the result code of the install/uninstall. The returned result
1628 * code will be {@link android.app.Activity#RESULT_OK} on success or
1629 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1630 */
1631 public static final String EXTRA_RETURN_RESULT
1632 = "android.intent.extra.RETURN_RESULT";
1633
1634 /**
1635 * Package manager install result code. @hide because result codes are not
1636 * yet ready to be exposed.
1637 */
1638 public static final String EXTRA_INSTALL_RESULT
1639 = "android.intent.extra.INSTALL_RESULT";
1640
1641 /**
1642 * Activity Action: Launch application uninstaller.
1643 * <p>
1644 * Input: The data must be a package: URI whose scheme specific part is
1645 * the package name of the current installed package to be uninstalled.
1646 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1647 * <p>
1648 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1649 * succeeded.
1650 */
1651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1652 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1653
1654 /**
msnider3c191b82017-01-23 14:23:16 -08001655 * Activity Action: Launch application uninstaller.
1656 * <p>
1657 * Input: The data must be a package: URI whose scheme specific part is
1658 * the package name of the current installed package to be uninstalled.
1659 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1660 * <p>
1661 * Output: Nothing.
1662 * </p>
1663 */
1664 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1665 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1666
1667 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001668 * Specify whether the package should be uninstalled for all users.
1669 * @hide because these should not be part of normal application flow.
1670 */
1671 public static final String EXTRA_UNINSTALL_ALL_USERS
1672 = "android.intent.extra.UNINSTALL_ALL_USERS";
1673
1674 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001675 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1676 * describing the last run version of the platform that was setup.
1677 * @hide
1678 */
1679 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1680
Svet Ganov3695b8a2015-03-24 16:30:25 -07001681 /**
1682 * Activity action: Launch UI to manage the permissions of an app.
1683 * <p>
1684 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1685 * will be managed by the launched UI.
1686 * </p>
1687 * <p>
1688 * Output: Nothing.
1689 * </p>
1690 *
1691 * @see #EXTRA_PACKAGE_NAME
1692 *
1693 * @hide
1694 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001695 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1697 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1698 "android.intent.action.MANAGE_APP_PERMISSIONS";
1699
1700 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001701 * Activity action: Launch UI to manage permissions.
1702 * <p>
1703 * Input: Nothing.
1704 * </p>
1705 * <p>
1706 * Output: Nothing.
1707 * </p>
1708 *
1709 * @hide
1710 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001711 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1713 public static final String ACTION_MANAGE_PERMISSIONS =
1714 "android.intent.action.MANAGE_PERMISSIONS";
1715
1716 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001717 * Activity action: Launch UI to review permissions for an app.
1718 * The system uses this intent if permission review for apps not
1719 * supporting the new runtime permissions model is enabled. In
1720 * this mode a permission review is required before any of the
1721 * app components can run.
1722 * <p>
1723 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1724 * permissions will be reviewed (mandatory).
1725 * </p>
1726 * <p>
1727 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1728 * be fired after the permission review (optional).
1729 * </p>
1730 * <p>
1731 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1732 * be invoked after the permission review (optional).
1733 * </p>
1734 * <p>
1735 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1736 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1737 * </p>
1738 * <p>
1739 * Output: Nothing.
1740 * </p>
1741 *
1742 * @see #EXTRA_PACKAGE_NAME
1743 * @see #EXTRA_INTENT
1744 * @see #EXTRA_REMOTE_CALLBACK
1745 * @see #EXTRA_RESULT_NEEDED
1746 *
1747 * @hide
1748 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001749 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001750 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1751 public static final String ACTION_REVIEW_PERMISSIONS =
1752 "android.intent.action.REVIEW_PERMISSIONS";
1753
1754 /**
1755 * Intent extra: A callback for reporting remote result as a bundle.
1756 * <p>
1757 * Type: IRemoteCallback
1758 * </p>
1759 *
1760 * @hide
1761 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001762 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001763 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1764
1765 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001766 * Intent extra: An app package name.
1767 * <p>
1768 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001769 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001770 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001771 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001772 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1773
1774 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001775 * Intent extra: An app split name.
1776 * <p>
1777 * Type: String
1778 * </p>
1779 * @hide
1780 */
1781 @SystemApi
1782 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1783
1784 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001785 * Intent extra: An extra for specifying whether a result is needed.
1786 * <p>
1787 * Type: boolean
1788 * </p>
1789 *
1790 * @hide
1791 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001792 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001793 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1794
1795 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001796 * Activity action: Launch UI to manage which apps have a given permission.
1797 * <p>
1798 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1799 * to which will be managed by the launched UI.
1800 * </p>
1801 * <p>
1802 * Output: Nothing.
1803 * </p>
1804 *
1805 * @see #EXTRA_PERMISSION_NAME
1806 *
1807 * @hide
1808 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001809 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001810 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1811 public static final String ACTION_MANAGE_PERMISSION_APPS =
1812 "android.intent.action.MANAGE_PERMISSION_APPS";
1813
1814 /**
1815 * Intent extra: The name of a permission.
1816 * <p>
1817 * Type: String
1818 * </p>
1819 *
1820 * @hide
1821 */
1822 @SystemApi
1823 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1824
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001825 // ---------------------------------------------------------------------
1826 // ---------------------------------------------------------------------
1827 // Standard intent broadcast actions (see action variable).
1828
1829 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001830 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1831 * <p>
1832 * For historical reasons, the name of this broadcast action refers to the power
1833 * state of the screen but it is actually sent in response to changes in the
1834 * overall interactive state of the device.
1835 * </p><p>
1836 * This broadcast is sent when the device becomes non-interactive which may have
1837 * nothing to do with the screen turning off. To determine the
1838 * actual state of the screen, use {@link android.view.Display#getState}.
1839 * </p><p>
1840 * See {@link android.os.PowerManager#isInteractive} for details.
1841 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001842 * You <em>cannot</em> receive this through components declared in
1843 * manifests, only by explicitly registering for it with
1844 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1845 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001846 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001847 * <p class="note">This is a protected intent that can only be sent
1848 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001849 */
1850 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1851 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001852
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001853 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001854 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1855 * <p>
1856 * For historical reasons, the name of this broadcast action refers to the power
1857 * state of the screen but it is actually sent in response to changes in the
1858 * overall interactive state of the device.
1859 * </p><p>
1860 * This broadcast is sent when the device becomes interactive which may have
1861 * nothing to do with the screen turning on. To determine the
1862 * actual state of the screen, use {@link android.view.Display#getState}.
1863 * </p><p>
1864 * See {@link android.os.PowerManager#isInteractive} for details.
1865 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001866 * You <em>cannot</em> receive this through components declared in
1867 * manifests, only by explicitly registering for it with
1868 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1869 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001870 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001871 * <p class="note">This is a protected intent that can only be sent
1872 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001873 */
1874 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1875 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001876
1877 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001878 * Broadcast Action: Sent after the system stops dreaming.
1879 *
1880 * <p class="note">This is a protected intent that can only be sent by the system.
1881 * It is only sent to registered receivers.</p>
1882 */
1883 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1884 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1885
1886 /**
1887 * Broadcast Action: Sent after the system starts dreaming.
1888 *
1889 * <p class="note">This is a protected intent that can only be sent by the system.
1890 * It is only sent to registered receivers.</p>
1891 */
1892 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1893 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1894
1895 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001896 * 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 -07001897 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001898 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001899 * <p class="note">This is a protected intent that can only be sent
1900 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001901 */
1902 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001903 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001904
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001905 /**
1906 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001907 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001908 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001909 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1910 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001911 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001912 * <p class="note">This is a protected intent that can only be sent
1913 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001914 */
1915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1916 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1917 /**
1918 * Broadcast Action: The time was set.
1919 */
1920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1921 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1922 /**
1923 * Broadcast Action: The date has changed.
1924 */
1925 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1926 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1927 /**
1928 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1929 * <ul>
1930 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1931 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001932 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001933 * <p class="note">This is a protected intent that can only be sent
1934 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001935 */
1936 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1937 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1938 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001939 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1940 * DNS entries should be tossed.
1941 * @hide
1942 */
1943 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1944 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1945 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001946 * Alarm Changed Action: This is broadcast when the AlarmClock
1947 * application's alarm is set or unset. It is used by the
1948 * AlarmClock application and the StatusBar service.
1949 * @hide
1950 */
1951 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1952 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001953
1954 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001955 * Broadcast Action: This is broadcast once, after the user has finished
1956 * booting, but while still in the "locked" state. It can be used to perform
1957 * application-specific initialization, such as installing alarms. You must
1958 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1959 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001960 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001961 * This broadcast is sent immediately at boot by all devices (regardless of
1962 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1963 * higher. Upon receipt of this broadcast, the user is still locked and only
1964 * device-protected storage can be accessed safely. If you want to access
1965 * credential-protected storage, you need to wait for the user to be
1966 * unlocked (typically by entering their lock pattern or PIN for the first
1967 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1968 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1969 * <p>
1970 * To receive this broadcast, your receiver component must be marked as
1971 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001972 * <p class="note">
1973 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001974 *
1975 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001976 */
1977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1978 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1979
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001980 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001981 * Broadcast Action: This is broadcast once, after the user has finished
1982 * booting. It can be used to perform application-specific initialization,
1983 * such as installing alarms. You must hold the
1984 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1985 * order to receive this broadcast.
1986 * <p>
1987 * This broadcast is sent at boot by all devices (both with and without
1988 * direct boot support). Upon receipt of this broadcast, the user is
1989 * unlocked and both device-protected and credential-protected storage can
1990 * accessed safely.
1991 * <p>
1992 * If you need to run while the user is still locked (before they've entered
1993 * their lock pattern or PIN for the first time), you can listen for the
1994 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1995 * <p class="note">
1996 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001997 */
1998 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07001999 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002000 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002001
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002002 /**
2003 * Broadcast Action: This is broadcast when a user action should request a
2004 * temporary system dialog to dismiss. Some examples of temporary system
2005 * dialogs are the notification window-shade and the recent tasks dialog.
2006 */
2007 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2008 /**
2009 * Broadcast Action: Trigger the download and eventual installation
2010 * of a package.
2011 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002012 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002013 * <p class="note">This is a protected intent that can only be sent
2014 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002015 *
2016 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002017 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002018 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002019 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2020 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2021 /**
2022 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002023 * device. The data contains the name of the package. Note that the
2024 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002025 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002026 * <ul>
2027 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2028 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2029 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2030 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002031 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002032 * <p class="note">This is a protected intent that can only be sent
2033 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002034 */
2035 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2036 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2037 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002038 * Broadcast Action: A new version of an application package has been
2039 * installed, replacing an existing version that was previously installed.
2040 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002041 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002042 * <ul>
2043 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2044 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002045 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002046 * <p class="note">This is a protected intent that can only be sent
2047 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002048 */
2049 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2050 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2051 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002052 * Broadcast Action: A new version of your application has been installed
2053 * over an existing one. This is only sent to the application that was
2054 * replaced. It does not contain any additional data; to receive it, just
2055 * use an intent filter for this action.
2056 *
2057 * <p class="note">This is a protected intent that can only be sent
2058 * by the system.
2059 */
2060 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2061 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2062 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002063 * Broadcast Action: An existing application package has been removed from
2064 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002065 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002066 * <ul>
2067 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2068 * to the package.
2069 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2070 * application -- data and code -- is being removed.
2071 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2072 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2073 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002074 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002075 * <p class="note">This is a protected intent that can only be sent
2076 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 */
2078 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2079 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2080 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002081 * Broadcast Action: An existing application package has been completely
2082 * removed from the device. The data contains the name of the package.
2083 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2084 * {@link #EXTRA_DATA_REMOVED} is true and
2085 * {@link #EXTRA_REPLACING} is false of that broadcast.
2086 *
2087 * <ul>
2088 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2089 * to the package.
2090 * </ul>
2091 *
2092 * <p class="note">This is a protected intent that can only be sent
2093 * by the system.
2094 */
2095 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2096 public static final String ACTION_PACKAGE_FULLY_REMOVED
2097 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2098 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002099 * Broadcast Action: An existing application package has been changed (for
2100 * example, a component has been enabled or disabled). The data contains
2101 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002102 * <ul>
2103 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002104 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002105 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002106 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2107 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002108 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002109 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002110 * <p class="note">This is a protected intent that can only be sent
2111 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002112 */
2113 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2114 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2115 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002116 * @hide
2117 * Broadcast Action: Ask system services if there is any reason to
2118 * restart the given package. The data contains the name of the
2119 * package.
2120 * <ul>
2121 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2122 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2123 * </ul>
2124 *
2125 * <p class="note">This is a protected intent that can only be sent
2126 * by the system.
2127 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002128 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002129 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2130 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2131 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002132 * Broadcast Action: The user has restarted a package, and all of its
2133 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002134 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002135 * be removed. Note that the restarted package does <em>not</em>
2136 * receive this broadcast.
2137 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002138 * <ul>
2139 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2140 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002141 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002142 * <p class="note">This is a protected intent that can only be sent
2143 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002144 */
2145 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2146 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2147 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002148 * Broadcast Action: The user has cleared the data of a package. This should
2149 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002150 * its persistent data is erased and this broadcast sent.
2151 * Note that the cleared package does <em>not</em>
2152 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002153 * <ul>
2154 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2155 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002156 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002157 * <p class="note">This is a protected intent that can only be sent
2158 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002159 */
2160 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2161 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2162 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002163 * Broadcast Action: Packages have been suspended.
2164 * <p>Includes the following extras:
2165 * <ul>
2166 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2167 * </ul>
2168 *
2169 * <p class="note">This is a protected intent that can only be sent
2170 * by the system. It is only sent to registered receivers.
2171 */
2172 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2173 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2174 /**
2175 * Broadcast Action: Packages have been unsuspended.
2176 * <p>Includes the following extras:
2177 * <ul>
2178 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2179 * </ul>
2180 *
2181 * <p class="note">This is a protected intent that can only be sent
2182 * by the system. It is only sent to registered receivers.
2183 */
2184 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2185 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2186 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002187 * Broadcast Action: A user ID has been removed from the system. The user
2188 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002189 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002190 * <p class="note">This is a protected intent that can only be sent
2191 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002192 */
2193 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2194 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002195
2196 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002197 * Broadcast Action: Sent to the installer package of an application when
2198 * that application is first launched (that is the first time it is moved
2199 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002200 *
2201 * <p class="note">This is a protected intent that can only be sent
2202 * by the system.
2203 */
2204 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2205 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2206
2207 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002208 * Broadcast Action: Sent to the system package verifier when a package
2209 * needs to be verified. The data contains the package URI.
2210 * <p class="note">
2211 * This is a protected intent that can only be sent by the system.
2212 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002213 */
2214 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2215 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2216
2217 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002218 * Broadcast Action: Sent to the system package verifier when a package is
2219 * verified. The data contains the package URI.
2220 * <p class="note">
2221 * This is a protected intent that can only be sent by the system.
2222 */
2223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2224 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2225
2226 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002227 * Broadcast Action: Sent to the system intent filter verifier when an
2228 * intent filter needs to be verified. The data contains the filter data
2229 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002230 * <p class="note">
2231 * This is a protected intent that can only be sent by the system.
2232 * </p>
2233 *
2234 * @hide
2235 */
2236 @SystemApi
2237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2238 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2239
2240 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002241 * Broadcast Action: Resources for a set of packages (which were
2242 * previously unavailable) are currently
2243 * available since the media on which they exist is available.
2244 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2245 * list of packages whose availability changed.
2246 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2247 * list of uids of packages whose availability changed.
2248 * Note that the
2249 * packages in this list do <em>not</em> receive this broadcast.
2250 * The specified set of packages are now available on the system.
2251 * <p>Includes the following extras:
2252 * <ul>
2253 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2254 * whose resources(were previously unavailable) are currently available.
2255 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2256 * packages whose resources(were previously unavailable)
2257 * are currently available.
2258 * </ul>
2259 *
2260 * <p class="note">This is a protected intent that can only be sent
2261 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002262 */
2263 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002264 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2265 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002266
2267 /**
2268 * Broadcast Action: Resources for a set of packages are currently
2269 * unavailable since the media on which they exist is unavailable.
2270 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2271 * list of packages whose availability changed.
2272 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2273 * list of uids of packages whose availability changed.
2274 * The specified set of packages can no longer be
2275 * launched and are practically unavailable on the system.
2276 * <p>Inclues the following extras:
2277 * <ul>
2278 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2279 * whose resources are no longer available.
2280 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2281 * whose resources are no longer available.
2282 * </ul>
2283 *
2284 * <p class="note">This is a protected intent that can only be sent
2285 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002286 */
2287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002288 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002289 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002290
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002291 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002292 * Broadcast Action: preferred activities have changed *explicitly*.
2293 *
2294 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2295 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2296 * be sent.
2297 *
2298 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2299 *
2300 * @hide
2301 */
2302 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2303 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2304 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2305
2306
2307 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002308 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002309 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002310 * This should <em>only</em> be used to determine when the wallpaper
2311 * has changed to show the new wallpaper to the user. You should certainly
2312 * never, in response to this, change the wallpaper or other attributes of
2313 * it such as the suggested size. That would be crazy, right? You'd cause
2314 * all kinds of loops, especially if other apps are doing similar things,
2315 * right? Of course. So please don't do this.
2316 *
2317 * @deprecated Modern applications should use
2318 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2319 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2320 * shown behind their UI, rather than watching for this broadcast and
2321 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002322 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002323 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002324 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2325 /**
2326 * Broadcast Action: The current device {@link android.content.res.Configuration}
2327 * (orientation, locale, etc) has changed. When such a change happens, the
2328 * UIs (view hierarchy) will need to be rebuilt based on this new
2329 * information; for the most part, applications don't need to worry about
2330 * this, because the system will take care of stopping and restarting the
2331 * application to make sure it sees the new changes. Some system code that
2332 * can not be restarted will need to watch for this action and handle it
2333 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002334 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002335 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002336 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002337 * in manifests, only by explicitly registering for it with
2338 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2339 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002340 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002341 * <p class="note">This is a protected intent that can only be sent
2342 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002343 *
2344 * @see android.content.res.Configuration
2345 */
2346 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2347 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2348 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002349 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002350 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002351 * <p class="note">This is a protected intent that can only be sent
2352 * by the system.
2353 */
2354 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2355 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2356 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002357 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2358 * charging state, level, and other information about the battery.
2359 * See {@link android.os.BatteryManager} for documentation on the
2360 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002361 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002362 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002363 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002364 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002365 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002366 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2367 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2368 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2369 * broadcasts that are sent and can be received through manifest
2370 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002371 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002372 * <p class="note">This is a protected intent that can only be sent
2373 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002374 */
2375 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2376 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2377 /**
2378 * Broadcast Action: Indicates low battery condition on the device.
2379 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002380 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002381 * <p class="note">This is a protected intent that can only be sent
2382 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002383 */
2384 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2385 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2386 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002387 * Broadcast Action: Indicates the battery is now okay after being low.
2388 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2389 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002390 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002391 * <p class="note">This is a protected intent that can only be sent
2392 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002393 */
2394 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2395 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2396 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002397 * Broadcast Action: External power has been connected to the device.
2398 * This is intended for applications that wish to register specifically to this notification.
2399 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2400 * stay active to receive this notification. This action can be used to implement actions
2401 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002402 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002403 * <p class="note">This is a protected intent that can only be sent
2404 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002405 */
2406 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002407 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002408 /**
2409 * Broadcast Action: External power has been removed from the device.
2410 * This is intended for applications that wish to register specifically to this notification.
2411 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2412 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002413 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002414 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002415 * <p class="note">This is a protected intent that can only be sent
2416 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002417 */
2418 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002419 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002420 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002421 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002422 * Broadcast Action: Device is shutting down.
2423 * This is broadcast when the device is being shut down (completely turned
2424 * off, not sleeping). Once the broadcast is complete, the final shutdown
2425 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002426 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002427 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002428 * <p class="note">This is a protected intent that can only be sent
2429 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002430 * <p>May include the following extras:
2431 * <ul>
2432 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2433 * shutdown is only for userspace processes. If not set, assumed to be false.
2434 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002435 */
2436 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002437 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002438 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002439 * Activity Action: Start this activity to request system shutdown.
2440 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002441 * to request confirmation from the user before shutting down. The optional boolean
2442 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2443 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002444 *
2445 * <p class="note">This is a protected intent that can only be sent
2446 * by the system.
2447 *
2448 * {@hide}
2449 */
2450 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2451 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002452 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002453 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002454 * <p class="note">
2455 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002456 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002457 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2458 * or above, this broadcast will no longer be delivered to any
2459 * {@link BroadcastReceiver} defined in your manifest. Instead,
2460 * apps are strongly encouraged to use the improved
2461 * {@link Context#getCacheDir()} behavior so the system can
2462 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002463 */
2464 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002465 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2467 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002468 * Broadcast Action: Indicates low storage space condition on the device no
2469 * longer exists
2470 * <p class="note">
2471 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002472 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002473 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2474 * or above, this broadcast will no longer be delivered to any
2475 * {@link BroadcastReceiver} defined in your manifest. Instead,
2476 * apps are strongly encouraged to use the improved
2477 * {@link Context#getCacheDir()} behavior so the system can
2478 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002479 */
2480 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002481 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002482 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2483 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002484 * Broadcast Action: A sticky broadcast that indicates a storage space full
2485 * condition on the device. This is intended for activities that want to be
2486 * able to fill the data partition completely, leaving only enough free
2487 * space to prevent system-wide SQLite failures.
2488 * <p class="note">
2489 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002490 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002491 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2492 * or above, this broadcast will no longer be delivered to any
2493 * {@link BroadcastReceiver} defined in your manifest. Instead,
2494 * apps are strongly encouraged to use the improved
2495 * {@link Context#getCacheDir()} behavior so the system can
2496 * automatically free up storage when needed.
2497 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002498 */
2499 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002500 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002501 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2502 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002503 * Broadcast Action: Indicates storage space full condition on the device no
2504 * longer exists.
2505 * <p class="note">
2506 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002507 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002508 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2509 * or above, this broadcast will no longer be delivered to any
2510 * {@link BroadcastReceiver} defined in your manifest. Instead,
2511 * apps are strongly encouraged to use the improved
2512 * {@link Context#getCacheDir()} behavior so the system can
2513 * automatically free up storage when needed.
2514 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002515 */
2516 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002517 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002518 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2519 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002520 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2521 * and package management should be started.
2522 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2523 * notification.
2524 */
2525 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2526 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2527 /**
2528 * Broadcast Action: The device has entered USB Mass Storage mode.
2529 * This is used mainly for the USB Settings panel.
2530 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2531 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002532 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002533 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002534 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002535 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2536
2537 /**
2538 * Broadcast Action: The device has exited USB Mass Storage mode.
2539 * This is used mainly for the USB Settings panel.
2540 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2541 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002542 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002543 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002544 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002545 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2546
2547 /**
2548 * Broadcast Action: External media has been removed.
2549 * The path to the mount point for the removed media is contained in the Intent.mData field.
2550 */
2551 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2552 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2553
2554 /**
2555 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002556 * 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 -07002557 */
2558 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2559 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2560
2561 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002562 * Broadcast Action: External media is present, and being disk-checked
2563 * 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 -08002564 */
2565 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2566 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2567
2568 /**
2569 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2570 * 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 -08002571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2573 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2574
2575 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002576 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002577 * 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 -07002578 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2579 * media was mounted read only.
2580 */
2581 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2582 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2583
2584 /**
2585 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002586 * 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 -07002587 */
2588 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2589 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2590
2591 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002592 * Broadcast Action: External media is no longer being shared via USB mass storage.
2593 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2594 *
2595 * @hide
2596 */
2597 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2598
2599 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002600 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2601 * The path to the mount point for the removed media is contained in the Intent.mData field.
2602 */
2603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2604 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2605
2606 /**
2607 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002608 * 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 -07002609 */
2610 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2611 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2612
2613 /**
2614 * Broadcast Action: User has expressed the desire to remove the external storage media.
2615 * Applications should close all files they have open within the mount point when they receive this intent.
2616 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2617 */
2618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2619 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2620
2621 /**
2622 * Broadcast Action: The media scanner has started scanning a directory.
2623 * The path to the directory being scanned is contained in the Intent.mData field.
2624 */
2625 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2626 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2627
2628 /**
2629 * Broadcast Action: The media scanner has finished scanning a directory.
2630 * The path to the scanned directory is contained in the Intent.mData field.
2631 */
2632 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2633 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2634
2635 /**
2636 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2637 * The path to the file is contained in the Intent.mData field.
2638 */
2639 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2640 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2641
2642 /**
2643 * Broadcast Action: The "Media Button" was pressed. Includes a single
2644 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2645 * caused the broadcast.
2646 */
2647 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2648 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2649
2650 /**
2651 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2652 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2653 * caused the broadcast.
2654 */
2655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2656 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2657
2658 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2659 // location; they are not general-purpose actions.
2660
2661 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002662 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002663 */
2664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2665 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2666 "android.intent.action.GTALK_CONNECTED";
2667
2668 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002669 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002670 */
2671 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2672 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2673 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002674
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002675 /**
2676 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002677 */
2678 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2679 public static final String ACTION_INPUT_METHOD_CHANGED =
2680 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002681
2682 /**
2683 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2684 * more radios have been turned off or on. The intent will have the following extra value:</p>
2685 * <ul>
2686 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2687 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2688 * turned off</li>
2689 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002690 *
Peng Xua35b5532016-01-20 00:05:45 -08002691 * <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 -07002692 */
2693 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2694 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2695
2696 /**
2697 * Broadcast Action: Some content providers have parts of their namespace
2698 * where they publish new events or items that the user may be especially
2699 * interested in. For these things, they may broadcast this action when the
2700 * set of interesting items change.
2701 *
2702 * For example, GmailProvider sends this notification when the set of unread
2703 * mail in the inbox changes.
2704 *
2705 * <p>The data of the intent identifies which part of which provider
2706 * changed. When queried through the content resolver, the data URI will
2707 * return the data set in question.
2708 *
2709 * <p>The intent will have the following extra values:
2710 * <ul>
2711 * <li><em>count</em> - The number of items in the data set. This is the
2712 * same as the number of items in the cursor returned by querying the
2713 * data URI. </li>
2714 * </ul>
2715 *
2716 * This intent will be sent at boot (if the count is non-zero) and when the
2717 * data set changes. It is possible for the data set to change without the
2718 * count changing (for example, if a new unread message arrives in the same
2719 * sync operation in which a message is archived). The phone should still
2720 * ring/vibrate/etc as normal in this case.
2721 */
2722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2723 public static final String ACTION_PROVIDER_CHANGED =
2724 "android.intent.action.PROVIDER_CHANGED";
2725
2726 /**
2727 * Broadcast Action: Wired Headset plugged in or unplugged.
2728 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002729 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2730 * and documentation.
2731 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002732 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002733 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002734 */
2735 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002736 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002737
2738 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002739 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2740 * <ul>
2741 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2742 * </ul>
2743 *
2744 * <p class="note">This is a protected intent that can only be sent
2745 * by the system.
2746 *
2747 * @hide
2748 */
2749 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2750 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2751 = "android.intent.action.ADVANCED_SETTINGS";
2752
2753 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002754 * Broadcast Action: Sent after application restrictions are changed.
2755 *
2756 * <p class="note">This is a protected intent that can only be sent
2757 * by the system.</p>
2758 */
2759 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2760 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2761 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2762
2763 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002764 * Broadcast Action: An outgoing call is about to be placed.
2765 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002766 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002768 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002769 * the phone number originally intended to be dialed.</li>
2770 * </ul>
2771 * <p>Once the broadcast is finished, the resultData is used as the actual
2772 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002773 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002774 * outgoing call in turn: for example, a parental control application
2775 * might verify that the user is authorized to place the call at that
2776 * time, then a number-rewriting application might add an area code if
2777 * one was not specified.</p>
2778 * <p>For consistency, any receiver whose purpose is to prohibit phone
2779 * calls should have a priority of 0, to ensure it will see the final
2780 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002781 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002782 * should have a positive priority.
2783 * Negative priorities are reserved for the system for this broadcast;
2784 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002785 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2786 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002787 * <p>Emergency calls cannot be intercepted using this mechanism, and
2788 * other calls cannot be modified to call emergency numbers using this
2789 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002790 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2791 * call to use their own service instead. Those apps should first prevent
2792 * the call from being placed by setting resultData to <code>null</code>
2793 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002794 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002795 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2796 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002797 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002798 * <p class="note">This is a protected intent that can only be sent
2799 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002800 */
2801 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2802 public static final String ACTION_NEW_OUTGOING_CALL =
2803 "android.intent.action.NEW_OUTGOING_CALL";
2804
2805 /**
2806 * Broadcast Action: Have the device reboot. This is only for use by
2807 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002808 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002809 * <p class="note">This is a protected intent that can only be sent
2810 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002811 */
2812 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2813 public static final String ACTION_REBOOT =
2814 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002815
Wei Huang97ecc9c2009-05-11 17:44:20 -07002816 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002817 * Broadcast Action: A sticky broadcast for changes in the physical
2818 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002819 *
2820 * <p>The intent will have the following extra values:
2821 * <ul>
2822 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002823 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002824 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002825 * <p>This is intended for monitoring the current physical dock state.
2826 * See {@link android.app.UiModeManager} for the normal API dealing with
2827 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002828 */
2829 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2830 public static final String ACTION_DOCK_EVENT =
2831 "android.intent.action.DOCK_EVENT";
2832
2833 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002834 * Broadcast Action: A broadcast when idle maintenance can be started.
2835 * This means that the user is not interacting with the device and is
2836 * not expected to do so soon. Typical use of the idle maintenance is
2837 * to perform somehow expensive tasks that can be postponed at a moment
2838 * when they will not degrade user experience.
2839 * <p>
2840 * <p class="note">In order to keep the device responsive in case of an
2841 * unexpected user interaction, implementations of a maintenance task
2842 * should be interruptible. In such a scenario a broadcast with action
2843 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2844 * should not do the maintenance work in
2845 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2846 * maintenance service by {@link Context#startService(Intent)}. Also
2847 * you should hold a wake lock while your maintenance service is running
2848 * to prevent the device going to sleep.
2849 * </p>
2850 * <p>
2851 * <p class="note">This is a protected intent that can only be sent by
2852 * the system.
2853 * </p>
2854 *
2855 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002856 *
2857 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002858 */
2859 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2860 public static final String ACTION_IDLE_MAINTENANCE_START =
2861 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2862
2863 /**
2864 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2865 * This means that the user was not interacting with the device as a result
2866 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2867 * was sent and now the user started interacting with the device. Typical
2868 * use of the idle maintenance is to perform somehow expensive tasks that
2869 * can be postponed at a moment when they will not degrade user experience.
2870 * <p>
2871 * <p class="note">In order to keep the device responsive in case of an
2872 * unexpected user interaction, implementations of a maintenance task
2873 * should be interruptible. Hence, on receiving a broadcast with this
2874 * action, the maintenance task should be interrupted as soon as possible.
2875 * In other words, you should not do the maintenance work in
2876 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2877 * maintenance service that was started on receiving of
2878 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2879 * lock you acquired when your maintenance service started.
2880 * </p>
2881 * <p class="note">This is a protected intent that can only be sent
2882 * by the system.
2883 *
2884 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002885 *
2886 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002887 */
2888 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2889 public static final String ACTION_IDLE_MAINTENANCE_END =
2890 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2891
2892 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002893 * Broadcast Action: a remote intent is to be broadcasted.
2894 *
2895 * A remote intent is used for remote RPC between devices. The remote intent
2896 * is serialized and sent from one device to another device. The receiving
2897 * device parses the remote intent and broadcasts it. Note that anyone can
2898 * broadcast a remote intent. However, if the intent receiver of the remote intent
2899 * does not trust intent broadcasts from arbitrary intent senders, it should require
2900 * the sender to hold certain permissions so only trusted sender's broadcast will be
2901 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002902 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002903 */
2904 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002905 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002906
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002907 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002908 * Broadcast Action: This is broadcast once when the user is booting after a
2909 * system update. It can be used to perform cleanup or upgrades after a
2910 * system update.
2911 * <p>
2912 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2913 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2914 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2915 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002916 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002917 * @hide
2918 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002919 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002920 public static final String ACTION_PRE_BOOT_COMPLETED =
2921 "android.intent.action.PRE_BOOT_COMPLETED";
2922
Amith Yamasani13593602012-03-22 16:16:17 -07002923 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002924 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002925 * on restricted users. The broadcast intent contains an extra
2926 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2927 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2928 * String[] depending on the restriction type.<p/>
2929 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002930 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2931 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2932 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002933 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2934 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002935 * @see RestrictionEntry
2936 */
2937 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2938 "android.intent.action.GET_RESTRICTION_ENTRIES";
2939
2940 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002941 * Sent the first time a user is starting, to allow system apps to
2942 * perform one time initialization. (This will not be seen by third
2943 * party applications because a newly initialized user does not have any
2944 * third party applications installed for it.) This is sent early in
2945 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002946 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2947 * broadcast, since it is part of a visible user interaction; be as quick
2948 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002949 */
2950 public static final String ACTION_USER_INITIALIZE =
2951 "android.intent.action.USER_INITIALIZE";
2952
2953 /**
2954 * Sent when a user switch is happening, causing the process's user to be
2955 * brought to the foreground. This is only sent to receivers registered
2956 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2957 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002958 * foreground. This is sent as a foreground
2959 * broadcast, since it is part of a visible user interaction; be as quick
2960 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002961 */
2962 public static final String ACTION_USER_FOREGROUND =
2963 "android.intent.action.USER_FOREGROUND";
2964
2965 /**
2966 * Sent when a user switch is happening, causing the process's user to be
2967 * sent to the background. This is only sent to receivers registered
2968 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2969 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002970 * background. This is sent as a foreground
2971 * broadcast, since it is part of a visible user interaction; be as quick
2972 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002973 */
2974 public static final String ACTION_USER_BACKGROUND =
2975 "android.intent.action.USER_BACKGROUND";
2976
2977 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002978 * Broadcast sent to the system when a user is added. Carries an extra
2979 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2980 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002981 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002982 * @hide
2983 */
2984 public static final String ACTION_USER_ADDED =
2985 "android.intent.action.USER_ADDED";
2986
2987 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002988 * Broadcast sent by the system when a user is started. Carries an extra
2989 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002990 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002991 * that has been started. This is sent as a foreground
2992 * broadcast, since it is part of a visible user interaction; be as quick
2993 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002994 * @hide
2995 */
2996 public static final String ACTION_USER_STARTED =
2997 "android.intent.action.USER_STARTED";
2998
2999 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003000 * Broadcast sent when a user is in the process of starting. Carries an extra
3001 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3002 * sent to registered receivers, not manifest receivers. It is sent to all
3003 * users (including the one that is being started). You must hold
3004 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3005 * this broadcast. This is sent as a background broadcast, since
3006 * its result is not part of the primary UX flow; to safely keep track of
3007 * started/stopped state of a user you can use this in conjunction with
3008 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3009 * other user state broadcasts since those are foreground broadcasts so can
3010 * execute in a different order.
3011 * @hide
3012 */
3013 public static final String ACTION_USER_STARTING =
3014 "android.intent.action.USER_STARTING";
3015
3016 /**
3017 * Broadcast sent when a user is going to be stopped. Carries an extra
3018 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3019 * sent to registered receivers, not manifest receivers. It is sent to all
3020 * users (including the one that is being stopped). You must hold
3021 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3022 * this broadcast. The user will not stop until all receivers have
3023 * handled the broadcast. This is sent as a background broadcast, since
3024 * its result is not part of the primary UX flow; to safely keep track of
3025 * started/stopped state of a user you can use this in conjunction with
3026 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3027 * other user state broadcasts since those are foreground broadcasts so can
3028 * execute in a different order.
3029 * @hide
3030 */
3031 public static final String ACTION_USER_STOPPING =
3032 "android.intent.action.USER_STOPPING";
3033
3034 /**
3035 * Broadcast sent to the system when a user is stopped. Carries an extra
3036 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3037 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3038 * specific package. This is only sent to registered receivers, not manifest
3039 * receivers. It is sent to all running users <em>except</em> the one that
3040 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003041 * @hide
3042 */
3043 public static final String ACTION_USER_STOPPED =
3044 "android.intent.action.USER_STOPPED";
3045
3046 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003047 * 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 -07003048 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003049 * one that has been removed. The user will not be completely removed until all receivers have
3050 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003051 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003052 * @hide
3053 */
3054 public static final String ACTION_USER_REMOVED =
3055 "android.intent.action.USER_REMOVED";
3056
3057 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003058 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003059 * the userHandle of the user to become the current one. This is only sent to
3060 * registered receivers, not manifest receivers. It is sent to all running users.
3061 * You must hold
3062 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003063 * @hide
3064 */
3065 public static final String ACTION_USER_SWITCHED =
3066 "android.intent.action.USER_SWITCHED";
3067
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003068 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003069 * Broadcast Action: Sent when the credential-encrypted private storage has
3070 * become unlocked for the target user. This is only sent to registered
3071 * receivers, not manifest receivers.
3072 */
3073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3074 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3075
3076 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003077 * Broadcast sent to the system when a user's information changes. Carries an extra
3078 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003079 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003080 * @hide
3081 */
3082 public static final String ACTION_USER_INFO_CHANGED =
3083 "android.intent.action.USER_INFO_CHANGED";
3084
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003085 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003086 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3087 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003088 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3089 * that need to display merged content across both primary and managed profiles need to
3090 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003091 * not manifest receivers.
3092 */
3093 public static final String ACTION_MANAGED_PROFILE_ADDED =
3094 "android.intent.action.MANAGED_PROFILE_ADDED";
3095
3096 /**
3097 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003098 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3099 * Only applications (for example Launchers) that need to display merged content across both
3100 * primary and managed profiles need to worry about this broadcast. This is only sent to
3101 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003102 */
3103 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3104 "android.intent.action.MANAGED_PROFILE_REMOVED";
3105
3106 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003107 * Broadcast sent to the primary user when the credential-encrypted private storage for
3108 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3109 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3110 * Launchers) that need to display merged content across both primary and managed profiles
3111 * need to worry about this broadcast. This is only sent to registered receivers,
3112 * not manifest receivers.
3113 */
3114 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3115 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3116
3117 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003118 * Broadcast sent to the primary user when an associated managed profile has become available.
3119 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003120 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3121 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3122 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003123 */
Rubin Xue95057a2016-04-01 16:49:25 +01003124 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3125 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3126
3127 /**
3128 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3129 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3130 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3131 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3132 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3133 */
3134 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3135 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003136
3137 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003138 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3139 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3140 * the device was locked or unlocked.
3141 *
3142 * This is only sent to registered receivers.
3143 *
3144 * @hide
3145 */
3146 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3147 "android.intent.action.DEVICE_LOCKED_CHANGED";
3148
3149 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003150 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3151 */
3152 public static final String ACTION_QUICK_CLOCK =
3153 "android.intent.action.QUICK_CLOCK";
3154
Michael Wright0087a142013-02-05 16:29:39 -08003155 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003156 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003157 * @hide
3158 */
3159 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003160 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003161
Justin Kohd378ad72013-04-01 12:18:26 -07003162 /**
3163 * Broadcast Action: A global button was pressed. Includes a single
3164 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3165 * caused the broadcast.
3166 * @hide
3167 */
3168 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3169
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003170 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003171 * Broadcast Action: Sent when media resource is granted.
3172 * <p>
3173 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3174 * granted.
3175 * </p>
3176 * <p class="note">
3177 * This is a protected intent that can only be sent by the system.
3178 * </p>
3179 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003180 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003181 * </p>
3182 *
3183 * @hide
3184 */
3185 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3186 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3187
3188 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003189 * Broadcast Action: An overlay package has been installed. The data
3190 * contains the name of the added overlay package.
3191 * @hide
3192 */
3193 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3194
3195 /**
3196 * Broadcast Action: An overlay package has changed. The data contains the
3197 * name of the overlay package which has changed. This is broadcast on all
3198 * changes to the OverlayInfo returned by {@link
3199 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3200 * most common change is a state change that will change whether the
3201 * overlay is enabled or not.
3202 * @hide
3203 */
3204 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3205
3206 /**
3207 * Broadcast Action: An overlay package has been removed. The data contains
3208 * the name of the overlay package which has been removed.
3209 * @hide
3210 */
3211 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3212
3213 /**
3214 * Broadcast Action: The order of a package's list of overlay packages has
3215 * changed. The data contains the package name of the overlay package that
3216 * had its position in the list adjusted.
3217 * @hide
3218 */
3219 public static final String
3220 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3221
3222 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003223 * Activity Action: Allow the user to select and return one or more existing
3224 * documents. When invoked, the system will display the various
3225 * {@link DocumentsProvider} instances installed on the device, letting the
3226 * user interactively navigate through them. These documents include local
3227 * media, such as photos and video, and documents provided by installed
3228 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003229 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003230 * Each document is represented as a {@code content://} URI backed by a
3231 * {@link DocumentsProvider}, which can be opened as a stream with
3232 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3233 * {@link android.provider.DocumentsContract.Document} metadata.
3234 * <p>
3235 * All selected documents are returned to the calling application with
3236 * persistable read and write permission grants. If you want to maintain
3237 * access to the documents across device reboots, you need to explicitly
3238 * take the persistable permissions using
3239 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3240 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003241 * Callers must indicate the acceptable document MIME types through
3242 * {@link #setType(String)}. For example, to select photos, use
3243 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3244 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3245 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003246 * <p>
3247 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003248 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3249 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003250 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003251 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3252 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003253 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003254 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003255 * Callers can set a document URI through
3256 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3257 * location of documents navigator. System will do its best to launch the
3258 * navigator in the specified document if it's a folder, or the folder that
3259 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003260 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003261 * Output: The URI of the item that was picked, returned in
3262 * {@link #getData()}. This must be a {@code content://} URI so that any
3263 * receiver can access it. If multiple documents were selected, they are
3264 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003265 *
3266 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003267 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003268 * @see #ACTION_CREATE_DOCUMENT
3269 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003270 */
3271 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3272 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3273
3274 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003275 * Activity Action: Allow the user to create a new document. When invoked,
3276 * the system will display the various {@link DocumentsProvider} instances
3277 * installed on the device, letting the user navigate through them. The
3278 * returned document may be a newly created document with no content, or it
3279 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003280 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003281 * Each document is represented as a {@code content://} URI backed by a
3282 * {@link DocumentsProvider}, which can be opened as a stream with
3283 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3284 * {@link android.provider.DocumentsContract.Document} metadata.
3285 * <p>
3286 * Callers must indicate the concrete MIME type of the document being
3287 * created by setting {@link #setType(String)}. This MIME type cannot be
3288 * changed after the document is created.
3289 * <p>
3290 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3291 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003292 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003293 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3294 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003295 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003296 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003297 * Callers can set a document URI through
3298 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3299 * location of documents navigator. System will do its best to launch the
3300 * navigator in the specified document if it's a folder, or the folder that
3301 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003302 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003303 * Output: The URI of the item that was created. This must be a
3304 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003305 *
3306 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003307 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003308 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003309 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003310 */
3311 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3312 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3313
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003314 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003315 * Activity Action: Allow the user to pick a directory subtree. When
3316 * invoked, the system will display the various {@link DocumentsProvider}
3317 * instances installed on the device, letting the user navigate through
3318 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003319 * <p>
3320 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003321 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3322 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3323 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003324 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003325 * Callers can set a document URI through
3326 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3327 * location of documents navigator. System will do its best to launch the
3328 * navigator in the specified document if it's a folder, or the folder that
3329 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003330 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003331 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003332 *
3333 * @see DocumentsContract
3334 */
3335 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003336 public static final String
3337 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003338
Felipe Lemec7b1f892016-01-15 15:02:31 -08003339 /**
Peng Xua35b5532016-01-20 00:05:45 -08003340 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3341 * exisiting sensor being disconnected.
3342 *
3343 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3344 *
3345 * {@hide}
3346 */
3347 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3348 public static final String
3349 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3350
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003351 /**
3352 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3353 *
3354 * {@hide}
3355 */
3356 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003357 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3358
Christopher Tate6597e342015-02-17 12:15:25 -08003359 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003360 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3361 * is about to be performed.
3362 * @hide
3363 */
3364 @SystemApi
3365 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3366 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3367 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3368
3369 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003370 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3371 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3372 *
3373 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3374 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003375 * @hide
3376 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003377 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003378 public static final String EXTRA_FORCE_MASTER_CLEAR =
3379 "android.intent.extra.FORCE_MASTER_CLEAR";
3380
3381 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003382 * A broadcast action to trigger a factory reset.
3383 *
3384 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3385 *
3386 * <p>Not for use by third-party applications.
3387 *
3388 * @see #EXTRA_FORCE_MASTER_CLEAR
3389 *
3390 * {@hide}
3391 */
3392 @SystemApi
3393 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3394 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3395
3396 /**
3397 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3398 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3399 *
3400 * <p>Not for use by third-party applications.
3401 *
3402 * @hide
3403 */
3404 @SystemApi
3405 public static final String EXTRA_FORCE_FACTORY_RESET =
3406 "android.intent.extra.FORCE_FACTORY_RESET";
3407
3408 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003409 * Broadcast action: report that a settings element is being restored from backup. The intent
3410 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3411 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3412 * is the value of that settings entry prior to the restore operation. All of these values are
3413 * represented as strings.
3414 *
3415 * <p>This broadcast is sent only for settings provider entries known to require special handling
3416 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3417 * the provider's backup agent implementation.
3418 *
3419 * @see #EXTRA_SETTING_NAME
3420 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3421 * @see #EXTRA_SETTING_NEW_VALUE
3422 * {@hide}
3423 */
3424 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3425
3426 /** {@hide} */
3427 public static final String EXTRA_SETTING_NAME = "setting_name";
3428 /** {@hide} */
3429 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3430 /** {@hide} */
3431 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3432
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003433 /**
3434 * Activity Action: Process a piece of text.
3435 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3436 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3437 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3438 */
3439 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3440 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003441
3442 /**
3443 * Broadcast Action: The sim card state has changed.
3444 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3445 * because TelephonyIntents is an internal class.
3446 * @hide
3447 */
3448 @SystemApi
3449 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3450 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3451
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003452 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003453 * The name of the extra used to define the text to be processed, as a
3454 * CharSequence. Note that this may be a styled CharSequence, so you must use
3455 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003456 */
3457 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3458 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003459 * 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 +00003460 */
3461 public static final String EXTRA_PROCESS_TEXT_READONLY =
3462 "android.intent.extra.PROCESS_TEXT_READONLY";
3463
Bryce Leebc58f592015-09-25 16:43:01 -07003464 /**
3465 * Broadcast action: reports when a new thermal event has been reached. When the device
3466 * is reaching its maximum temperatue, the thermal level reported
3467 * {@hide}
3468 */
3469 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3470 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3471
3472 /** {@hide} */
3473 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3474
3475 /**
3476 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003477 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003478 * {@hide}
3479 */
3480 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3481
3482 /**
3483 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003484 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003485 * {@hide}
3486 */
3487 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3488
3489 /**
3490 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003491 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003492 * {@hide}
3493 */
3494 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3495
3496
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003497 // ---------------------------------------------------------------------
3498 // ---------------------------------------------------------------------
3499 // Standard intent categories (see addCategory()).
3500
3501 /**
3502 * Set if the activity should be an option for the default action
3503 * (center press) to perform on a piece of data. Setting this will
3504 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003505 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003506 * Intent when initiating an action -- it is for use in intent filters
3507 * specified in packages.
3508 */
3509 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3510 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3511 /**
3512 * Activities that can be safely invoked from a browser must support this
3513 * category. For example, if the user is viewing a web page or an e-mail
3514 * and clicks on a link in the text, the Intent generated execute that
3515 * link will require the BROWSABLE category, so that only activities
3516 * supporting this category will be considered as possible actions. By
3517 * supporting this category, you are promising that there is nothing
3518 * damaging (without user intervention) that can happen by invoking any
3519 * matching Intent.
3520 */
3521 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3522 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3523 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003524 * Categories for activities that can participate in voice interaction.
3525 * An activity that supports this category must be prepared to run with
3526 * no UI shown at all (though in some case it may have a UI shown), and
3527 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3528 */
3529 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3530 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3531 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003532 * Set if the activity should be considered as an alternative action to
3533 * the data the user is currently viewing. See also
3534 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3535 * applies to the selection in a list of items.
3536 *
3537 * <p>Supporting this category means that you would like your activity to be
3538 * displayed in the set of alternative things the user can do, usually as
3539 * part of the current activity's options menu. You will usually want to
3540 * include a specific label in the &lt;intent-filter&gt; of this action
3541 * describing to the user what it does.
3542 *
3543 * <p>The action of IntentFilter with this category is important in that it
3544 * describes the specific action the target will perform. This generally
3545 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3546 * a specific name such as "com.android.camera.action.CROP. Only one
3547 * alternative of any particular action will be shown to the user, so using
3548 * a specific action like this makes sure that your alternative will be
3549 * displayed while also allowing other applications to provide their own
3550 * overrides of that particular action.
3551 */
3552 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3553 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3554 /**
3555 * Set if the activity should be considered as an alternative selection
3556 * action to the data the user has currently selected. This is like
3557 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3558 * of items from which the user can select, giving them alternatives to the
3559 * default action that will be performed on it.
3560 */
3561 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3562 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3563 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003564 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003565 */
3566 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3567 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3568 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003569 * Should be displayed in the top-level launcher.
3570 */
3571 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3572 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3573 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003574 * Indicates an activity optimized for Leanback mode, and that should
3575 * be displayed in the Leanback launcher.
3576 */
3577 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3578 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3579 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003580 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3581 * @hide
3582 */
3583 @SystemApi
3584 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3585 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003586 * Provides information about the package it is in; typically used if
3587 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3588 * a front-door to the user without having to be shown in the all apps list.
3589 */
3590 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3591 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3592 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003593 * This is the home activity, that is the first activity that is displayed
3594 * when the device boots.
3595 */
3596 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3597 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3598 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003599 * This is the home activity that is displayed when the device is finished setting up and ready
3600 * for use.
3601 * @hide
3602 */
3603 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3604 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3605 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003606 * This is the setup wizard activity, that is the first activity that is displayed
3607 * when the user sets up the device for the first time.
3608 * @hide
3609 */
3610 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3611 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3612 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003613 * This activity is a preference panel.
3614 */
3615 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3616 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3617 /**
3618 * This activity is a development preference panel.
3619 */
3620 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3621 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3622 /**
3623 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003624 */
3625 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3626 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3627 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003628 * This activity allows the user to browse and download new applications.
3629 */
3630 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3631 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3632 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003633 * This activity may be exercised by the monkey or other automated test tools.
3634 */
3635 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3636 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3637 /**
3638 * To be used as a test (not part of the normal user experience).
3639 */
3640 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3641 /**
3642 * To be used as a unit test (run through the Test Harness).
3643 */
3644 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3645 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003646 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003647 * experience).
3648 */
3649 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003650
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003651 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003652 * Used to indicate that an intent only wants URIs that can be opened with
3653 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3654 * must support at least the columns defined in {@link OpenableColumns} when
3655 * queried.
3656 *
3657 * @see #ACTION_GET_CONTENT
3658 * @see #ACTION_OPEN_DOCUMENT
3659 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003660 */
3661 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3662 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3663
3664 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003665 * Used to indicate that an intent filter can accept files which are not necessarily
3666 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3667 * at least streamable via
3668 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3669 * using one of the stream types exposed via
3670 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3671 *
3672 * @see #ACTION_SEND
3673 * @see #ACTION_SEND_MULTIPLE
3674 */
3675 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3676 public static final String CATEGORY_TYPED_OPENABLE =
3677 "android.intent.category.TYPED_OPENABLE";
3678
3679 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003680 * To be used as code under test for framework instrumentation tests.
3681 */
3682 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3683 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003684 /**
3685 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003686 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3687 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003688 */
3689 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3690 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3691 /**
3692 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003693 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3694 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003695 */
3696 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3697 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003698 /**
3699 * An activity to run when device is inserted into a analog (low end) dock.
3700 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3701 * information, see {@link android.app.UiModeManager}.
3702 */
3703 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3704 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3705
3706 /**
3707 * An activity to run when device is inserted into a digital (high end) dock.
3708 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3709 * information, see {@link android.app.UiModeManager}.
3710 */
3711 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3712 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003713
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003714 /**
3715 * Used to indicate that the activity can be used in a car environment.
3716 */
3717 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3718 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3719
Zak Cohendb6ca492017-01-26 14:09:00 -08003720 /**
3721 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3722 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3723 * information, see {@link android.app.UiModeManager}.
3724 */
3725 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3726 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003727 // ---------------------------------------------------------------------
3728 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003729 // Application launch intent categories (see addCategory()).
3730
3731 /**
3732 * Used with {@link #ACTION_MAIN} to launch the browser application.
3733 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003734 * <p>NOTE: This should not be used as the primary key of an Intent,
3735 * since it will not result in the app launching with the correct
3736 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003737 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003738 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003739 */
3740 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3741 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3742
3743 /**
3744 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3745 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003746 * <p>NOTE: This should not be used as the primary key of an Intent,
3747 * since it will not result in the app launching with the correct
3748 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003749 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003750 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003751 */
3752 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3753 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3754
3755 /**
3756 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3757 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003758 * <p>NOTE: This should not be used as the primary key of an Intent,
3759 * since it will not result in the app launching with the correct
3760 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003761 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003762 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003763 */
3764 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3765 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3766
3767 /**
3768 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3769 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003770 * <p>NOTE: This should not be used as the primary key of an Intent,
3771 * since it will not result in the app launching with the correct
3772 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003773 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003774 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003775 */
3776 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3777 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3778
3779 /**
3780 * Used with {@link #ACTION_MAIN} to launch the email application.
3781 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003782 * <p>NOTE: This should not be used as the primary key of an Intent,
3783 * since it will not result in the app launching with the correct
3784 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003785 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003786 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003787 */
3788 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3789 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3790
3791 /**
3792 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3793 * The activity should be able to view and manipulate image and video files
3794 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003795 * <p>NOTE: This should not be used as the primary key of an Intent,
3796 * since it will not result in the app launching with the correct
3797 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003798 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003799 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003800 */
3801 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3802 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3803
3804 /**
3805 * Used with {@link #ACTION_MAIN} to launch the maps application.
3806 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003807 * <p>NOTE: This should not be used as the primary key of an Intent,
3808 * since it will not result in the app launching with the correct
3809 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003810 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003811 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003812 */
3813 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3814 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3815
3816 /**
3817 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3818 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003819 * <p>NOTE: This should not be used as the primary key of an Intent,
3820 * since it will not result in the app launching with the correct
3821 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003822 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003823 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003824 */
3825 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3826 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3827
3828 /**
3829 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003830 * The activity should be able to play, browse, or manipulate music files
3831 * stored on the device.
3832 * <p>NOTE: This should not be used as the primary key of an Intent,
3833 * since it will not result in the app launching with the correct
3834 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003835 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003836 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003837 */
3838 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3839 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3840
3841 // ---------------------------------------------------------------------
3842 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003843 // Standard extra data keys.
3844
3845 /**
3846 * The initial data to place in a newly created record. Use with
3847 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3848 * fields as would be given to the underlying ContentProvider.insert()
3849 * call.
3850 */
3851 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3852
3853 /**
3854 * A constant CharSequence that is associated with the Intent, used with
3855 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3856 * this may be a styled CharSequence, so you must use
3857 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3858 * retrieve it.
3859 */
3860 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3861
3862 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003863 * A constant String that is associated with the Intent, used with
3864 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3865 * as HTML formatted text. Note that you <em>must</em> also supply
3866 * {@link #EXTRA_TEXT}.
3867 */
3868 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3869
3870 /**
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003871 * A content: URI holding a stream of data associated with the Intent, used
3872 * with {@link #ACTION_SEND} to supply the data being sent.
3873 * <p>
3874 * Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this value
3875 * will be automatically promoted to {@link Intent#setClipData(ClipData)}
3876 * when that value is not already defined.
3877 * <p>
3878 * Starting in {@link android.os.Build.VERSION_CODES#O} this value will be
3879 * automatically demoted from {@link Intent#getClipData()} when this value
3880 * is not already defined.
3881 *
3882 * @deprecated apps should use {@link Intent#setClipData(ClipData)} and
3883 * {@link Intent#getClipData()} instead of this extra, since
3884 * only those APIs can extend temporary permission grants to the
3885 * underlying resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003886 */
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003887 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003888 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3889
3890 /**
3891 * A String[] holding e-mail addresses that should be delivered to.
3892 */
3893 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3894
3895 /**
3896 * A String[] holding e-mail addresses that should be carbon copied.
3897 */
3898 public static final String EXTRA_CC = "android.intent.extra.CC";
3899
3900 /**
3901 * A String[] holding e-mail addresses that should be blind carbon copied.
3902 */
3903 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3904
3905 /**
3906 * A constant string holding the desired subject line of a message.
3907 */
3908 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3909
3910 /**
3911 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003912 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003913 */
3914 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3915
3916 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003917 * An int representing the user id to be used.
3918 *
3919 * @hide
3920 */
3921 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3922
3923 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003924 * An int representing the task id to be retrieved. This is used when a launch from recents is
3925 * intercepted by another action such as credentials confirmation to remember which task should
3926 * be resumed when complete.
3927 *
3928 * @hide
3929 */
3930 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3931
3932 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003933 * An Intent[] describing additional, alternate choices you would like shown with
3934 * {@link #ACTION_CHOOSER}.
3935 *
3936 * <p>An app may be capable of providing several different payload types to complete a
3937 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3938 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3939 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3940 * photo data or a hosted link where the photos can be viewed.</p>
3941 *
3942 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3943 * first/primary/preferred intent in the set. Additional intents specified in
3944 * this extra are ordered; by default intents that appear earlier in the array will be
3945 * preferred over intents that appear later in the array as matches for the same
3946 * target component. To alter this preference, a calling app may also supply
3947 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3948 */
3949 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3950
3951 /**
Adam Powell52c39212016-04-07 15:14:18 -07003952 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3953 * and omitted from a list of components presented to the user.
3954 *
3955 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3956 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3957 * from your own package or other apps from your organization if the idea of sending to those
3958 * targets would be redundant with other app functionality. Filtered components will not
3959 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3960 */
3961 public static final String EXTRA_EXCLUDE_COMPONENTS
3962 = "android.intent.extra.EXCLUDE_COMPONENTS";
3963
3964 /**
3965 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3966 * describing additional high-priority deep-link targets for the chooser to present to the user.
3967 *
3968 * <p>Targets provided in this way will be presented inline with all other targets provided
3969 * by services from other apps. They will be prioritized before other service targets, but
3970 * after those targets provided by sources that the user has manually pinned to the front.</p>
3971 *
3972 * @see #ACTION_CHOOSER
3973 */
3974 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3975
3976 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003977 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3978 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3979 *
3980 * <p>An app preparing an action for another app to complete may wish to allow the user to
3981 * disambiguate between several options for completing the action based on the chosen target
3982 * or otherwise refine the action before it is invoked.
3983 * </p>
3984 *
3985 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3986 * <ul>
3987 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3988 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3989 * chosen target beyond the first</li>
3990 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3991 * should fill in and send once the disambiguation is complete</li>
3992 * </ul>
3993 */
3994 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3995 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3996
3997 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003998 * An {@code ArrayList} of {@code String} annotations describing content for
3999 * {@link #ACTION_CHOOSER}.
4000 *
4001 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4002 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4003 *
4004 * <p>Annotations should describe the major components or topics of the content. It is up to
4005 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4006 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4007 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4008 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4009 * use the following annotations when applicable:</p>
4010 * <ul>
4011 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4012 * health & beauty, and office supplies.</li>
4013 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4014 * happy, and sad.</li>
4015 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4016 * face, finger, standing, and walking.</li>
4017 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4018 * child, and baby.</li>
4019 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4020 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4021 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4022 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4023 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4024 * flowers.</li>
4025 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4026 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4027 * sunglasses, jewelry, handbags and clothing.</li>
4028 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4029 * paper, and silk.</li>
4030 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4031 * cars, and boats.</li>
4032 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4033 * posters.</li>
4034 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4035 * and designs of houses.</li>
4036 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4037 * Christmas and Thanksgiving.</li>
4038 * </ul>
4039 */
4040 public static final String EXTRA_CONTENT_ANNOTATIONS
4041 = "android.intent.extra.CONTENT_ANNOTATIONS";
4042
4043 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004044 * A {@link ResultReceiver} used to return data back to the sender.
4045 *
4046 * <p>Used to complete an app-specific
4047 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4048 *
4049 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4050 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4051 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4052 * when the user selects a target component from the chooser. It is up to the recipient
4053 * to send a result to this ResultReceiver to signal that disambiguation is complete
4054 * and that the chooser should invoke the user's choice.</p>
4055 *
4056 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4057 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4058 * to match and fill in the final Intent or ChooserTarget before starting it.
4059 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4060 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4061 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4062 *
4063 * <p>The result code passed to the ResultReceiver should be
4064 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4065 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4066 * the chooser should finish without starting a target.</p>
4067 */
4068 public static final String EXTRA_RESULT_RECEIVER
4069 = "android.intent.extra.RESULT_RECEIVER";
4070
4071 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004072 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004073 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004074 */
4075 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4076
4077 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004078 * A Parcelable[] of {@link Intent} or
4079 * {@link android.content.pm.LabeledIntent} objects as set with
4080 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4081 * a the front of the list of choices, when shown to the user with a
4082 * {@link #ACTION_CHOOSER}.
4083 */
4084 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4085
4086 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004087 * A {@link IntentSender} to start after ephemeral installation success.
4088 * @hide
4089 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004090 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4091
4092 /**
4093 * A {@link IntentSender} to start after ephemeral installation failure.
4094 * @hide
4095 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004096 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4097
4098 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004099 * The host name that triggered an ephemeral resolution.
4100 * @hide
4101 */
4102 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4103
4104 /**
4105 * An opaque token to track ephemeral resolution.
4106 * @hide
4107 */
4108 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4109
4110 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004111 * The version code of the app to install components from.
4112 * @hide
4113 */
4114 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4115
4116 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004117 * A Bundle forming a mapping of potential target package names to different extras Bundles
4118 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4119 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4120 * be currently installed on the device.
4121 *
4122 * <p>An application may choose to provide alternate extras for the case where a user
4123 * selects an activity from a predetermined set of target packages. If the activity
4124 * the user selects from the chooser belongs to a package with its package name as
4125 * a key in this bundle, the corresponding extras for that package will be merged with
4126 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4127 * extra has the same key as an extra already present in the intent it will overwrite
4128 * the extra from the intent.</p>
4129 *
4130 * <p><em>Examples:</em>
4131 * <ul>
4132 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4133 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4134 * parameters for that target.</li>
4135 * <li>An application may offer additional metadata for known targets of a given intent
4136 * to pass along information only relevant to that target such as account or content
4137 * identifiers already known to that application.</li>
4138 * </ul></p>
4139 */
4140 public static final String EXTRA_REPLACEMENT_EXTRAS =
4141 "android.intent.extra.REPLACEMENT_EXTRAS";
4142
4143 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004144 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4145 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4146 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4147 * {@link ComponentName} of the chosen component.
4148 *
4149 * <p>In some situations this callback may never come, for example if the user abandons
4150 * the chooser, switches to another task or any number of other reasons. Apps should not
4151 * be written assuming that this callback will always occur.</p>
4152 */
4153 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4154 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4155
4156 /**
4157 * The {@link ComponentName} chosen by the user to complete an action.
4158 *
4159 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4160 */
4161 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4162
4163 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004164 * A {@link android.view.KeyEvent} object containing the event that
4165 * triggered the creation of the Intent it is in.
4166 */
4167 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4168
4169 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004170 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4171 * before shutting down.
4172 *
4173 * {@hide}
4174 */
4175 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4176
4177 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004178 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4179 * requested by the user.
4180 *
4181 * {@hide}
4182 */
4183 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4184 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4185
4186 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004187 * 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 -07004188 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4189 * of restarting the application.
4190 */
4191 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4192
4193 /**
4194 * A String holding the phone number originally entered in
4195 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4196 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4197 */
4198 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004199
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004200 /**
4201 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4202 * intents to supply the uid the package had been assigned. Also an optional
4203 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4204 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4205 * purpose.
4206 */
4207 public static final String EXTRA_UID = "android.intent.extra.UID";
4208
4209 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004210 * @hide String array of package names.
4211 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004212 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004213 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4214
4215 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004216 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4217 * intents to indicate whether this represents a full uninstall (removing
4218 * both the code and its data) or a partial uninstall (leaving its data,
4219 * implying that this is an update).
4220 */
4221 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004222
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004223 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004224 * @hide
4225 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4226 * intents to indicate that at this point the package has been removed for
4227 * all users on the device.
4228 */
4229 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4230 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4231
4232 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004233 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4234 * intents to indicate that this is a replacement of the package, so this
4235 * broadcast will immediately be followed by an add broadcast for a
4236 * different version of the same package.
4237 */
4238 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004239
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004240 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004241 * Used as an int extra field in {@link android.app.AlarmManager} intents
4242 * to tell the application being invoked how many pending alarms are being
4243 * delievered with the intent. For one-shot alarms this will always be 1.
4244 * For recurring alarms, this might be greater than 1 if the device was
4245 * asleep or powered off at the time an earlier alarm would have been
4246 * delivered.
4247 */
4248 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004249
Jacek Surazski86b6c532009-05-13 14:38:28 +02004250 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004251 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4252 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004253 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4254 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004255 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4256 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4257 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004258 */
4259 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4260
4261 /**
4262 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4263 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004264 */
4265 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4266
4267 /**
4268 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4269 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004270 */
4271 public static final int EXTRA_DOCK_STATE_DESK = 1;
4272
4273 /**
4274 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4275 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004276 */
4277 public static final int EXTRA_DOCK_STATE_CAR = 2;
4278
4279 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004280 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4281 * to represent that the phone is in a analog (low end) dock.
4282 */
4283 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4284
4285 /**
4286 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4287 * to represent that the phone is in a digital (high end) dock.
4288 */
4289 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4290
4291 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004292 * Boolean that can be supplied as meta-data with a dock activity, to
4293 * indicate that the dock should take over the home key when it is active.
4294 */
4295 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004296
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004297 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004298 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4299 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004300 */
4301 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4302
4303 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004304 * Used in the extra field in the remote intent. It's astring token passed with the
4305 * remote intent.
4306 */
4307 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4308 "android.intent.extra.remote_intent_token";
4309
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004310 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004311 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004312 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004313 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004314 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004315 "android.intent.extra.changed_component_name";
4316
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004317 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004318 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004319 * and contains a string array of all of the components that have changed. If
4320 * the state of the overall package has changed, then it will contain an entry
4321 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004322 */
4323 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4324 "android.intent.extra.changed_component_name_list";
4325
4326 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004327 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004328 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004329 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4330 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4331 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004332 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004333 */
4334 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4335 "android.intent.extra.changed_package_list";
4336
4337 /**
4338 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004339 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4340 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004341 * and contains an integer array of uids of all of the components
4342 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004343 */
4344 public static final String EXTRA_CHANGED_UID_LIST =
4345 "android.intent.extra.changed_uid_list";
4346
4347 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004348 * @hide
4349 * Magic extra system code can use when binding, to give a label for
4350 * who it is that has bound to a service. This is an integer giving
4351 * a framework string resource that can be displayed to the user.
4352 */
4353 public static final String EXTRA_CLIENT_LABEL =
4354 "android.intent.extra.client_label";
4355
4356 /**
4357 * @hide
4358 * Magic extra system code can use when binding, to give a PendingIntent object
4359 * that can be launched for the user to disable the system's use of this
4360 * service.
4361 */
4362 public static final String EXTRA_CLIENT_INTENT =
4363 "android.intent.extra.client_intent";
4364
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004365 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004366 * Extra used to indicate that an intent should only return data that is on
4367 * the local device. This is a boolean extra; the default is false. If true,
4368 * an implementation should only allow the user to select data that is
4369 * already on the device, not requiring it be downloaded from a remote
4370 * service when opened.
4371 *
4372 * @see #ACTION_GET_CONTENT
4373 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004374 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004375 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004376 */
4377 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004378 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004379
Amith Yamasani13593602012-03-22 16:16:17 -07004380 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004381 * Extra used to indicate that an intent can allow the user to select and
4382 * return multiple items. This is a boolean extra; the default is false. If
4383 * true, an implementation is allowed to present the user with a UI where
4384 * they can pick multiple items that are all returned to the caller. When
4385 * this happens, they should be returned as the {@link #getClipData()} part
4386 * of the result Intent.
4387 *
4388 * @see #ACTION_GET_CONTENT
4389 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004390 */
4391 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004392 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004393
4394 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004395 * The integer userHandle carried with broadcast intents related to addition, removal and
4396 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4397 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4398 *
Amith Yamasani13593602012-03-22 16:16:17 -07004399 * @hide
4400 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004401 public static final String EXTRA_USER_HANDLE =
4402 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004403
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004404 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004405 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4406 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4407 */
4408 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004409 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004410
4411 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004412 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004413 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4414 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004415 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004416 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4417
4418 /**
4419 * Extra sent in the intent to the BroadcastReceiver that handles
4420 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4421 * the restrictions as key/value pairs.
4422 */
4423 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4424 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004425
Amith Yamasani86118ba2013-03-28 14:33:16 -07004426 /**
4427 * Extra used in the response from a BroadcastReceiver that handles
4428 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4429 */
4430 public static final String EXTRA_RESTRICTIONS_INTENT =
4431 "android.intent.extra.restrictions_intent";
4432
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004433 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004434 * Extra used to communicate a set of acceptable MIME types. The type of the
4435 * extra is {@code String[]}. Values may be a combination of concrete MIME
4436 * types (such as "image/png") and/or partial MIME types (such as
4437 * "audio/*").
4438 *
4439 * @see #ACTION_GET_CONTENT
4440 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004441 */
4442 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4443
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004444 /**
4445 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4446 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004447 * When this is true, hardware devices can use this information to determine that
4448 * they shouldn't do a complete shutdown of their device since this is not a
4449 * complete shutdown down to the kernel, but only user space restarting.
4450 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004451 */
4452 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4453 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4454
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004455 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004456 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4457 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4458 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4459 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004460 *
4461 * @hide for internal use only.
4462 */
4463 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4464 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004465 /** @hide */
4466 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4467 /** @hide */
4468 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4469 /** @hide */
4470 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004471
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004472 /** {@hide} */
4473 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4474
Rubin Xue8490f12015-06-25 12:17:48 +01004475 /** {@hide} */
4476 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4477
Santos Cordon15a13782015-03-31 18:32:31 -07004478 /**
4479 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4480 * activation request.
4481 * TODO: Add information about the structure and response data used with the pending intent.
4482 * @hide
4483 */
4484 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4485 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4486
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004487 /**
4488 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004489 *
4490 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004491 * @see ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004492 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004493 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4494
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004495 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004496 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4497 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4498 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004499 *
4500 * <p>The value is boolean. By default false.
4501 * @see ACTION_QUICK_VIEW
4502 */
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004503 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4504 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004505
4506 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004507 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004508 * When a profile goes into quiet mode, all apps in the profile are killed and the
4509 * profile user is stopped. Widgets originating from the profile are masked, and app
4510 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004511 */
4512 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004513
4514 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004515 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004516 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004517 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4518 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004519 *
4520 * @hide
4521 */
4522 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4523 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4524
4525 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004526 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4527 * whether to show the chooser or not when there is only one application available
4528 * to choose from.
4529 *
4530 * @hide
4531 */
4532 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4533 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4534
4535 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004536 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004537 * to represent that a video codec is allowed to use.
4538 *
4539 * @hide
4540 */
4541 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4542
4543 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004544 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004545 * to represent that a audio codec is allowed to use.
4546 *
4547 * @hide
4548 */
4549 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4550
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004551 // ---------------------------------------------------------------------
4552 // ---------------------------------------------------------------------
4553 // Intent flags (see mFlags variable).
4554
Tor Norbyed9273d62013-05-30 15:59:53 -07004555 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004556 @IntDef(flag = true, value = {
4557 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4558 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004559 @Retention(RetentionPolicy.SOURCE)
4560 public @interface GrantUriMode {}
4561
Jeff Sharkey846318a2014-04-04 12:12:41 -07004562 /** @hide */
4563 @IntDef(flag = true, value = {
4564 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4565 @Retention(RetentionPolicy.SOURCE)
4566 public @interface AccessUriMode {}
4567
4568 /**
4569 * Test if given mode flags specify an access mode, which must be at least
4570 * read and/or write.
4571 *
4572 * @hide
4573 */
4574 public static boolean isAccessUriMode(int modeFlags) {
4575 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4576 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4577 }
4578
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004579 /**
4580 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004581 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004582 * specified in its ClipData. When applying to an Intent's ClipData,
4583 * all URIs as well as recursive traversals through data or other ClipData
4584 * in Intent items will be granted; only the grant flags of the top-level
4585 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004586 */
4587 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4588 /**
4589 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004590 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004591 * specified in its ClipData. When applying to an Intent's ClipData,
4592 * all URIs as well as recursive traversals through data or other ClipData
4593 * in Intent items will be granted; only the grant flags of the top-level
4594 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004595 */
4596 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4597 /**
4598 * Can be set by the caller to indicate that this Intent is coming from
4599 * a background operation, not from direct user interaction.
4600 */
4601 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4602 /**
4603 * A flag you can enable for debugging: when set, log messages will be
4604 * printed during the resolution of this intent to show you what has
4605 * been found to create the final resolved list.
4606 */
4607 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004608 /**
4609 * If set, this intent will not match any components in packages that
4610 * are currently stopped. If this is not set, then the default behavior
4611 * is to include such applications in the result.
4612 */
4613 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4614 /**
4615 * If set, this intent will always match any components in packages that
4616 * are currently stopped. This is the default behavior when
4617 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4618 * flags are set, this one wins (it allows overriding of exclude for
4619 * places where the framework may automatically set the exclude flag).
4620 */
4621 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004622
4623 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004624 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004625 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004626 * persisted across device reboots until explicitly revoked with
4627 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4628 * grant for possible persisting; the receiving application must call
4629 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4630 * actually persist.
4631 *
4632 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4633 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4634 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004635 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004636 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004637 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004638
4639 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004640 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4641 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4642 * applies to any URI that is a prefix match against the original granted
4643 * URI. (Without this flag, the URI must match exactly for access to be
4644 * granted.) Another URI is considered a prefix match only when scheme,
4645 * authority, and all path segments defined by the prefix are an exact
4646 * match.
4647 */
4648 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4649
4650 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004651 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004652 * homework and verified that they correctly handle packages and components
4653 * that come and go over time. In particular:
4654 * <ul>
4655 * <li>Apps installed on external storage, which will appear to be
4656 * uninstalled while the the device is ejected.
4657 * <li>Apps with encryption unaware components, which will appear to not
4658 * exist while the device is locked.
4659 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004660 *
4661 * @hide
4662 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004663 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004664
4665 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004666 * Internal flag used to indicate ephemeral applications should not be
4667 * considered when resolving the intent.
4668 *
4669 * @hide
4670 */
4671 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4672
4673 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004674 * If set, the new activity is not kept in the history stack. As soon as
4675 * the user navigates away from it, the activity is finished. This may also
4676 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4677 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004678 *
4679 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4680 * is never invoked when the current activity starts a new activity which
4681 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004682 */
4683 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4684 /**
4685 * If set, the activity will not be launched if it is already running
4686 * at the top of the history stack.
4687 */
4688 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4689 /**
4690 * If set, this activity will become the start of a new task on this
4691 * history stack. A task (from the activity that started it to the
4692 * next task activity) defines an atomic group of activities that the
4693 * user can move to. Tasks can be moved to the foreground and background;
4694 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004695 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004696 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4697 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004698 *
4699 * <p>This flag is generally used by activities that want
4700 * to present a "launcher" style behavior: they give the user a list of
4701 * separate things that can be done, which otherwise run completely
4702 * independently of the activity launching them.
4703 *
4704 * <p>When using this flag, if a task is already running for the activity
4705 * you are now starting, then a new activity will not be started; instead,
4706 * the current task will simply be brought to the front of the screen with
4707 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4708 * to disable this behavior.
4709 *
4710 * <p>This flag can not be used when the caller is requesting a result from
4711 * the activity being launched.
4712 */
4713 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4714 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004715 * This flag is used to create a new task and launch an activity into it.
4716 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4717 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4718 * search through existing tasks for ones matching this Intent. Only if no such
4719 * task is found would a new task be created. When paired with
4720 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4721 * the search for a matching task and unconditionally start a new task.
4722 *
4723 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4724 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004725 * top-level application launcher.</strong> Used in conjunction with
4726 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4727 * behavior of bringing an existing task to the foreground. When set,
4728 * a new task is <em>always</em> started to host the Activity for the
4729 * Intent, regardless of whether there is already an existing task running
4730 * the same thing.
4731 *
4732 * <p><strong>Because the default system does not include graphical task management,
4733 * you should not use this flag unless you provide some way for a user to
4734 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004735 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004736 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4737 * creating new document tasks.
4738 *
4739 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004740 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 *
Scott Main7aee61f2011-02-08 11:25:01 -08004742 * <p>See
4743 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4744 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004745 *
4746 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4747 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004748 */
4749 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4750 /**
4751 * If set, and the activity being launched is already running in the
4752 * current task, then instead of launching a new instance of that activity,
4753 * all of the other activities on top of it will be closed and this Intent
4754 * will be delivered to the (now on top) old activity as a new Intent.
4755 *
4756 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4757 * If D calls startActivity() with an Intent that resolves to the component
4758 * of activity B, then C and D will be finished and B receive the given
4759 * Intent, resulting in the stack now being: A, B.
4760 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004761 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004762 * either receive the new intent you are starting here in its
4763 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004764 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004765 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4766 * the same intent, then it will be finished and re-created; for all other
4767 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4768 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004769 *
4770 * <p>This launch mode can also be used to good effect in conjunction with
4771 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4772 * of a task, it will bring any currently running instance of that task
4773 * to the foreground, and then clear it to its root state. This is
4774 * especially useful, for example, when launching an activity from the
4775 * notification manager.
4776 *
Scott Main7aee61f2011-02-08 11:25:01 -08004777 * <p>See
4778 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4779 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004780 */
4781 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4782 /**
4783 * If set and this intent is being used to launch a new activity from an
4784 * existing one, then the reply target of the existing activity will be
4785 * transfered to the new activity. This way the new activity can call
4786 * {@link android.app.Activity#setResult} and have that result sent back to
4787 * the reply target of the original activity.
4788 */
4789 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4790 /**
4791 * If set and this intent is being used to launch a new activity from an
4792 * existing one, the current activity will not be counted as the top
4793 * activity for deciding whether the new intent should be delivered to
4794 * the top instead of starting a new one. The previous activity will
4795 * be used as the top, with the assumption being that the current activity
4796 * will finish itself immediately.
4797 */
4798 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4799 /**
4800 * If set, the new activity is not kept in the list of recently launched
4801 * activities.
4802 */
4803 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4804 /**
4805 * This flag is not normally set by application code, but set for you by
4806 * the system as described in the
4807 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4808 * launchMode} documentation for the singleTask mode.
4809 */
4810 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4811 /**
4812 * If set, and this activity is either being started in a new task or
4813 * bringing to the top an existing task, then it will be launched as
4814 * the front door of the task. This will result in the application of
4815 * any affinities needed to have that task in the proper state (either
4816 * moving activities to or from it), or simply resetting that task to
4817 * its initial state if needed.
4818 */
4819 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4820 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004821 * This flag is not normally set by application code, but set for you by
4822 * the system if this activity is being launched from history
4823 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004824 */
4825 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004826 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004827 * @deprecated As of API 21 this performs identically to
4828 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004829 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004830 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004831 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004832 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004833 * This flag is used to open a document into a new task rooted at the activity launched
4834 * by this Intent. Through the use of this flag, or its equivalent attribute,
4835 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004836 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004837 *
Craig Mautner026596b2014-05-21 15:35:44 -07004838 * <p>The use of the activity attribute form of this,
4839 * {@link android.R.attr#documentLaunchMode}, is
4840 * preferred over the Intent flag described here. The attribute form allows the
4841 * Activity to specify multiple document behavior for all launchers of the Activity
4842 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004843 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004844 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4845 * it is kept after the activity is finished is different than the use of
4846 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4847 * this flag is being used to create a new recents entry, then by default that entry
4848 * will be removed once the activity is finished. You can modify this behavior with
4849 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4850 *
Craig Mautner026596b2014-05-21 15:35:44 -07004851 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4852 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4853 * equivalent of the Activity manifest specifying {@link
4854 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4855 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4856 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004857 *
Craig Mautner026596b2014-05-21 15:35:44 -07004858 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004859 *
Craig Mautner026596b2014-05-21 15:35:44 -07004860 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004861 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4862 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004863 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004864 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004865 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004866 * callback from occurring on the current frontmost activity before it is
4867 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004868 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004869 * <p>Typically, an activity can rely on that callback to indicate that an
4870 * explicit user action has caused their activity to be moved out of the
4871 * foreground. The callback marks an appropriate point in the activity's
4872 * lifecycle for it to dismiss any notifications that it intends to display
4873 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004874 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004875 * <p>If an activity is ever started via any non-user-driven events such as
4876 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4877 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004878 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004879 */
4880 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004881 /**
4882 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4883 * this flag will cause the launched activity to be brought to the front of its
4884 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004885 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004886 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4887 * If D calls startActivity() with an Intent that resolves to the component
4888 * of activity B, then B will be brought to the front of the history stack,
4889 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004890 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004891 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004892 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004893 */
4894 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004895 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004896 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4897 * this flag will prevent the system from applying an activity transition
4898 * animation to go to the next activity state. This doesn't mean an
4899 * animation will never run -- if another activity change happens that doesn't
4900 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004901 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004902 * when you are going to do a series of activity operations but the
4903 * animation seen by the user shouldn't be driven by the first activity
4904 * change but rather a later one.
4905 */
4906 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4907 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004908 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4909 * this flag will cause any existing task that would be associated with the
4910 * activity to be cleared before the activity is started. That is, the activity
4911 * becomes the new root of an otherwise empty task, and any old activities
4912 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4913 */
4914 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4915 /**
4916 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4917 * this flag will cause a newly launching task to be placed on top of the current
4918 * home activity task (if there is one). That is, pressing back from the task
4919 * will always return the user to home even if that was not the last activity they
4920 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4921 */
4922 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4923 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004924 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4925 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004926 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004927 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004928 * this flag. When set and the task's activity is finished, the recents
4929 * entry will remain in the interface for the user to re-launch it, like a
4930 * recents entry for a top-level application.
4931 * <p>
4932 * The receiving activity can override this request with
4933 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4934 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004935 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004936 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004937 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004938
4939 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004940 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4941 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004942 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4943 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004944 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004945 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004946
4947 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004948 * If set, when sending a broadcast only registered receivers will be
4949 * called -- no BroadcastReceiver components will be launched.
4950 */
4951 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004952 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004953 * If set, when sending a broadcast the new broadcast will replace
4954 * any existing pending broadcast that matches it. Matching is defined
4955 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4956 * true for the intents of the two broadcasts. When a match is found,
4957 * the new broadcast (and receivers associated with it) will replace the
4958 * existing one in the pending broadcast list, remaining at the same
4959 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004960 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004961 * <p>This flag is most typically used with sticky broadcasts, which
4962 * only care about delivering the most recent values of the broadcast
4963 * to their receivers.
4964 */
4965 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4966 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004967 * If set, when sending a broadcast the recipient is allowed to run at
4968 * foreground priority, with a shorter timeout interval. During normal
4969 * broadcasts the receivers are not automatically hoisted out of the
4970 * background priority class.
4971 */
4972 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4973 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004974 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4975 * They can still propagate results through to later receivers, but they can not prevent
4976 * later receivers from seeing the broadcast.
4977 */
4978 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4979 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004980 * If set, when sending a broadcast <i>before boot has completed</i> only
4981 * registered receivers will be called -- no BroadcastReceiver components
4982 * will be launched. Sticky intent state will be recorded properly even
4983 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4984 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004985 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004986 * <p>This flag is only for use by system sevices as a convenience to
4987 * avoid having to implement a more complex mechanism around detection
4988 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004989 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004990 * @hide
4991 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004992 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004993 /**
4994 * Set when this broadcast is for a boot upgrade, a special mode that
4995 * allows the broadcast to be sent before the system is ready and launches
4996 * the app process with no providers running in it.
4997 * @hide
4998 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004999 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005000 /**
5001 * If set, the broadcast will always go to manifest receivers in background (cached
5002 * or not running) apps, regardless of whether that would be done by default. By
5003 * default they will only receive broadcasts if the broadcast has specified an
5004 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005005 *
5006 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5007 * the broadcast code there must also be changed to match.
5008 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005009 * @hide
5010 */
5011 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5012 /**
5013 * If set, the broadcast will never go to manifest receivers in background (cached
5014 * or not running) apps, regardless of whether that would be done by default. By
5015 * default they will receive broadcasts if the broadcast has specified an
5016 * explicit component or package name.
5017 * @hide
5018 */
5019 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005020 /**
5021 * If set, this broadcast is being sent from the shell.
5022 * @hide
5023 */
5024 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005025
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005026 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005027 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5028 * will not receive broadcasts.
5029 *
5030 * <em>This flag has no effect when used by an Instant App.</em>
5031 */
5032 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5033
5034 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005035 * @hide Flags that can't be changed with PendingIntent.
5036 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005037 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5038 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5039 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005040
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005041 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005042 // ---------------------------------------------------------------------
5043 // toUri() and parseUri() options.
5044
5045 /**
5046 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5047 * always has the "intent:" scheme. This syntax can be used when you want
5048 * to later disambiguate between URIs that are intended to describe an
5049 * Intent vs. all others that should be treated as raw URIs. When used
5050 * with {@link #parseUri}, any other scheme will result in a generic
5051 * VIEW action for that raw URI.
5052 */
5053 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005054
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005055 /**
5056 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5057 * always has the "android-app:" scheme. This is a variation of
5058 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5059 * http/https URI being delivered to a specific package name. The format
5060 * is:
5061 *
5062 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005063 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005064 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005065 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5066 * you must also include a scheme; including a path also requires both a host and a scheme.
5067 * The final #Intent; fragment can be used without a scheme, host, or path.
5068 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005069 * used with intents that have a {@link #setSelector}, since the base intent
5070 * will always have an explicit package name.</p>
5071 *
5072 * <p>Some examples of how this scheme maps to Intent objects:</p>
5073 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5074 * <colgroup align="left" />
5075 * <colgroup align="left" />
5076 * <thead>
5077 * <tr><th>URI</th> <th>Intent</th></tr>
5078 * </thead>
5079 *
5080 * <tbody>
5081 * <tr><td><code>android-app://com.example.app</code></td>
5082 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5083 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5084 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5085 * </table></td>
5086 * </tr>
5087 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5088 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5089 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5090 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5091 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5092 * </table></td>
5093 * </tr>
5094 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5095 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5096 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5097 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5098 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5099 * </table></td>
5100 * </tr>
5101 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5102 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5103 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5104 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5105 * </table></td>
5106 * </tr>
5107 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5108 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5109 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5110 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5111 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5112 * </table></td>
5113 * </tr>
5114 * <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>
5115 * <td><table border="" style="margin:0" >
5116 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5117 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5118 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5119 * </table></td>
5120 * </tr>
5121 * </tbody>
5122 * </table>
5123 */
5124 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5125
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005126 /**
5127 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5128 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5129 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5130 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5131 * generated Intent can not cause unexpected data access to happen.
5132 *
5133 * <p>If you do not trust the source of the URI being parsed, you should still do further
5134 * processing to protect yourself from it. In particular, when using it to start an
5135 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5136 * that can handle it.</p>
5137 */
5138 public static final int URI_ALLOW_UNSAFE = 1<<2;
5139
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005140 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005141
5142 private String mAction;
5143 private Uri mData;
5144 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005145 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005146 private ComponentName mComponent;
5147 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005148 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005149 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005150 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005151 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005152 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005153 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005154 /** Token to track instant app launches. Local only; do not copy cross-process. */
5155 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005156
5157 // ---------------------------------------------------------------------
5158
5159 /**
5160 * Create an empty intent.
5161 */
5162 public Intent() {
5163 }
5164
5165 /**
5166 * Copy constructor.
5167 */
5168 public Intent(Intent o) {
5169 this.mAction = o.mAction;
5170 this.mData = o.mData;
5171 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005172 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005173 this.mComponent = o.mComponent;
5174 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005175 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005176 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005177 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005178 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005179 }
5180 if (o.mExtras != null) {
5181 this.mExtras = new Bundle(o.mExtras);
5182 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005183 if (o.mSourceBounds != null) {
5184 this.mSourceBounds = new Rect(o.mSourceBounds);
5185 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005186 if (o.mSelector != null) {
5187 this.mSelector = new Intent(o.mSelector);
5188 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005189 if (o.mClipData != null) {
5190 this.mClipData = new ClipData(o.mClipData);
5191 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005192 }
5193
5194 @Override
5195 public Object clone() {
5196 return new Intent(this);
5197 }
5198
5199 private Intent(Intent o, boolean all) {
5200 this.mAction = o.mAction;
5201 this.mData = o.mData;
5202 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005203 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005204 this.mComponent = o.mComponent;
5205 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005206 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005207 }
5208 }
5209
5210 /**
5211 * Make a clone of only the parts of the Intent that are relevant for
5212 * filter matching: the action, data, type, component, and categories.
5213 */
5214 public Intent cloneFilter() {
5215 return new Intent(this, false);
5216 }
5217
5218 /**
5219 * Create an intent with a given action. All other fields (data, type,
5220 * class) are null. Note that the action <em>must</em> be in a
5221 * namespace because Intents are used globally in the system -- for
5222 * example the system VIEW action is android.intent.action.VIEW; an
5223 * application's custom action would be something like
5224 * com.google.app.myapp.CUSTOM_ACTION.
5225 *
5226 * @param action The Intent action, such as ACTION_VIEW.
5227 */
5228 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005229 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005230 }
5231
5232 /**
5233 * Create an intent with a given action and for a given data url. Note
5234 * that the action <em>must</em> be in a namespace because Intents are
5235 * used globally in the system -- for example the system VIEW action is
5236 * android.intent.action.VIEW; an application's custom action would be
5237 * something like com.google.app.myapp.CUSTOM_ACTION.
5238 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005239 * <p><em>Note: scheme and host name matching in the Android framework is
5240 * case-sensitive, unlike the formal RFC. As a result,
5241 * you should always ensure that you write your Uri with these elements
5242 * using lower case letters, and normalize any Uris you receive from
5243 * outside of Android to ensure the scheme and host is lower case.</em></p>
5244 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005245 * @param action The Intent action, such as ACTION_VIEW.
5246 * @param uri The Intent data URI.
5247 */
5248 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005249 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005250 mData = uri;
5251 }
5252
5253 /**
5254 * Create an intent for a specific component. All other fields (action, data,
5255 * type, class) are null, though they can be modified later with explicit
5256 * calls. This provides a convenient way to create an intent that is
5257 * intended to execute a hard-coded class name, rather than relying on the
5258 * system to find an appropriate class for you; see {@link #setComponent}
5259 * for more information on the repercussions of this.
5260 *
5261 * @param packageContext A Context of the application package implementing
5262 * this class.
5263 * @param cls The component class that is to be used for the intent.
5264 *
5265 * @see #setClass
5266 * @see #setComponent
5267 * @see #Intent(String, android.net.Uri , Context, Class)
5268 */
5269 public Intent(Context packageContext, Class<?> cls) {
5270 mComponent = new ComponentName(packageContext, cls);
5271 }
5272
5273 /**
5274 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005275 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005276 * construct the Intent and then calling {@link #setClass} to set its
5277 * class.
5278 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005279 * <p><em>Note: scheme and host name matching in the Android framework is
5280 * case-sensitive, unlike the formal RFC. As a result,
5281 * you should always ensure that you write your Uri with these elements
5282 * using lower case letters, and normalize any Uris you receive from
5283 * outside of Android to ensure the scheme and host is lower case.</em></p>
5284 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005285 * @param action The Intent action, such as ACTION_VIEW.
5286 * @param uri The Intent data URI.
5287 * @param packageContext A Context of the application package implementing
5288 * this class.
5289 * @param cls The component class that is to be used for the intent.
5290 *
5291 * @see #Intent(String, android.net.Uri)
5292 * @see #Intent(Context, Class)
5293 * @see #setClass
5294 * @see #setComponent
5295 */
5296 public Intent(String action, Uri uri,
5297 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005298 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005299 mData = uri;
5300 mComponent = new ComponentName(packageContext, cls);
5301 }
5302
5303 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005304 * Create an intent to launch the main (root) activity of a task. This
5305 * is the Intent that is started when the application's is launched from
5306 * Home. For anything else that wants to launch an application in the
5307 * same way, it is important that they use an Intent structured the same
5308 * way, and can use this function to ensure this is the case.
5309 *
5310 * <p>The returned Intent has the given Activity component as its explicit
5311 * component, {@link #ACTION_MAIN} as its action, and includes the
5312 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5313 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5314 * to do that through {@link #addFlags(int)} on the returned Intent.
5315 *
5316 * @param mainActivity The main activity component that this Intent will
5317 * launch.
5318 * @return Returns a newly created Intent that can be used to launch the
5319 * activity as a main application entry.
5320 *
5321 * @see #setClass
5322 * @see #setComponent
5323 */
5324 public static Intent makeMainActivity(ComponentName mainActivity) {
5325 Intent intent = new Intent(ACTION_MAIN);
5326 intent.setComponent(mainActivity);
5327 intent.addCategory(CATEGORY_LAUNCHER);
5328 return intent;
5329 }
5330
5331 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005332 * Make an Intent for the main activity of an application, without
5333 * specifying a specific activity to run but giving a selector to find
5334 * the activity. This results in a final Intent that is structured
5335 * the same as when the application is launched from
5336 * Home. For anything else that wants to launch an application in the
5337 * same way, it is important that they use an Intent structured the same
5338 * way, and can use this function to ensure this is the case.
5339 *
5340 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5341 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5342 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5343 * to do that through {@link #addFlags(int)} on the returned Intent.
5344 *
5345 * @param selectorAction The action name of the Intent's selector.
5346 * @param selectorCategory The name of a category to add to the Intent's
5347 * selector.
5348 * @return Returns a newly created Intent that can be used to launch the
5349 * activity as a main application entry.
5350 *
5351 * @see #setSelector(Intent)
5352 */
5353 public static Intent makeMainSelectorActivity(String selectorAction,
5354 String selectorCategory) {
5355 Intent intent = new Intent(ACTION_MAIN);
5356 intent.addCategory(CATEGORY_LAUNCHER);
5357 Intent selector = new Intent();
5358 selector.setAction(selectorAction);
5359 selector.addCategory(selectorCategory);
5360 intent.setSelector(selector);
5361 return intent;
5362 }
5363
5364 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005365 * Make an Intent that can be used to re-launch an application's task
5366 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5367 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5368 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5369 *
5370 * @param mainActivity The activity component that is the root of the
5371 * task; this is the activity that has been published in the application's
5372 * manifest as the main launcher icon.
5373 *
5374 * @return Returns a newly created Intent that can be used to relaunch the
5375 * activity's task in its root state.
5376 */
5377 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5378 Intent intent = makeMainActivity(mainActivity);
5379 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5380 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5381 return intent;
5382 }
5383
5384 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005385 * Call {@link #parseUri} with 0 flags.
5386 * @deprecated Use {@link #parseUri} instead.
5387 */
5388 @Deprecated
5389 public static Intent getIntent(String uri) throws URISyntaxException {
5390 return parseUri(uri, 0);
5391 }
Tom Taylord4a47292009-12-21 13:59:18 -08005392
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005393 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005394 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005395 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005396 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005397 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005398 *
5399 * <p>The URI given here must not be relative -- that is, it must include
5400 * the scheme and full path.
5401 *
5402 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005403 * @param flags Additional processing flags. Either 0,
5404 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005405 *
5406 * @return Intent The newly created Intent object.
5407 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005408 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5409 * it bad (as parsed by the Uri class) or the Intent data within the
5410 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005411 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005412 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005413 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005414 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005415 int i = 0;
5416 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005417 final boolean androidApp = uri.startsWith("android-app:");
5418
5419 // Validate intent scheme if requested.
5420 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5421 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005422 Intent intent = new Intent(ACTION_VIEW);
5423 try {
5424 intent.setData(Uri.parse(uri));
5425 } catch (IllegalArgumentException e) {
5426 throw new URISyntaxException(uri, e.getMessage());
5427 }
5428 return intent;
5429 }
5430 }
Tom Taylord4a47292009-12-21 13:59:18 -08005431
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005432 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005433 // simple case
5434 if (i == -1) {
5435 if (!androidApp) {
5436 return new Intent(ACTION_VIEW, Uri.parse(uri));
5437 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005438
5439 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005440 } else if (!uri.startsWith("#Intent;", i)) {
5441 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005442 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005443 } else {
5444 i = -1;
5445 }
5446 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005447
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005448 // new format
5449 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005450 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005451 boolean explicitAction = false;
5452 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005453
5454 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005455 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005456 String data;
5457 if (i >= 0) {
5458 data = uri.substring(0, i);
5459 i += 8; // length of "#Intent;"
5460 } else {
5461 data = uri;
5462 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005463
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005464 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005465 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005467 if (eq < 0) eq = i-1;
5468 int semi = uri.indexOf(';', i);
5469 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005470
5471 // action
5472 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005473 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005474 if (!inSelector) {
5475 explicitAction = true;
5476 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005477 }
5478
5479 // categories
5480 else if (uri.startsWith("category=", i)) {
5481 intent.addCategory(value);
5482 }
5483
5484 // type
5485 else if (uri.startsWith("type=", i)) {
5486 intent.mType = value;
5487 }
5488
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005489 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005490 else if (uri.startsWith("launchFlags=", i)) {
5491 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005492 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5493 intent.mFlags &= ~IMMUTABLE_FLAGS;
5494 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005495 }
5496
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005497 // package
5498 else if (uri.startsWith("package=", i)) {
5499 intent.mPackage = value;
5500 }
5501
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005502 // component
5503 else if (uri.startsWith("component=", i)) {
5504 intent.mComponent = ComponentName.unflattenFromString(value);
5505 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005506
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005507 // scheme
5508 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005509 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005510 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005511 } else {
5512 scheme = value;
5513 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005514 }
5515
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005516 // source bounds
5517 else if (uri.startsWith("sourceBounds=", i)) {
5518 intent.mSourceBounds = Rect.unflattenFromString(value);
5519 }
5520
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005521 // selector
5522 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5523 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005524 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005525 }
5526
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005527 // extra
5528 else {
5529 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005530 // create Bundle if it doesn't already exist
5531 if (intent.mExtras == null) intent.mExtras = new Bundle();
5532 Bundle b = intent.mExtras;
5533 // add EXTRA
5534 if (uri.startsWith("S.", i)) b.putString(key, value);
5535 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5536 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5537 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5538 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5539 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5540 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5541 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5542 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5543 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5544 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005545
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005546 // move to the next item
5547 i = semi + 1;
5548 }
5549
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005550 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005551 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005552 if (baseIntent.mPackage == null) {
5553 baseIntent.setSelector(intent);
5554 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005555 intent = baseIntent;
5556 }
5557
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005558 if (data != null) {
5559 if (data.startsWith("intent:")) {
5560 data = data.substring(7);
5561 if (scheme != null) {
5562 data = scheme + ':' + data;
5563 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005564 } else if (data.startsWith("android-app:")) {
5565 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5566 // Correctly formed android-app, first part is package name.
5567 int end = data.indexOf('/', 14);
5568 if (end < 0) {
5569 // All we have is a package name.
5570 intent.mPackage = data.substring(14);
5571 if (!explicitAction) {
5572 intent.setAction(ACTION_MAIN);
5573 }
5574 data = "";
5575 } else {
5576 // Target the Intent at the given package name always.
5577 String authority = null;
5578 intent.mPackage = data.substring(14, end);
5579 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005580 if ((end+1) < data.length()) {
5581 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5582 // Found a scheme, remember it.
5583 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005584 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005585 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5586 // Found a authority, remember it.
5587 authority = data.substring(end+1, newEnd);
5588 end = newEnd;
5589 }
5590 } else {
5591 // All we have is a scheme.
5592 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005593 }
5594 }
5595 if (scheme == null) {
5596 // If there was no scheme, then this just targets the package.
5597 if (!explicitAction) {
5598 intent.setAction(ACTION_MAIN);
5599 }
5600 data = "";
5601 } else if (authority == null) {
5602 data = scheme + ":";
5603 } else {
5604 data = scheme + "://" + authority + data.substring(end);
5605 }
5606 }
5607 } else {
5608 data = "";
5609 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005610 }
Tom Taylord4a47292009-12-21 13:59:18 -08005611
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005612 if (data.length() > 0) {
5613 try {
5614 intent.mData = Uri.parse(data);
5615 } catch (IllegalArgumentException e) {
5616 throw new URISyntaxException(uri, e.getMessage());
5617 }
5618 }
5619 }
Tom Taylord4a47292009-12-21 13:59:18 -08005620
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005621 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005622
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005623 } catch (IndexOutOfBoundsException e) {
5624 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5625 }
5626 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005627
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005628 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005629 return getIntentOld(uri, 0);
5630 }
5631
5632 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005633 Intent intent;
5634
5635 int i = uri.lastIndexOf('#');
5636 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005637 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005638 final int intentFragmentStart = i;
5639 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005640
5641 i++;
5642
5643 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005644 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005645 i += 7;
5646 int j = uri.indexOf(')', i);
5647 action = uri.substring(i, j);
5648 i = j + 1;
5649 }
5650
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005651 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005652
5653 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005654 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005655 i += 11;
5656 int j = uri.indexOf(')', i);
5657 while (i < j) {
5658 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005659 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005660 if (i < sep) {
5661 intent.addCategory(uri.substring(i, sep));
5662 }
5663 i = sep + 1;
5664 }
5665 i = j + 1;
5666 }
5667
5668 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005669 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005670 i += 5;
5671 int j = uri.indexOf(')', i);
5672 intent.mType = uri.substring(i, j);
5673 i = j + 1;
5674 }
5675
5676 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005677 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005678 i += 12;
5679 int j = uri.indexOf(')', i);
5680 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005681 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5682 intent.mFlags &= ~IMMUTABLE_FLAGS;
5683 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005684 i = j + 1;
5685 }
5686
5687 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005688 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005689 i += 10;
5690 int j = uri.indexOf(')', i);
5691 int sep = uri.indexOf('!', i);
5692 if (sep >= 0 && sep < j) {
5693 String pkg = uri.substring(i, sep);
5694 String cls = uri.substring(sep + 1, j);
5695 intent.mComponent = new ComponentName(pkg, cls);
5696 }
5697 i = j + 1;
5698 }
5699
5700 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005701 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005702 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005704 final int closeParen = uri.indexOf(')', i);
5705 if (closeParen == -1) throw new URISyntaxException(uri,
5706 "EXTRA missing trailing ')'", i);
5707
5708 while (i < closeParen) {
5709 // fetch the key value
5710 int j = uri.indexOf('=', i);
5711 if (j <= i + 1 || i >= closeParen) {
5712 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5713 }
5714 char type = uri.charAt(i);
5715 i++;
5716 String key = uri.substring(i, j);
5717 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005718
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005719 // get type-value
5720 j = uri.indexOf('!', i);
5721 if (j == -1 || j >= closeParen) j = closeParen;
5722 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5723 String value = uri.substring(i, j);
5724 i = j;
5725
5726 // create Bundle if it doesn't already exist
5727 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005728
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005729 // add item to bundle
5730 try {
5731 switch (type) {
5732 case 'S':
5733 intent.mExtras.putString(key, Uri.decode(value));
5734 break;
5735 case 'B':
5736 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5737 break;
5738 case 'b':
5739 intent.mExtras.putByte(key, Byte.parseByte(value));
5740 break;
5741 case 'c':
5742 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5743 break;
5744 case 'd':
5745 intent.mExtras.putDouble(key, Double.parseDouble(value));
5746 break;
5747 case 'f':
5748 intent.mExtras.putFloat(key, Float.parseFloat(value));
5749 break;
5750 case 'i':
5751 intent.mExtras.putInt(key, Integer.parseInt(value));
5752 break;
5753 case 'l':
5754 intent.mExtras.putLong(key, Long.parseLong(value));
5755 break;
5756 case 's':
5757 intent.mExtras.putShort(key, Short.parseShort(value));
5758 break;
5759 default:
5760 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5761 }
5762 } catch (NumberFormatException e) {
5763 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5764 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005765
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005766 char ch = uri.charAt(i);
5767 if (ch == ')') break;
5768 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5769 i++;
5770 }
5771 }
5772
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005773 if (isIntentFragment) {
5774 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5775 } else {
5776 intent.mData = Uri.parse(uri);
5777 }
Tom Taylord4a47292009-12-21 13:59:18 -08005778
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005779 if (intent.mAction == null) {
5780 // By default, if no action is specified, then use VIEW.
5781 intent.mAction = ACTION_VIEW;
5782 }
5783
5784 } else {
5785 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5786 }
5787
5788 return intent;
5789 }
5790
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005791 /** @hide */
5792 public interface CommandOptionHandler {
5793 boolean handleOption(String opt, ShellCommand cmd);
5794 }
5795
5796 /** @hide */
5797 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5798 throws URISyntaxException {
5799 Intent intent = new Intent();
5800 Intent baseIntent = intent;
5801 boolean hasIntentInfo = false;
5802
5803 Uri data = null;
5804 String type = null;
5805
5806 String opt;
5807 while ((opt=cmd.getNextOption()) != null) {
5808 switch (opt) {
5809 case "-a":
5810 intent.setAction(cmd.getNextArgRequired());
5811 if (intent == baseIntent) {
5812 hasIntentInfo = true;
5813 }
5814 break;
5815 case "-d":
5816 data = Uri.parse(cmd.getNextArgRequired());
5817 if (intent == baseIntent) {
5818 hasIntentInfo = true;
5819 }
5820 break;
5821 case "-t":
5822 type = cmd.getNextArgRequired();
5823 if (intent == baseIntent) {
5824 hasIntentInfo = true;
5825 }
5826 break;
5827 case "-c":
5828 intent.addCategory(cmd.getNextArgRequired());
5829 if (intent == baseIntent) {
5830 hasIntentInfo = true;
5831 }
5832 break;
5833 case "-e":
5834 case "--es": {
5835 String key = cmd.getNextArgRequired();
5836 String value = cmd.getNextArgRequired();
5837 intent.putExtra(key, value);
5838 }
5839 break;
5840 case "--esn": {
5841 String key = cmd.getNextArgRequired();
5842 intent.putExtra(key, (String) null);
5843 }
5844 break;
5845 case "--ei": {
5846 String key = cmd.getNextArgRequired();
5847 String value = cmd.getNextArgRequired();
5848 intent.putExtra(key, Integer.decode(value));
5849 }
5850 break;
5851 case "--eu": {
5852 String key = cmd.getNextArgRequired();
5853 String value = cmd.getNextArgRequired();
5854 intent.putExtra(key, Uri.parse(value));
5855 }
5856 break;
5857 case "--ecn": {
5858 String key = cmd.getNextArgRequired();
5859 String value = cmd.getNextArgRequired();
5860 ComponentName cn = ComponentName.unflattenFromString(value);
5861 if (cn == null)
5862 throw new IllegalArgumentException("Bad component name: " + value);
5863 intent.putExtra(key, cn);
5864 }
5865 break;
5866 case "--eia": {
5867 String key = cmd.getNextArgRequired();
5868 String value = cmd.getNextArgRequired();
5869 String[] strings = value.split(",");
5870 int[] list = new int[strings.length];
5871 for (int i = 0; i < strings.length; i++) {
5872 list[i] = Integer.decode(strings[i]);
5873 }
5874 intent.putExtra(key, list);
5875 }
5876 break;
5877 case "--eial": {
5878 String key = cmd.getNextArgRequired();
5879 String value = cmd.getNextArgRequired();
5880 String[] strings = value.split(",");
5881 ArrayList<Integer> list = new ArrayList<>(strings.length);
5882 for (int i = 0; i < strings.length; i++) {
5883 list.add(Integer.decode(strings[i]));
5884 }
5885 intent.putExtra(key, list);
5886 }
5887 break;
5888 case "--el": {
5889 String key = cmd.getNextArgRequired();
5890 String value = cmd.getNextArgRequired();
5891 intent.putExtra(key, Long.valueOf(value));
5892 }
5893 break;
5894 case "--ela": {
5895 String key = cmd.getNextArgRequired();
5896 String value = cmd.getNextArgRequired();
5897 String[] strings = value.split(",");
5898 long[] list = new long[strings.length];
5899 for (int i = 0; i < strings.length; i++) {
5900 list[i] = Long.valueOf(strings[i]);
5901 }
5902 intent.putExtra(key, list);
5903 hasIntentInfo = true;
5904 }
5905 break;
5906 case "--elal": {
5907 String key = cmd.getNextArgRequired();
5908 String value = cmd.getNextArgRequired();
5909 String[] strings = value.split(",");
5910 ArrayList<Long> list = new ArrayList<>(strings.length);
5911 for (int i = 0; i < strings.length; i++) {
5912 list.add(Long.valueOf(strings[i]));
5913 }
5914 intent.putExtra(key, list);
5915 hasIntentInfo = true;
5916 }
5917 break;
5918 case "--ef": {
5919 String key = cmd.getNextArgRequired();
5920 String value = cmd.getNextArgRequired();
5921 intent.putExtra(key, Float.valueOf(value));
5922 hasIntentInfo = true;
5923 }
5924 break;
5925 case "--efa": {
5926 String key = cmd.getNextArgRequired();
5927 String value = cmd.getNextArgRequired();
5928 String[] strings = value.split(",");
5929 float[] list = new float[strings.length];
5930 for (int i = 0; i < strings.length; i++) {
5931 list[i] = Float.valueOf(strings[i]);
5932 }
5933 intent.putExtra(key, list);
5934 hasIntentInfo = true;
5935 }
5936 break;
5937 case "--efal": {
5938 String key = cmd.getNextArgRequired();
5939 String value = cmd.getNextArgRequired();
5940 String[] strings = value.split(",");
5941 ArrayList<Float> list = new ArrayList<>(strings.length);
5942 for (int i = 0; i < strings.length; i++) {
5943 list.add(Float.valueOf(strings[i]));
5944 }
5945 intent.putExtra(key, list);
5946 hasIntentInfo = true;
5947 }
5948 break;
5949 case "--esa": {
5950 String key = cmd.getNextArgRequired();
5951 String value = cmd.getNextArgRequired();
5952 // Split on commas unless they are preceeded by an escape.
5953 // The escape character must be escaped for the string and
5954 // again for the regex, thus four escape characters become one.
5955 String[] strings = value.split("(?<!\\\\),");
5956 intent.putExtra(key, strings);
5957 hasIntentInfo = true;
5958 }
5959 break;
5960 case "--esal": {
5961 String key = cmd.getNextArgRequired();
5962 String value = cmd.getNextArgRequired();
5963 // Split on commas unless they are preceeded by an escape.
5964 // The escape character must be escaped for the string and
5965 // again for the regex, thus four escape characters become one.
5966 String[] strings = value.split("(?<!\\\\),");
5967 ArrayList<String> list = new ArrayList<>(strings.length);
5968 for (int i = 0; i < strings.length; i++) {
5969 list.add(strings[i]);
5970 }
5971 intent.putExtra(key, list);
5972 hasIntentInfo = true;
5973 }
5974 break;
5975 case "--ez": {
5976 String key = cmd.getNextArgRequired();
5977 String value = cmd.getNextArgRequired().toLowerCase();
5978 // Boolean.valueOf() results in false for anything that is not "true", which is
5979 // error-prone in shell commands
5980 boolean arg;
5981 if ("true".equals(value) || "t".equals(value)) {
5982 arg = true;
5983 } else if ("false".equals(value) || "f".equals(value)) {
5984 arg = false;
5985 } else {
5986 try {
5987 arg = Integer.decode(value) != 0;
5988 } catch (NumberFormatException ex) {
5989 throw new IllegalArgumentException("Invalid boolean value: " + value);
5990 }
5991 }
5992
5993 intent.putExtra(key, arg);
5994 }
5995 break;
5996 case "-n": {
5997 String str = cmd.getNextArgRequired();
5998 ComponentName cn = ComponentName.unflattenFromString(str);
5999 if (cn == null)
6000 throw new IllegalArgumentException("Bad component name: " + str);
6001 intent.setComponent(cn);
6002 if (intent == baseIntent) {
6003 hasIntentInfo = true;
6004 }
6005 }
6006 break;
6007 case "-p": {
6008 String str = cmd.getNextArgRequired();
6009 intent.setPackage(str);
6010 if (intent == baseIntent) {
6011 hasIntentInfo = true;
6012 }
6013 }
6014 break;
6015 case "-f":
6016 String str = cmd.getNextArgRequired();
6017 intent.setFlags(Integer.decode(str).intValue());
6018 break;
6019 case "--grant-read-uri-permission":
6020 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6021 break;
6022 case "--grant-write-uri-permission":
6023 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6024 break;
6025 case "--grant-persistable-uri-permission":
6026 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6027 break;
6028 case "--grant-prefix-uri-permission":
6029 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6030 break;
6031 case "--exclude-stopped-packages":
6032 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6033 break;
6034 case "--include-stopped-packages":
6035 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6036 break;
6037 case "--debug-log-resolution":
6038 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6039 break;
6040 case "--activity-brought-to-front":
6041 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6042 break;
6043 case "--activity-clear-top":
6044 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6045 break;
6046 case "--activity-clear-when-task-reset":
6047 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6048 break;
6049 case "--activity-exclude-from-recents":
6050 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6051 break;
6052 case "--activity-launched-from-history":
6053 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6054 break;
6055 case "--activity-multiple-task":
6056 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6057 break;
6058 case "--activity-no-animation":
6059 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6060 break;
6061 case "--activity-no-history":
6062 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6063 break;
6064 case "--activity-no-user-action":
6065 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6066 break;
6067 case "--activity-previous-is-top":
6068 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6069 break;
6070 case "--activity-reorder-to-front":
6071 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6072 break;
6073 case "--activity-reset-task-if-needed":
6074 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6075 break;
6076 case "--activity-single-top":
6077 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6078 break;
6079 case "--activity-clear-task":
6080 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6081 break;
6082 case "--activity-task-on-home":
6083 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6084 break;
6085 case "--receiver-registered-only":
6086 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6087 break;
6088 case "--receiver-replace-pending":
6089 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6090 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006091 case "--receiver-foreground":
6092 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6093 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006094 case "--receiver-no-abort":
6095 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6096 break;
6097 case "--receiver-include-background":
6098 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6099 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006100 case "--selector":
6101 intent.setDataAndType(data, type);
6102 intent = new Intent();
6103 break;
6104 default:
6105 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6106 // Okay, caller handled this option.
6107 } else {
6108 throw new IllegalArgumentException("Unknown option: " + opt);
6109 }
6110 break;
6111 }
6112 }
6113 intent.setDataAndType(data, type);
6114
6115 final boolean hasSelector = intent != baseIntent;
6116 if (hasSelector) {
6117 // A selector was specified; fix up.
6118 baseIntent.setSelector(intent);
6119 intent = baseIntent;
6120 }
6121
6122 String arg = cmd.getNextArg();
6123 baseIntent = null;
6124 if (arg == null) {
6125 if (hasSelector) {
6126 // If a selector has been specified, and no arguments
6127 // have been supplied for the main Intent, then we can
6128 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6129 // need to have a component name specified yet, the
6130 // selector will take care of that.
6131 baseIntent = new Intent(Intent.ACTION_MAIN);
6132 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6133 }
6134 } else if (arg.indexOf(':') >= 0) {
6135 // The argument is a URI. Fully parse it, and use that result
6136 // to fill in any data not specified so far.
6137 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6138 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6139 } else if (arg.indexOf('/') >= 0) {
6140 // The argument is a component name. Build an Intent to launch
6141 // it.
6142 baseIntent = new Intent(Intent.ACTION_MAIN);
6143 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6144 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6145 } else {
6146 // Assume the argument is a package name.
6147 baseIntent = new Intent(Intent.ACTION_MAIN);
6148 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6149 baseIntent.setPackage(arg);
6150 }
6151 if (baseIntent != null) {
6152 Bundle extras = intent.getExtras();
6153 intent.replaceExtras((Bundle)null);
6154 Bundle uriExtras = baseIntent.getExtras();
6155 baseIntent.replaceExtras((Bundle)null);
6156 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6157 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6158 for (String c : cats) {
6159 baseIntent.removeCategory(c);
6160 }
6161 }
6162 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6163 if (extras == null) {
6164 extras = uriExtras;
6165 } else if (uriExtras != null) {
6166 uriExtras.putAll(extras);
6167 extras = uriExtras;
6168 }
6169 intent.replaceExtras(extras);
6170 hasIntentInfo = true;
6171 }
6172
6173 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6174 return intent;
6175 }
6176
6177 /** @hide */
6178 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6179 final String[] lines = new String[] {
6180 "<INTENT> specifications include these flags and arguments:",
6181 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6182 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6183 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6184 " [--esn <EXTRA_KEY> ...]",
6185 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6186 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6187 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6188 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6189 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6190 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6191 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6192 " (mutiple extras passed as Integer[])",
6193 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6194 " (mutiple extras passed as List<Integer>)",
6195 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6196 " (mutiple extras passed as Long[])",
6197 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6198 " (mutiple extras passed as List<Long>)",
6199 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6200 " (mutiple extras passed as Float[])",
6201 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6202 " (mutiple extras passed as List<Float>)",
6203 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6204 " (mutiple extras passed as String[]; to embed a comma into a string,",
6205 " escape it using \"\\,\")",
6206 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6207 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6208 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006209 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006210 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6211 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6212 " [--debug-log-resolution] [--exclude-stopped-packages]",
6213 " [--include-stopped-packages]",
6214 " [--activity-brought-to-front] [--activity-clear-top]",
6215 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6216 " [--activity-launched-from-history] [--activity-multiple-task]",
6217 " [--activity-no-animation] [--activity-no-history]",
6218 " [--activity-no-user-action] [--activity-previous-is-top]",
6219 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6220 " [--activity-single-top] [--activity-clear-task]",
6221 " [--activity-task-on-home]",
6222 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006223 " [--receiver-foreground] [--receiver-no-abort]",
6224 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006225 " [--selector]",
6226 " [<URI> | <PACKAGE> | <COMPONENT>]"
6227 };
6228 for (String line : lines) {
6229 pw.print(prefix);
6230 pw.println(line);
6231 }
6232 }
6233
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006234 /**
6235 * Retrieve the general action to be performed, such as
6236 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6237 * the information in the intent should be interpreted -- most importantly,
6238 * what to do with the data returned by {@link #getData}.
6239 *
6240 * @return The action of this intent or null if none is specified.
6241 *
6242 * @see #setAction
6243 */
6244 public String getAction() {
6245 return mAction;
6246 }
6247
6248 /**
6249 * Retrieve data this intent is operating on. This URI specifies the name
6250 * of the data; often it uses the content: scheme, specifying data in a
6251 * content provider. Other schemes may be handled by specific activities,
6252 * such as http: by the web browser.
6253 *
6254 * @return The URI of the data this intent is targeting or null.
6255 *
6256 * @see #getScheme
6257 * @see #setData
6258 */
6259 public Uri getData() {
6260 return mData;
6261 }
6262
6263 /**
6264 * The same as {@link #getData()}, but returns the URI as an encoded
6265 * String.
6266 */
6267 public String getDataString() {
6268 return mData != null ? mData.toString() : null;
6269 }
6270
6271 /**
6272 * Return the scheme portion of the intent's data. If the data is null or
6273 * does not include a scheme, null is returned. Otherwise, the scheme
6274 * prefix without the final ':' is returned, i.e. "http".
6275 *
6276 * <p>This is the same as calling getData().getScheme() (and checking for
6277 * null data).
6278 *
6279 * @return The scheme of this intent.
6280 *
6281 * @see #getData
6282 */
6283 public String getScheme() {
6284 return mData != null ? mData.getScheme() : null;
6285 }
6286
6287 /**
6288 * Retrieve any explicit MIME type included in the intent. This is usually
6289 * null, as the type is determined by the intent data.
6290 *
6291 * @return If a type was manually set, it is returned; else null is
6292 * returned.
6293 *
6294 * @see #resolveType(ContentResolver)
6295 * @see #setType
6296 */
6297 public String getType() {
6298 return mType;
6299 }
6300
6301 /**
6302 * Return the MIME data type of this intent. If the type field is
6303 * explicitly set, that is simply returned. Otherwise, if the data is set,
6304 * the type of that data is returned. If neither fields are set, a null is
6305 * returned.
6306 *
6307 * @return The MIME type of this intent.
6308 *
6309 * @see #getType
6310 * @see #resolveType(ContentResolver)
6311 */
6312 public String resolveType(Context context) {
6313 return resolveType(context.getContentResolver());
6314 }
6315
6316 /**
6317 * Return the MIME data type of this intent. If the type field is
6318 * explicitly set, that is simply returned. Otherwise, if the data is set,
6319 * the type of that data is returned. If neither fields are set, a null is
6320 * returned.
6321 *
6322 * @param resolver A ContentResolver that can be used to determine the MIME
6323 * type of the intent's data.
6324 *
6325 * @return The MIME type of this intent.
6326 *
6327 * @see #getType
6328 * @see #resolveType(Context)
6329 */
6330 public String resolveType(ContentResolver resolver) {
6331 if (mType != null) {
6332 return mType;
6333 }
6334 if (mData != null) {
6335 if ("content".equals(mData.getScheme())) {
6336 return resolver.getType(mData);
6337 }
6338 }
6339 return null;
6340 }
6341
6342 /**
6343 * Return the MIME data type of this intent, only if it will be needed for
6344 * intent resolution. This is not generally useful for application code;
6345 * it is used by the frameworks for communicating with back-end system
6346 * services.
6347 *
6348 * @param resolver A ContentResolver that can be used to determine the MIME
6349 * type of the intent's data.
6350 *
6351 * @return The MIME type of this intent, or null if it is unknown or not
6352 * needed.
6353 */
6354 public String resolveTypeIfNeeded(ContentResolver resolver) {
6355 if (mComponent != null) {
6356 return mType;
6357 }
6358 return resolveType(resolver);
6359 }
6360
6361 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006362 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006363 *
6364 * @param category The category to check.
6365 *
6366 * @return boolean True if the intent contains the category, else false.
6367 *
6368 * @see #getCategories
6369 * @see #addCategory
6370 */
6371 public boolean hasCategory(String category) {
6372 return mCategories != null && mCategories.contains(category);
6373 }
6374
6375 /**
6376 * Return the set of all categories in the intent. If there are no categories,
6377 * returns NULL.
6378 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006379 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006380 *
6381 * @see #hasCategory
6382 * @see #addCategory
6383 */
6384 public Set<String> getCategories() {
6385 return mCategories;
6386 }
6387
6388 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006389 * Return the specific selector associated with this Intent. If there is
6390 * none, returns null. See {@link #setSelector} for more information.
6391 *
6392 * @see #setSelector
6393 */
6394 public Intent getSelector() {
6395 return mSelector;
6396 }
6397
6398 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006399 * Return the {@link ClipData} associated with this Intent. If there is
6400 * none, returns null. See {@link #setClipData} for more information.
6401 *
John Spurlock125d1332013-11-25 11:58:37 -05006402 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006403 */
6404 public ClipData getClipData() {
6405 return mClipData;
6406 }
6407
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006408 /** @hide */
6409 public int getContentUserHint() {
6410 return mContentUserHint;
6411 }
6412
Todd Kennedyb3b431302017-03-20 16:05:48 -07006413 /** @hide */
6414 public String getLaunchToken() {
6415 return mLaunchToken;
6416 }
6417
6418 /** @hide */
6419 public void setLaunchToken(String launchToken) {
6420 mLaunchToken = launchToken;
6421 }
6422
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006423 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006424 * Sets the ClassLoader that will be used when unmarshalling
6425 * any Parcelable values from the extras of this Intent.
6426 *
6427 * @param loader a ClassLoader, or null to use the default loader
6428 * at the time of unmarshalling.
6429 */
6430 public void setExtrasClassLoader(ClassLoader loader) {
6431 if (mExtras != null) {
6432 mExtras.setClassLoader(loader);
6433 }
6434 }
6435
6436 /**
6437 * Returns true if an extra value is associated with the given name.
6438 * @param name the extra's name
6439 * @return true if the given extra is present.
6440 */
6441 public boolean hasExtra(String name) {
6442 return mExtras != null && mExtras.containsKey(name);
6443 }
6444
6445 /**
6446 * Returns true if the Intent's extras contain a parcelled file descriptor.
6447 * @return true if the Intent contains a parcelled file descriptor.
6448 */
6449 public boolean hasFileDescriptors() {
6450 return mExtras != null && mExtras.hasFileDescriptors();
6451 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006452
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006453 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006454 public void setAllowFds(boolean allowFds) {
6455 if (mExtras != null) {
6456 mExtras.setAllowFds(allowFds);
6457 }
6458 }
6459
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006460 /** {@hide} */
6461 public void setDefusable(boolean defusable) {
6462 if (mExtras != null) {
6463 mExtras.setDefusable(defusable);
6464 }
6465 }
6466
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006467 /**
6468 * Retrieve extended data from the intent.
6469 *
6470 * @param name The name of the desired item.
6471 *
6472 * @return the value of an item that previously added with putExtra()
6473 * or null if none was found.
6474 *
6475 * @deprecated
6476 * @hide
6477 */
6478 @Deprecated
6479 public Object getExtra(String name) {
6480 return getExtra(name, null);
6481 }
6482
6483 /**
6484 * Retrieve extended data from the intent.
6485 *
6486 * @param name The name of the desired item.
6487 * @param defaultValue the value to be returned if no value of the desired
6488 * type is stored with the given name.
6489 *
6490 * @return the value of an item that previously added with putExtra()
6491 * or the default value if none was found.
6492 *
6493 * @see #putExtra(String, boolean)
6494 */
6495 public boolean getBooleanExtra(String name, boolean defaultValue) {
6496 return mExtras == null ? defaultValue :
6497 mExtras.getBoolean(name, defaultValue);
6498 }
6499
6500 /**
6501 * Retrieve extended data from the intent.
6502 *
6503 * @param name The name of the desired item.
6504 * @param defaultValue the value to be returned if no value of the desired
6505 * type is stored with the given name.
6506 *
6507 * @return the value of an item that previously added with putExtra()
6508 * or the default value if none was found.
6509 *
6510 * @see #putExtra(String, byte)
6511 */
6512 public byte getByteExtra(String name, byte defaultValue) {
6513 return mExtras == null ? defaultValue :
6514 mExtras.getByte(name, defaultValue);
6515 }
6516
6517 /**
6518 * Retrieve extended data from the intent.
6519 *
6520 * @param name The name of the desired item.
6521 * @param defaultValue the value to be returned if no value of the desired
6522 * type is stored with the given name.
6523 *
6524 * @return the value of an item that previously added with putExtra()
6525 * or the default value if none was found.
6526 *
6527 * @see #putExtra(String, short)
6528 */
6529 public short getShortExtra(String name, short defaultValue) {
6530 return mExtras == null ? defaultValue :
6531 mExtras.getShort(name, defaultValue);
6532 }
6533
6534 /**
6535 * Retrieve extended data from the intent.
6536 *
6537 * @param name The name of the desired item.
6538 * @param defaultValue the value to be returned if no value of the desired
6539 * type is stored with the given name.
6540 *
6541 * @return the value of an item that previously added with putExtra()
6542 * or the default value if none was found.
6543 *
6544 * @see #putExtra(String, char)
6545 */
6546 public char getCharExtra(String name, char defaultValue) {
6547 return mExtras == null ? defaultValue :
6548 mExtras.getChar(name, defaultValue);
6549 }
6550
6551 /**
6552 * Retrieve extended data from the intent.
6553 *
6554 * @param name The name of the desired item.
6555 * @param defaultValue the value to be returned if no value of the desired
6556 * type is stored with the given name.
6557 *
6558 * @return the value of an item that previously added with putExtra()
6559 * or the default value if none was found.
6560 *
6561 * @see #putExtra(String, int)
6562 */
6563 public int getIntExtra(String name, int defaultValue) {
6564 return mExtras == null ? defaultValue :
6565 mExtras.getInt(name, defaultValue);
6566 }
6567
6568 /**
6569 * Retrieve extended data from the intent.
6570 *
6571 * @param name The name of the desired item.
6572 * @param defaultValue the value to be returned if no value of the desired
6573 * type is stored with the given name.
6574 *
6575 * @return the value of an item that previously added with putExtra()
6576 * or the default value if none was found.
6577 *
6578 * @see #putExtra(String, long)
6579 */
6580 public long getLongExtra(String name, long defaultValue) {
6581 return mExtras == null ? defaultValue :
6582 mExtras.getLong(name, defaultValue);
6583 }
6584
6585 /**
6586 * Retrieve extended data from the intent.
6587 *
6588 * @param name The name of the desired item.
6589 * @param defaultValue the value to be returned if no value of the desired
6590 * type is stored with the given name.
6591 *
6592 * @return the value of an item that previously added with putExtra(),
6593 * or the default value if no such item is present
6594 *
6595 * @see #putExtra(String, float)
6596 */
6597 public float getFloatExtra(String name, float defaultValue) {
6598 return mExtras == null ? defaultValue :
6599 mExtras.getFloat(name, defaultValue);
6600 }
6601
6602 /**
6603 * Retrieve extended data from the intent.
6604 *
6605 * @param name The name of the desired item.
6606 * @param defaultValue the value to be returned if no value of the desired
6607 * type is stored with the given name.
6608 *
6609 * @return the value of an item that previously added with putExtra()
6610 * or the default value if none was found.
6611 *
6612 * @see #putExtra(String, double)
6613 */
6614 public double getDoubleExtra(String name, double defaultValue) {
6615 return mExtras == null ? defaultValue :
6616 mExtras.getDouble(name, defaultValue);
6617 }
6618
6619 /**
6620 * Retrieve extended data from the intent.
6621 *
6622 * @param name The name of the desired item.
6623 *
6624 * @return the value of an item that previously added with putExtra()
6625 * or null if no String value was found.
6626 *
6627 * @see #putExtra(String, String)
6628 */
6629 public String getStringExtra(String name) {
6630 return mExtras == null ? null : mExtras.getString(name);
6631 }
6632
6633 /**
6634 * Retrieve extended data from the intent.
6635 *
6636 * @param name The name of the desired item.
6637 *
6638 * @return the value of an item that previously added with putExtra()
6639 * or null if no CharSequence value was found.
6640 *
6641 * @see #putExtra(String, CharSequence)
6642 */
6643 public CharSequence getCharSequenceExtra(String name) {
6644 return mExtras == null ? null : mExtras.getCharSequence(name);
6645 }
6646
6647 /**
6648 * Retrieve extended data from the intent.
6649 *
6650 * @param name The name of the desired item.
6651 *
6652 * @return the value of an item that previously added with putExtra()
6653 * or null if no Parcelable value was found.
6654 *
6655 * @see #putExtra(String, Parcelable)
6656 */
6657 public <T extends Parcelable> T getParcelableExtra(String name) {
6658 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6659 }
6660
6661 /**
6662 * Retrieve extended data from the intent.
6663 *
6664 * @param name The name of the desired item.
6665 *
6666 * @return the value of an item that previously added with putExtra()
6667 * or null if no Parcelable[] value was found.
6668 *
6669 * @see #putExtra(String, Parcelable[])
6670 */
6671 public Parcelable[] getParcelableArrayExtra(String name) {
6672 return mExtras == null ? null : mExtras.getParcelableArray(name);
6673 }
6674
6675 /**
6676 * Retrieve extended data from the intent.
6677 *
6678 * @param name The name of the desired item.
6679 *
6680 * @return the value of an item that previously added with putExtra()
6681 * or null if no ArrayList<Parcelable> value was found.
6682 *
6683 * @see #putParcelableArrayListExtra(String, ArrayList)
6684 */
6685 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6686 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6687 }
6688
6689 /**
6690 * Retrieve extended data from the intent.
6691 *
6692 * @param name The name of the desired item.
6693 *
6694 * @return the value of an item that previously added with putExtra()
6695 * or null if no Serializable value was found.
6696 *
6697 * @see #putExtra(String, Serializable)
6698 */
6699 public Serializable getSerializableExtra(String name) {
6700 return mExtras == null ? null : mExtras.getSerializable(name);
6701 }
6702
6703 /**
6704 * Retrieve extended data from the intent.
6705 *
6706 * @param name The name of the desired item.
6707 *
6708 * @return the value of an item that previously added with putExtra()
6709 * or null if no ArrayList<Integer> value was found.
6710 *
6711 * @see #putIntegerArrayListExtra(String, ArrayList)
6712 */
6713 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6714 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6715 }
6716
6717 /**
6718 * Retrieve extended data from the intent.
6719 *
6720 * @param name The name of the desired item.
6721 *
6722 * @return the value of an item that previously added with putExtra()
6723 * or null if no ArrayList<String> value was found.
6724 *
6725 * @see #putStringArrayListExtra(String, ArrayList)
6726 */
6727 public ArrayList<String> getStringArrayListExtra(String name) {
6728 return mExtras == null ? null : mExtras.getStringArrayList(name);
6729 }
6730
6731 /**
6732 * Retrieve extended data from the intent.
6733 *
6734 * @param name The name of the desired item.
6735 *
6736 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006737 * or null if no ArrayList<CharSequence> value was found.
6738 *
6739 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6740 */
6741 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6742 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6743 }
6744
6745 /**
6746 * Retrieve extended data from the intent.
6747 *
6748 * @param name The name of the desired item.
6749 *
6750 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006751 * or null if no boolean array value was found.
6752 *
6753 * @see #putExtra(String, boolean[])
6754 */
6755 public boolean[] getBooleanArrayExtra(String name) {
6756 return mExtras == null ? null : mExtras.getBooleanArray(name);
6757 }
6758
6759 /**
6760 * Retrieve extended data from the intent.
6761 *
6762 * @param name The name of the desired item.
6763 *
6764 * @return the value of an item that previously added with putExtra()
6765 * or null if no byte array value was found.
6766 *
6767 * @see #putExtra(String, byte[])
6768 */
6769 public byte[] getByteArrayExtra(String name) {
6770 return mExtras == null ? null : mExtras.getByteArray(name);
6771 }
6772
6773 /**
6774 * Retrieve extended data from the intent.
6775 *
6776 * @param name The name of the desired item.
6777 *
6778 * @return the value of an item that previously added with putExtra()
6779 * or null if no short array value was found.
6780 *
6781 * @see #putExtra(String, short[])
6782 */
6783 public short[] getShortArrayExtra(String name) {
6784 return mExtras == null ? null : mExtras.getShortArray(name);
6785 }
6786
6787 /**
6788 * Retrieve extended data from the intent.
6789 *
6790 * @param name The name of the desired item.
6791 *
6792 * @return the value of an item that previously added with putExtra()
6793 * or null if no char array value was found.
6794 *
6795 * @see #putExtra(String, char[])
6796 */
6797 public char[] getCharArrayExtra(String name) {
6798 return mExtras == null ? null : mExtras.getCharArray(name);
6799 }
6800
6801 /**
6802 * Retrieve extended data from the intent.
6803 *
6804 * @param name The name of the desired item.
6805 *
6806 * @return the value of an item that previously added with putExtra()
6807 * or null if no int array value was found.
6808 *
6809 * @see #putExtra(String, int[])
6810 */
6811 public int[] getIntArrayExtra(String name) {
6812 return mExtras == null ? null : mExtras.getIntArray(name);
6813 }
6814
6815 /**
6816 * Retrieve extended data from the intent.
6817 *
6818 * @param name The name of the desired item.
6819 *
6820 * @return the value of an item that previously added with putExtra()
6821 * or null if no long array value was found.
6822 *
6823 * @see #putExtra(String, long[])
6824 */
6825 public long[] getLongArrayExtra(String name) {
6826 return mExtras == null ? null : mExtras.getLongArray(name);
6827 }
6828
6829 /**
6830 * Retrieve extended data from the intent.
6831 *
6832 * @param name The name of the desired item.
6833 *
6834 * @return the value of an item that previously added with putExtra()
6835 * or null if no float array value was found.
6836 *
6837 * @see #putExtra(String, float[])
6838 */
6839 public float[] getFloatArrayExtra(String name) {
6840 return mExtras == null ? null : mExtras.getFloatArray(name);
6841 }
6842
6843 /**
6844 * Retrieve extended data from the intent.
6845 *
6846 * @param name The name of the desired item.
6847 *
6848 * @return the value of an item that previously added with putExtra()
6849 * or null if no double array value was found.
6850 *
6851 * @see #putExtra(String, double[])
6852 */
6853 public double[] getDoubleArrayExtra(String name) {
6854 return mExtras == null ? null : mExtras.getDoubleArray(name);
6855 }
6856
6857 /**
6858 * Retrieve extended data from the intent.
6859 *
6860 * @param name The name of the desired item.
6861 *
6862 * @return the value of an item that previously added with putExtra()
6863 * or null if no String array value was found.
6864 *
6865 * @see #putExtra(String, String[])
6866 */
6867 public String[] getStringArrayExtra(String name) {
6868 return mExtras == null ? null : mExtras.getStringArray(name);
6869 }
6870
6871 /**
6872 * Retrieve extended data from the intent.
6873 *
6874 * @param name The name of the desired item.
6875 *
6876 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006877 * or null if no CharSequence array value was found.
6878 *
6879 * @see #putExtra(String, CharSequence[])
6880 */
6881 public CharSequence[] getCharSequenceArrayExtra(String name) {
6882 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6883 }
6884
6885 /**
6886 * Retrieve extended data from the intent.
6887 *
6888 * @param name The name of the desired item.
6889 *
6890 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006891 * or null if no Bundle value was found.
6892 *
6893 * @see #putExtra(String, Bundle)
6894 */
6895 public Bundle getBundleExtra(String name) {
6896 return mExtras == null ? null : mExtras.getBundle(name);
6897 }
6898
6899 /**
6900 * Retrieve extended data from the intent.
6901 *
6902 * @param name The name of the desired item.
6903 *
6904 * @return the value of an item that previously added with putExtra()
6905 * or null if no IBinder value was found.
6906 *
6907 * @see #putExtra(String, IBinder)
6908 *
6909 * @deprecated
6910 * @hide
6911 */
6912 @Deprecated
6913 public IBinder getIBinderExtra(String name) {
6914 return mExtras == null ? null : mExtras.getIBinder(name);
6915 }
6916
6917 /**
6918 * Retrieve extended data from the intent.
6919 *
6920 * @param name The name of the desired item.
6921 * @param defaultValue The default value to return in case no item is
6922 * associated with the key 'name'
6923 *
6924 * @return the value of an item that previously added with putExtra()
6925 * or defaultValue if none was found.
6926 *
6927 * @see #putExtra
6928 *
6929 * @deprecated
6930 * @hide
6931 */
6932 @Deprecated
6933 public Object getExtra(String name, Object defaultValue) {
6934 Object result = defaultValue;
6935 if (mExtras != null) {
6936 Object result2 = mExtras.get(name);
6937 if (result2 != null) {
6938 result = result2;
6939 }
6940 }
6941
6942 return result;
6943 }
6944
6945 /**
6946 * Retrieves a map of extended data from the intent.
6947 *
6948 * @return the map of all extras previously added with putExtra(),
6949 * or null if none have been added.
6950 */
6951 public Bundle getExtras() {
6952 return (mExtras != null)
6953 ? new Bundle(mExtras)
6954 : null;
6955 }
6956
6957 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006958 * Filter extras to only basic types.
6959 * @hide
6960 */
6961 public void removeUnsafeExtras() {
6962 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006963 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006964 }
6965 }
6966
6967 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006968 * Retrieve any special flags associated with this intent. You will
6969 * normally just set them with {@link #setFlags} and let the system
6970 * take the appropriate action with them.
6971 *
6972 * @return int The currently set flags.
6973 *
6974 * @see #setFlags
6975 */
6976 public int getFlags() {
6977 return mFlags;
6978 }
6979
Dianne Hackborne7f97212011-02-24 14:40:20 -08006980 /** @hide */
6981 public boolean isExcludingStopped() {
6982 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6983 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6984 }
6985
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006986 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006987 * Retrieve the application package name this Intent is limited to. When
6988 * resolving an Intent, if non-null this limits the resolution to only
6989 * components in the given application package.
6990 *
6991 * @return The name of the application package for the Intent.
6992 *
6993 * @see #resolveActivity
6994 * @see #setPackage
6995 */
6996 public String getPackage() {
6997 return mPackage;
6998 }
6999
7000 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007001 * Retrieve the concrete component associated with the intent. When receiving
7002 * an intent, this is the component that was found to best handle it (that is,
7003 * yourself) and will always be non-null; in all other cases it will be
7004 * null unless explicitly set.
7005 *
7006 * @return The name of the application component to handle the intent.
7007 *
7008 * @see #resolveActivity
7009 * @see #setComponent
7010 */
7011 public ComponentName getComponent() {
7012 return mComponent;
7013 }
7014
7015 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007016 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7017 * used as a hint to the receiver for animations and the like. Null means that there
7018 * is no source bounds.
7019 */
7020 public Rect getSourceBounds() {
7021 return mSourceBounds;
7022 }
7023
7024 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007025 * Return the Activity component that should be used to handle this intent.
7026 * The appropriate component is determined based on the information in the
7027 * intent, evaluated as follows:
7028 *
7029 * <p>If {@link #getComponent} returns an explicit class, that is returned
7030 * without any further consideration.
7031 *
7032 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7033 * category to be considered.
7034 *
7035 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7036 * action.
7037 *
7038 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7039 * this type.
7040 *
7041 * <p>If {@link #addCategory} has added any categories, the activity must
7042 * handle ALL of the categories specified.
7043 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007044 * <p>If {@link #getPackage} is non-NULL, only activity components in
7045 * that application package will be considered.
7046 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007047 * <p>If there are no activities that satisfy all of these conditions, a
7048 * null string is returned.
7049 *
7050 * <p>If multiple activities are found to satisfy the intent, the one with
7051 * the highest priority will be used. If there are multiple activities
7052 * with the same priority, the system will either pick the best activity
7053 * based on user preference, or resolve to a system class that will allow
7054 * the user to pick an activity and forward from there.
7055 *
7056 * <p>This method is implemented simply by calling
7057 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7058 * true.</p>
7059 * <p> This API is called for you as part of starting an activity from an
7060 * intent. You do not normally need to call it yourself.</p>
7061 *
7062 * @param pm The package manager with which to resolve the Intent.
7063 *
7064 * @return Name of the component implementing an activity that can
7065 * display the intent.
7066 *
7067 * @see #setComponent
7068 * @see #getComponent
7069 * @see #resolveActivityInfo
7070 */
7071 public ComponentName resolveActivity(PackageManager pm) {
7072 if (mComponent != null) {
7073 return mComponent;
7074 }
7075
7076 ResolveInfo info = pm.resolveActivity(
7077 this, PackageManager.MATCH_DEFAULT_ONLY);
7078 if (info != null) {
7079 return new ComponentName(
7080 info.activityInfo.applicationInfo.packageName,
7081 info.activityInfo.name);
7082 }
7083
7084 return null;
7085 }
7086
7087 /**
7088 * Resolve the Intent into an {@link ActivityInfo}
7089 * describing the activity that should execute the intent. Resolution
7090 * follows the same rules as described for {@link #resolveActivity}, but
7091 * you get back the completely information about the resolved activity
7092 * instead of just its class name.
7093 *
7094 * @param pm The package manager with which to resolve the Intent.
7095 * @param flags Addition information to retrieve as per
7096 * {@link PackageManager#getActivityInfo(ComponentName, int)
7097 * PackageManager.getActivityInfo()}.
7098 *
7099 * @return PackageManager.ActivityInfo
7100 *
7101 * @see #resolveActivity
7102 */
7103 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7104 ActivityInfo ai = null;
7105 if (mComponent != null) {
7106 try {
7107 ai = pm.getActivityInfo(mComponent, flags);
7108 } catch (PackageManager.NameNotFoundException e) {
7109 // ignore
7110 }
7111 } else {
7112 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007113 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007114 if (info != null) {
7115 ai = info.activityInfo;
7116 }
7117 }
7118
7119 return ai;
7120 }
7121
7122 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007123 * Special function for use by the system to resolve service
7124 * intents to system apps. Throws an exception if there are
7125 * multiple potential matches to the Intent. Returns null if
7126 * there are no matches.
7127 * @hide
7128 */
7129 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7130 if (mComponent != null) {
7131 return mComponent;
7132 }
7133
7134 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7135 if (results == null) {
7136 return null;
7137 }
7138 ComponentName comp = null;
7139 for (int i=0; i<results.size(); i++) {
7140 ResolveInfo ri = results.get(i);
7141 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7142 continue;
7143 }
7144 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7145 ri.serviceInfo.name);
7146 if (comp != null) {
7147 throw new IllegalStateException("Multiple system services handle " + this
7148 + ": " + comp + ", " + foundComp);
7149 }
7150 comp = foundComp;
7151 }
7152 return comp;
7153 }
7154
7155 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007156 * Set the general action to be performed.
7157 *
7158 * @param action An action name, such as ACTION_VIEW. Application-specific
7159 * actions should be prefixed with the vendor's package name.
7160 *
7161 * @return Returns the same Intent object, for chaining multiple calls
7162 * into a single statement.
7163 *
7164 * @see #getAction
7165 */
7166 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007167 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007168 return this;
7169 }
7170
7171 /**
7172 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007173 * clears any type that was previously set by {@link #setType} or
7174 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007175 *
Nick Pellyccae4122012-01-09 14:12:58 -08007176 * <p><em>Note: scheme matching in the Android framework is
7177 * case-sensitive, unlike the formal RFC. As a result,
7178 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007179 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007180 * {@link #setDataAndNormalize}
7181 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007182 *
Nick Pellyccae4122012-01-09 14:12:58 -08007183 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007184 *
7185 * @return Returns the same Intent object, for chaining multiple calls
7186 * into a single statement.
7187 *
7188 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007189 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007190 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007191 */
7192 public Intent setData(Uri data) {
7193 mData = data;
7194 mType = null;
7195 return this;
7196 }
7197
7198 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007199 * Normalize and set the data this intent is operating on.
7200 *
7201 * <p>This method automatically clears any type that was
7202 * previously set (for example, by {@link #setType}).
7203 *
7204 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007205 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007206 * so really this is just a convenience method for
7207 * <pre>
7208 * setData(data.normalize())
7209 * </pre>
7210 *
7211 * @param data The Uri of the data this intent is now targeting.
7212 *
7213 * @return Returns the same Intent object, for chaining multiple calls
7214 * into a single statement.
7215 *
7216 * @see #getData
7217 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007218 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007219 */
7220 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007221 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007222 }
7223
7224 /**
7225 * Set an explicit MIME data type.
7226 *
7227 * <p>This is used to create intents that only specify a type and not data,
7228 * for example to indicate the type of data to return.
7229 *
7230 * <p>This method automatically clears any data that was
7231 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007232 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007233 * <p><em>Note: MIME type matching in the Android framework is
7234 * case-sensitive, unlike formal RFC MIME types. As a result,
7235 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007236 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7237 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007238 *
7239 * @param type The MIME type of the data being handled by this intent.
7240 *
7241 * @return Returns the same Intent object, for chaining multiple calls
7242 * into a single statement.
7243 *
7244 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007245 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007246 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007247 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007248 */
7249 public Intent setType(String type) {
7250 mData = null;
7251 mType = type;
7252 return this;
7253 }
7254
7255 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007256 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007257 *
Nick Pellyccae4122012-01-09 14:12:58 -08007258 * <p>This is used to create intents that only specify a type and not data,
7259 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007260 *
Nick Pellyccae4122012-01-09 14:12:58 -08007261 * <p>This method automatically clears any data that was
7262 * previously set (for example by {@link #setData}).
7263 *
7264 * <p>The MIME type is normalized using
7265 * {@link #normalizeMimeType} before it is set,
7266 * so really this is just a convenience method for
7267 * <pre>
7268 * setType(Intent.normalizeMimeType(type))
7269 * </pre>
7270 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007271 * @param type The MIME type of the data being handled by this intent.
7272 *
7273 * @return Returns the same Intent object, for chaining multiple calls
7274 * into a single statement.
7275 *
Nick Pellyccae4122012-01-09 14:12:58 -08007276 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007277 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007278 * @see #normalizeMimeType
7279 */
7280 public Intent setTypeAndNormalize(String type) {
7281 return setType(normalizeMimeType(type));
7282 }
7283
7284 /**
7285 * (Usually optional) Set the data for the intent along with an explicit
7286 * MIME data type. This method should very rarely be used -- it allows you
7287 * to override the MIME type that would ordinarily be inferred from the
7288 * data with your own type given here.
7289 *
7290 * <p><em>Note: MIME type and Uri scheme matching in the
7291 * Android framework is case-sensitive, unlike the formal RFC definitions.
7292 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007293 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007294 * {@link #setDataAndTypeAndNormalize}
7295 * to ensure that they are converted to lower case.</em>
7296 *
7297 * @param data The Uri of the data this intent is now targeting.
7298 * @param type The MIME type of the data being handled by this intent.
7299 *
7300 * @return Returns the same Intent object, for chaining multiple calls
7301 * into a single statement.
7302 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007303 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007304 * @see #setData
7305 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007306 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007307 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007308 */
7309 public Intent setDataAndType(Uri data, String type) {
7310 mData = data;
7311 mType = type;
7312 return this;
7313 }
7314
7315 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007316 * (Usually optional) Normalize and set both the data Uri and an explicit
7317 * MIME data type. This method should very rarely be used -- it allows you
7318 * to override the MIME type that would ordinarily be inferred from the
7319 * data with your own type given here.
7320 *
7321 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007322 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007323 * before they are set, so really this is just a convenience method for
7324 * <pre>
7325 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7326 * </pre>
7327 *
7328 * @param data The Uri of the data this intent is now targeting.
7329 * @param type The MIME type of the data being handled by this intent.
7330 *
7331 * @return Returns the same Intent object, for chaining multiple calls
7332 * into a single statement.
7333 *
7334 * @see #setType
7335 * @see #setData
7336 * @see #setDataAndType
7337 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007338 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007339 */
7340 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007341 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007342 }
7343
7344 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007345 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007346 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007347 * activities that provide <em>all</em> of the requested categories will be
7348 * used.
7349 *
7350 * @param category The desired category. This can be either one of the
7351 * predefined Intent categories, or a custom category in your own
7352 * namespace.
7353 *
7354 * @return Returns the same Intent object, for chaining multiple calls
7355 * into a single statement.
7356 *
7357 * @see #hasCategory
7358 * @see #removeCategory
7359 */
7360 public Intent addCategory(String category) {
7361 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007362 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007363 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007364 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007365 return this;
7366 }
7367
7368 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007369 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007370 *
7371 * @param category The category to remove.
7372 *
7373 * @see #addCategory
7374 */
7375 public void removeCategory(String category) {
7376 if (mCategories != null) {
7377 mCategories.remove(category);
7378 if (mCategories.size() == 0) {
7379 mCategories = null;
7380 }
7381 }
7382 }
7383
7384 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007385 * Set a selector for this Intent. This is a modification to the kinds of
7386 * things the Intent will match. If the selector is set, it will be used
7387 * when trying to find entities that can handle the Intent, instead of the
7388 * main contents of the Intent. This allows you build an Intent containing
7389 * a generic protocol while targeting it more specifically.
7390 *
7391 * <p>An example of where this may be used is with things like
7392 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7393 * Intent that will launch the Browser application. However, the correct
7394 * main entry point of an application is actually {@link #ACTION_MAIN}
7395 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7396 * used to specify the actual Activity to launch. If you launch the browser
7397 * with something different, undesired behavior may happen if the user has
7398 * previously or later launches it the normal way, since they do not match.
7399 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7400 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7401 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7402 *
7403 * <p>Setting a selector does not impact the behavior of
7404 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7405 * desired behavior of a selector -- it does not impact the base meaning
7406 * of the Intent, just what kinds of things will be matched against it
7407 * when determining who can handle it.</p>
7408 *
7409 * <p>You can not use both a selector and {@link #setPackage(String)} on
7410 * the same base Intent.</p>
7411 *
7412 * @param selector The desired selector Intent; set to null to not use
7413 * a special selector.
7414 */
7415 public void setSelector(Intent selector) {
7416 if (selector == this) {
7417 throw new IllegalArgumentException(
7418 "Intent being set as a selector of itself");
7419 }
7420 if (selector != null && mPackage != null) {
7421 throw new IllegalArgumentException(
7422 "Can't set selector when package name is already set");
7423 }
7424 mSelector = selector;
7425 }
7426
7427 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007428 * Set a {@link ClipData} associated with this Intent. This replaces any
7429 * previously set ClipData.
7430 *
7431 * <p>The ClipData in an intent is not used for Intent matching or other
7432 * such operations. Semantically it is like extras, used to transmit
7433 * additional data with the Intent. The main feature of using this over
7434 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7435 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7436 * items included in the clip data. This is useful, in particular, if
7437 * you want to transmit an Intent containing multiple <code>content:</code>
7438 * URIs for which the recipient may not have global permission to access the
7439 * content provider.
7440 *
7441 * <p>If the ClipData contains items that are themselves Intents, any
7442 * grant flags in those Intents will be ignored. Only the top-level flags
7443 * of the main Intent are respected, and will be applied to all Uri or
7444 * Intent items in the clip (or sub-items of the clip).
7445 *
7446 * <p>The MIME type, label, and icon in the ClipData object are not
7447 * directly used by Intent. Applications should generally rely on the
7448 * MIME type of the Intent itself, not what it may find in the ClipData.
7449 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007450 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007451 *
7452 * @param clip The new clip to set. May be null to clear the current clip.
7453 */
7454 public void setClipData(ClipData clip) {
7455 mClipData = clip;
7456 }
7457
7458 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007459 * This is NOT a secure mechanism to identify the user who sent the intent.
7460 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7461 * who sent the intent.
7462 * @hide
7463 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007464 public void prepareToLeaveUser(int userId) {
7465 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7466 // We want mContentUserHint to refer to the original user, so don't do anything.
7467 if (mContentUserHint == UserHandle.USER_CURRENT) {
7468 mContentUserHint = userId;
7469 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007470 }
7471
7472 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007473 * Add extended data to the intent. The name must include a package
7474 * prefix, for example the app com.android.contacts would use names
7475 * like "com.android.contacts.ShowAll".
7476 *
7477 * @param name The name of the extra data, with package prefix.
7478 * @param value The boolean data value.
7479 *
7480 * @return Returns the same Intent object, for chaining multiple calls
7481 * into a single statement.
7482 *
7483 * @see #putExtras
7484 * @see #removeExtra
7485 * @see #getBooleanExtra(String, boolean)
7486 */
7487 public Intent putExtra(String name, boolean value) {
7488 if (mExtras == null) {
7489 mExtras = new Bundle();
7490 }
7491 mExtras.putBoolean(name, value);
7492 return this;
7493 }
7494
7495 /**
7496 * Add extended data to the intent. The name must include a package
7497 * prefix, for example the app com.android.contacts would use names
7498 * like "com.android.contacts.ShowAll".
7499 *
7500 * @param name The name of the extra data, with package prefix.
7501 * @param value The byte data value.
7502 *
7503 * @return Returns the same Intent object, for chaining multiple calls
7504 * into a single statement.
7505 *
7506 * @see #putExtras
7507 * @see #removeExtra
7508 * @see #getByteExtra(String, byte)
7509 */
7510 public Intent putExtra(String name, byte value) {
7511 if (mExtras == null) {
7512 mExtras = new Bundle();
7513 }
7514 mExtras.putByte(name, value);
7515 return this;
7516 }
7517
7518 /**
7519 * Add extended data to the intent. The name must include a package
7520 * prefix, for example the app com.android.contacts would use names
7521 * like "com.android.contacts.ShowAll".
7522 *
7523 * @param name The name of the extra data, with package prefix.
7524 * @param value The char data value.
7525 *
7526 * @return Returns the same Intent object, for chaining multiple calls
7527 * into a single statement.
7528 *
7529 * @see #putExtras
7530 * @see #removeExtra
7531 * @see #getCharExtra(String, char)
7532 */
7533 public Intent putExtra(String name, char value) {
7534 if (mExtras == null) {
7535 mExtras = new Bundle();
7536 }
7537 mExtras.putChar(name, value);
7538 return this;
7539 }
7540
7541 /**
7542 * Add extended data to the intent. The name must include a package
7543 * prefix, for example the app com.android.contacts would use names
7544 * like "com.android.contacts.ShowAll".
7545 *
7546 * @param name The name of the extra data, with package prefix.
7547 * @param value The short data value.
7548 *
7549 * @return Returns the same Intent object, for chaining multiple calls
7550 * into a single statement.
7551 *
7552 * @see #putExtras
7553 * @see #removeExtra
7554 * @see #getShortExtra(String, short)
7555 */
7556 public Intent putExtra(String name, short value) {
7557 if (mExtras == null) {
7558 mExtras = new Bundle();
7559 }
7560 mExtras.putShort(name, value);
7561 return this;
7562 }
7563
7564 /**
7565 * Add extended data to the intent. The name must include a package
7566 * prefix, for example the app com.android.contacts would use names
7567 * like "com.android.contacts.ShowAll".
7568 *
7569 * @param name The name of the extra data, with package prefix.
7570 * @param value The integer data value.
7571 *
7572 * @return Returns the same Intent object, for chaining multiple calls
7573 * into a single statement.
7574 *
7575 * @see #putExtras
7576 * @see #removeExtra
7577 * @see #getIntExtra(String, int)
7578 */
7579 public Intent putExtra(String name, int value) {
7580 if (mExtras == null) {
7581 mExtras = new Bundle();
7582 }
7583 mExtras.putInt(name, value);
7584 return this;
7585 }
7586
7587 /**
7588 * Add extended data to the intent. The name must include a package
7589 * prefix, for example the app com.android.contacts would use names
7590 * like "com.android.contacts.ShowAll".
7591 *
7592 * @param name The name of the extra data, with package prefix.
7593 * @param value The long data value.
7594 *
7595 * @return Returns the same Intent object, for chaining multiple calls
7596 * into a single statement.
7597 *
7598 * @see #putExtras
7599 * @see #removeExtra
7600 * @see #getLongExtra(String, long)
7601 */
7602 public Intent putExtra(String name, long value) {
7603 if (mExtras == null) {
7604 mExtras = new Bundle();
7605 }
7606 mExtras.putLong(name, value);
7607 return this;
7608 }
7609
7610 /**
7611 * Add extended data to the intent. The name must include a package
7612 * prefix, for example the app com.android.contacts would use names
7613 * like "com.android.contacts.ShowAll".
7614 *
7615 * @param name The name of the extra data, with package prefix.
7616 * @param value The float data value.
7617 *
7618 * @return Returns the same Intent object, for chaining multiple calls
7619 * into a single statement.
7620 *
7621 * @see #putExtras
7622 * @see #removeExtra
7623 * @see #getFloatExtra(String, float)
7624 */
7625 public Intent putExtra(String name, float value) {
7626 if (mExtras == null) {
7627 mExtras = new Bundle();
7628 }
7629 mExtras.putFloat(name, value);
7630 return this;
7631 }
7632
7633 /**
7634 * Add extended data to the intent. The name must include a package
7635 * prefix, for example the app com.android.contacts would use names
7636 * like "com.android.contacts.ShowAll".
7637 *
7638 * @param name The name of the extra data, with package prefix.
7639 * @param value The double data value.
7640 *
7641 * @return Returns the same Intent object, for chaining multiple calls
7642 * into a single statement.
7643 *
7644 * @see #putExtras
7645 * @see #removeExtra
7646 * @see #getDoubleExtra(String, double)
7647 */
7648 public Intent putExtra(String name, double value) {
7649 if (mExtras == null) {
7650 mExtras = new Bundle();
7651 }
7652 mExtras.putDouble(name, value);
7653 return this;
7654 }
7655
7656 /**
7657 * Add extended data to the intent. The name must include a package
7658 * prefix, for example the app com.android.contacts would use names
7659 * like "com.android.contacts.ShowAll".
7660 *
7661 * @param name The name of the extra data, with package prefix.
7662 * @param value The String data value.
7663 *
7664 * @return Returns the same Intent object, for chaining multiple calls
7665 * into a single statement.
7666 *
7667 * @see #putExtras
7668 * @see #removeExtra
7669 * @see #getStringExtra(String)
7670 */
7671 public Intent putExtra(String name, String value) {
7672 if (mExtras == null) {
7673 mExtras = new Bundle();
7674 }
7675 mExtras.putString(name, value);
7676 return this;
7677 }
7678
7679 /**
7680 * Add extended data to the intent. The name must include a package
7681 * prefix, for example the app com.android.contacts would use names
7682 * like "com.android.contacts.ShowAll".
7683 *
7684 * @param name The name of the extra data, with package prefix.
7685 * @param value The CharSequence data value.
7686 *
7687 * @return Returns the same Intent object, for chaining multiple calls
7688 * into a single statement.
7689 *
7690 * @see #putExtras
7691 * @see #removeExtra
7692 * @see #getCharSequenceExtra(String)
7693 */
7694 public Intent putExtra(String name, CharSequence value) {
7695 if (mExtras == null) {
7696 mExtras = new Bundle();
7697 }
7698 mExtras.putCharSequence(name, value);
7699 return this;
7700 }
7701
7702 /**
7703 * Add extended data to the intent. The name must include a package
7704 * prefix, for example the app com.android.contacts would use names
7705 * like "com.android.contacts.ShowAll".
7706 *
7707 * @param name The name of the extra data, with package prefix.
7708 * @param value The Parcelable data value.
7709 *
7710 * @return Returns the same Intent object, for chaining multiple calls
7711 * into a single statement.
7712 *
7713 * @see #putExtras
7714 * @see #removeExtra
7715 * @see #getParcelableExtra(String)
7716 */
7717 public Intent putExtra(String name, Parcelable value) {
7718 if (mExtras == null) {
7719 mExtras = new Bundle();
7720 }
7721 mExtras.putParcelable(name, value);
7722 return this;
7723 }
7724
7725 /**
7726 * Add extended data to the intent. The name must include a package
7727 * prefix, for example the app com.android.contacts would use names
7728 * like "com.android.contacts.ShowAll".
7729 *
7730 * @param name The name of the extra data, with package prefix.
7731 * @param value The Parcelable[] data value.
7732 *
7733 * @return Returns the same Intent object, for chaining multiple calls
7734 * into a single statement.
7735 *
7736 * @see #putExtras
7737 * @see #removeExtra
7738 * @see #getParcelableArrayExtra(String)
7739 */
7740 public Intent putExtra(String name, Parcelable[] value) {
7741 if (mExtras == null) {
7742 mExtras = new Bundle();
7743 }
7744 mExtras.putParcelableArray(name, value);
7745 return this;
7746 }
7747
7748 /**
7749 * Add extended data to the intent. The name must include a package
7750 * prefix, for example the app com.android.contacts would use names
7751 * like "com.android.contacts.ShowAll".
7752 *
7753 * @param name The name of the extra data, with package prefix.
7754 * @param value The ArrayList<Parcelable> data value.
7755 *
7756 * @return Returns the same Intent object, for chaining multiple calls
7757 * into a single statement.
7758 *
7759 * @see #putExtras
7760 * @see #removeExtra
7761 * @see #getParcelableArrayListExtra(String)
7762 */
7763 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7764 if (mExtras == null) {
7765 mExtras = new Bundle();
7766 }
7767 mExtras.putParcelableArrayList(name, value);
7768 return this;
7769 }
7770
7771 /**
7772 * Add extended data to the intent. The name must include a package
7773 * prefix, for example the app com.android.contacts would use names
7774 * like "com.android.contacts.ShowAll".
7775 *
7776 * @param name The name of the extra data, with package prefix.
7777 * @param value The ArrayList<Integer> data value.
7778 *
7779 * @return Returns the same Intent object, for chaining multiple calls
7780 * into a single statement.
7781 *
7782 * @see #putExtras
7783 * @see #removeExtra
7784 * @see #getIntegerArrayListExtra(String)
7785 */
7786 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7787 if (mExtras == null) {
7788 mExtras = new Bundle();
7789 }
7790 mExtras.putIntegerArrayList(name, value);
7791 return this;
7792 }
7793
7794 /**
7795 * Add extended data to the intent. The name must include a package
7796 * prefix, for example the app com.android.contacts would use names
7797 * like "com.android.contacts.ShowAll".
7798 *
7799 * @param name The name of the extra data, with package prefix.
7800 * @param value The ArrayList<String> data value.
7801 *
7802 * @return Returns the same Intent object, for chaining multiple calls
7803 * into a single statement.
7804 *
7805 * @see #putExtras
7806 * @see #removeExtra
7807 * @see #getStringArrayListExtra(String)
7808 */
7809 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7810 if (mExtras == null) {
7811 mExtras = new Bundle();
7812 }
7813 mExtras.putStringArrayList(name, value);
7814 return this;
7815 }
7816
7817 /**
7818 * Add extended data to the intent. The name must include a package
7819 * prefix, for example the app com.android.contacts would use names
7820 * like "com.android.contacts.ShowAll".
7821 *
7822 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007823 * @param value The ArrayList<CharSequence> data value.
7824 *
7825 * @return Returns the same Intent object, for chaining multiple calls
7826 * into a single statement.
7827 *
7828 * @see #putExtras
7829 * @see #removeExtra
7830 * @see #getCharSequenceArrayListExtra(String)
7831 */
7832 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7833 if (mExtras == null) {
7834 mExtras = new Bundle();
7835 }
7836 mExtras.putCharSequenceArrayList(name, value);
7837 return this;
7838 }
7839
7840 /**
7841 * Add extended data to the intent. The name must include a package
7842 * prefix, for example the app com.android.contacts would use names
7843 * like "com.android.contacts.ShowAll".
7844 *
7845 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007846 * @param value The Serializable data value.
7847 *
7848 * @return Returns the same Intent object, for chaining multiple calls
7849 * into a single statement.
7850 *
7851 * @see #putExtras
7852 * @see #removeExtra
7853 * @see #getSerializableExtra(String)
7854 */
7855 public Intent putExtra(String name, Serializable value) {
7856 if (mExtras == null) {
7857 mExtras = new Bundle();
7858 }
7859 mExtras.putSerializable(name, value);
7860 return this;
7861 }
7862
7863 /**
7864 * Add extended data to the intent. The name must include a package
7865 * prefix, for example the app com.android.contacts would use names
7866 * like "com.android.contacts.ShowAll".
7867 *
7868 * @param name The name of the extra data, with package prefix.
7869 * @param value The boolean array data value.
7870 *
7871 * @return Returns the same Intent object, for chaining multiple calls
7872 * into a single statement.
7873 *
7874 * @see #putExtras
7875 * @see #removeExtra
7876 * @see #getBooleanArrayExtra(String)
7877 */
7878 public Intent putExtra(String name, boolean[] value) {
7879 if (mExtras == null) {
7880 mExtras = new Bundle();
7881 }
7882 mExtras.putBooleanArray(name, value);
7883 return this;
7884 }
7885
7886 /**
7887 * Add extended data to the intent. The name must include a package
7888 * prefix, for example the app com.android.contacts would use names
7889 * like "com.android.contacts.ShowAll".
7890 *
7891 * @param name The name of the extra data, with package prefix.
7892 * @param value The byte array data value.
7893 *
7894 * @return Returns the same Intent object, for chaining multiple calls
7895 * into a single statement.
7896 *
7897 * @see #putExtras
7898 * @see #removeExtra
7899 * @see #getByteArrayExtra(String)
7900 */
7901 public Intent putExtra(String name, byte[] value) {
7902 if (mExtras == null) {
7903 mExtras = new Bundle();
7904 }
7905 mExtras.putByteArray(name, value);
7906 return this;
7907 }
7908
7909 /**
7910 * Add extended data to the intent. The name must include a package
7911 * prefix, for example the app com.android.contacts would use names
7912 * like "com.android.contacts.ShowAll".
7913 *
7914 * @param name The name of the extra data, with package prefix.
7915 * @param value The short array data value.
7916 *
7917 * @return Returns the same Intent object, for chaining multiple calls
7918 * into a single statement.
7919 *
7920 * @see #putExtras
7921 * @see #removeExtra
7922 * @see #getShortArrayExtra(String)
7923 */
7924 public Intent putExtra(String name, short[] value) {
7925 if (mExtras == null) {
7926 mExtras = new Bundle();
7927 }
7928 mExtras.putShortArray(name, value);
7929 return this;
7930 }
7931
7932 /**
7933 * Add extended data to the intent. The name must include a package
7934 * prefix, for example the app com.android.contacts would use names
7935 * like "com.android.contacts.ShowAll".
7936 *
7937 * @param name The name of the extra data, with package prefix.
7938 * @param value The char array data value.
7939 *
7940 * @return Returns the same Intent object, for chaining multiple calls
7941 * into a single statement.
7942 *
7943 * @see #putExtras
7944 * @see #removeExtra
7945 * @see #getCharArrayExtra(String)
7946 */
7947 public Intent putExtra(String name, char[] value) {
7948 if (mExtras == null) {
7949 mExtras = new Bundle();
7950 }
7951 mExtras.putCharArray(name, value);
7952 return this;
7953 }
7954
7955 /**
7956 * Add extended data to the intent. The name must include a package
7957 * prefix, for example the app com.android.contacts would use names
7958 * like "com.android.contacts.ShowAll".
7959 *
7960 * @param name The name of the extra data, with package prefix.
7961 * @param value The int array data value.
7962 *
7963 * @return Returns the same Intent object, for chaining multiple calls
7964 * into a single statement.
7965 *
7966 * @see #putExtras
7967 * @see #removeExtra
7968 * @see #getIntArrayExtra(String)
7969 */
7970 public Intent putExtra(String name, int[] value) {
7971 if (mExtras == null) {
7972 mExtras = new Bundle();
7973 }
7974 mExtras.putIntArray(name, value);
7975 return this;
7976 }
7977
7978 /**
7979 * Add extended data to the intent. The name must include a package
7980 * prefix, for example the app com.android.contacts would use names
7981 * like "com.android.contacts.ShowAll".
7982 *
7983 * @param name The name of the extra data, with package prefix.
7984 * @param value The byte array data value.
7985 *
7986 * @return Returns the same Intent object, for chaining multiple calls
7987 * into a single statement.
7988 *
7989 * @see #putExtras
7990 * @see #removeExtra
7991 * @see #getLongArrayExtra(String)
7992 */
7993 public Intent putExtra(String name, long[] value) {
7994 if (mExtras == null) {
7995 mExtras = new Bundle();
7996 }
7997 mExtras.putLongArray(name, value);
7998 return this;
7999 }
8000
8001 /**
8002 * Add extended data to the intent. The name must include a package
8003 * prefix, for example the app com.android.contacts would use names
8004 * like "com.android.contacts.ShowAll".
8005 *
8006 * @param name The name of the extra data, with package prefix.
8007 * @param value The float array data value.
8008 *
8009 * @return Returns the same Intent object, for chaining multiple calls
8010 * into a single statement.
8011 *
8012 * @see #putExtras
8013 * @see #removeExtra
8014 * @see #getFloatArrayExtra(String)
8015 */
8016 public Intent putExtra(String name, float[] value) {
8017 if (mExtras == null) {
8018 mExtras = new Bundle();
8019 }
8020 mExtras.putFloatArray(name, value);
8021 return this;
8022 }
8023
8024 /**
8025 * Add extended data to the intent. The name must include a package
8026 * prefix, for example the app com.android.contacts would use names
8027 * like "com.android.contacts.ShowAll".
8028 *
8029 * @param name The name of the extra data, with package prefix.
8030 * @param value The double array data value.
8031 *
8032 * @return Returns the same Intent object, for chaining multiple calls
8033 * into a single statement.
8034 *
8035 * @see #putExtras
8036 * @see #removeExtra
8037 * @see #getDoubleArrayExtra(String)
8038 */
8039 public Intent putExtra(String name, double[] value) {
8040 if (mExtras == null) {
8041 mExtras = new Bundle();
8042 }
8043 mExtras.putDoubleArray(name, value);
8044 return this;
8045 }
8046
8047 /**
8048 * Add extended data to the intent. The name must include a package
8049 * prefix, for example the app com.android.contacts would use names
8050 * like "com.android.contacts.ShowAll".
8051 *
8052 * @param name The name of the extra data, with package prefix.
8053 * @param value The String array data value.
8054 *
8055 * @return Returns the same Intent object, for chaining multiple calls
8056 * into a single statement.
8057 *
8058 * @see #putExtras
8059 * @see #removeExtra
8060 * @see #getStringArrayExtra(String)
8061 */
8062 public Intent putExtra(String name, String[] value) {
8063 if (mExtras == null) {
8064 mExtras = new Bundle();
8065 }
8066 mExtras.putStringArray(name, value);
8067 return this;
8068 }
8069
8070 /**
8071 * Add extended data to the intent. The name must include a package
8072 * prefix, for example the app com.android.contacts would use names
8073 * like "com.android.contacts.ShowAll".
8074 *
8075 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008076 * @param value The CharSequence array data value.
8077 *
8078 * @return Returns the same Intent object, for chaining multiple calls
8079 * into a single statement.
8080 *
8081 * @see #putExtras
8082 * @see #removeExtra
8083 * @see #getCharSequenceArrayExtra(String)
8084 */
8085 public Intent putExtra(String name, CharSequence[] value) {
8086 if (mExtras == null) {
8087 mExtras = new Bundle();
8088 }
8089 mExtras.putCharSequenceArray(name, value);
8090 return this;
8091 }
8092
8093 /**
8094 * Add extended data to the intent. The name must include a package
8095 * prefix, for example the app com.android.contacts would use names
8096 * like "com.android.contacts.ShowAll".
8097 *
8098 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008099 * @param value The Bundle data value.
8100 *
8101 * @return Returns the same Intent object, for chaining multiple calls
8102 * into a single statement.
8103 *
8104 * @see #putExtras
8105 * @see #removeExtra
8106 * @see #getBundleExtra(String)
8107 */
8108 public Intent putExtra(String name, Bundle value) {
8109 if (mExtras == null) {
8110 mExtras = new Bundle();
8111 }
8112 mExtras.putBundle(name, value);
8113 return this;
8114 }
8115
8116 /**
8117 * Add extended data to the intent. The name must include a package
8118 * prefix, for example the app com.android.contacts would use names
8119 * like "com.android.contacts.ShowAll".
8120 *
8121 * @param name The name of the extra data, with package prefix.
8122 * @param value The IBinder data value.
8123 *
8124 * @return Returns the same Intent object, for chaining multiple calls
8125 * into a single statement.
8126 *
8127 * @see #putExtras
8128 * @see #removeExtra
8129 * @see #getIBinderExtra(String)
8130 *
8131 * @deprecated
8132 * @hide
8133 */
8134 @Deprecated
8135 public Intent putExtra(String name, IBinder value) {
8136 if (mExtras == null) {
8137 mExtras = new Bundle();
8138 }
8139 mExtras.putIBinder(name, value);
8140 return this;
8141 }
8142
8143 /**
8144 * Copy all extras in 'src' in to this intent.
8145 *
8146 * @param src Contains the extras to copy.
8147 *
8148 * @see #putExtra
8149 */
8150 public Intent putExtras(Intent src) {
8151 if (src.mExtras != null) {
8152 if (mExtras == null) {
8153 mExtras = new Bundle(src.mExtras);
8154 } else {
8155 mExtras.putAll(src.mExtras);
8156 }
8157 }
8158 return this;
8159 }
8160
8161 /**
8162 * Add a set of extended data to the intent. The keys must include a package
8163 * prefix, for example the app com.android.contacts would use names
8164 * like "com.android.contacts.ShowAll".
8165 *
8166 * @param extras The Bundle of extras to add to this intent.
8167 *
8168 * @see #putExtra
8169 * @see #removeExtra
8170 */
8171 public Intent putExtras(Bundle extras) {
8172 if (mExtras == null) {
8173 mExtras = new Bundle();
8174 }
8175 mExtras.putAll(extras);
8176 return this;
8177 }
8178
8179 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008180 * Completely replace the extras in the Intent with the extras in the
8181 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008182 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008183 * @param src The exact extras contained in this Intent are copied
8184 * into the target intent, replacing any that were previously there.
8185 */
8186 public Intent replaceExtras(Intent src) {
8187 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8188 return this;
8189 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008190
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008191 /**
8192 * Completely replace the extras in the Intent with the given Bundle of
8193 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008194 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008195 * @param extras The new set of extras in the Intent, or null to erase
8196 * all extras.
8197 */
8198 public Intent replaceExtras(Bundle extras) {
8199 mExtras = extras != null ? new Bundle(extras) : null;
8200 return this;
8201 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008202
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008203 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008204 * Remove extended data from the intent.
8205 *
8206 * @see #putExtra
8207 */
8208 public void removeExtra(String name) {
8209 if (mExtras != null) {
8210 mExtras.remove(name);
8211 if (mExtras.size() == 0) {
8212 mExtras = null;
8213 }
8214 }
8215 }
8216
8217 /**
8218 * Set special flags controlling how this intent is handled. Most values
8219 * here depend on the type of component being executed by the Intent,
8220 * specifically the FLAG_ACTIVITY_* flags are all for use with
8221 * {@link Context#startActivity Context.startActivity()} and the
8222 * FLAG_RECEIVER_* flags are all for use with
8223 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8224 *
Scott Main7aee61f2011-02-08 11:25:01 -08008225 * <p>See the
8226 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8227 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008228 * the behavior of your application.
8229 *
8230 * @param flags The desired flags.
8231 *
8232 * @return Returns the same Intent object, for chaining multiple calls
8233 * into a single statement.
8234 *
8235 * @see #getFlags
8236 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008237 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008238 *
8239 * @see #FLAG_GRANT_READ_URI_PERMISSION
8240 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008241 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8242 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008243 * @see #FLAG_DEBUG_LOG_RESOLUTION
8244 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008245 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008246 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008247 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008248 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008249 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8250 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008251 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008252 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008253 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008254 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008255 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008256 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008257 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008258 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8259 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008260 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008261 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008262 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008263 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8264 */
8265 public Intent setFlags(int flags) {
8266 mFlags = flags;
8267 return this;
8268 }
8269
8270 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008271 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008272 *
8273 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008274 * @return Returns the same Intent object, for chaining multiple calls into
8275 * a single statement.
8276 * @see #setFlags(int)
8277 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008278 */
8279 public Intent addFlags(int flags) {
8280 mFlags |= flags;
8281 return this;
8282 }
8283
8284 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008285 * Remove these flags from the intent.
8286 *
8287 * @param flags The flags to remove.
8288 * @see #setFlags(int)
8289 * @see #addFlags(int)
8290 */
8291 public void removeFlags(int flags) {
8292 mFlags &= ~flags;
8293 }
8294
8295 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008296 * (Usually optional) Set an explicit application package name that limits
8297 * the components this Intent will resolve to. If left to the default
8298 * value of null, all components in all applications will considered.
8299 * If non-null, the Intent can only match the components in the given
8300 * application package.
8301 *
8302 * @param packageName The name of the application package to handle the
8303 * intent, or null to allow any application package.
8304 *
8305 * @return Returns the same Intent object, for chaining multiple calls
8306 * into a single statement.
8307 *
8308 * @see #getPackage
8309 * @see #resolveActivity
8310 */
8311 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008312 if (packageName != null && mSelector != null) {
8313 throw new IllegalArgumentException(
8314 "Can't set package name when selector is already set");
8315 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008316 mPackage = packageName;
8317 return this;
8318 }
8319
8320 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008321 * (Usually optional) Explicitly set the component to handle the intent.
8322 * If left with the default value of null, the system will determine the
8323 * appropriate class to use based on the other fields (action, data,
8324 * type, categories) in the Intent. If this class is defined, the
8325 * specified class will always be used regardless of the other fields. You
8326 * should only set this value when you know you absolutely want a specific
8327 * class to be used; otherwise it is better to let the system find the
8328 * appropriate class so that you will respect the installed applications
8329 * and user preferences.
8330 *
8331 * @param component The name of the application component to handle the
8332 * intent, or null to let the system find one for you.
8333 *
8334 * @return Returns the same Intent object, for chaining multiple calls
8335 * into a single statement.
8336 *
8337 * @see #setClass
8338 * @see #setClassName(Context, String)
8339 * @see #setClassName(String, String)
8340 * @see #getComponent
8341 * @see #resolveActivity
8342 */
8343 public Intent setComponent(ComponentName component) {
8344 mComponent = component;
8345 return this;
8346 }
8347
8348 /**
8349 * Convenience for calling {@link #setComponent} with an
8350 * explicit class name.
8351 *
8352 * @param packageContext A Context of the application package implementing
8353 * this class.
8354 * @param className The name of a class inside of the application package
8355 * that will be used as the component for this Intent.
8356 *
8357 * @return Returns the same Intent object, for chaining multiple calls
8358 * into a single statement.
8359 *
8360 * @see #setComponent
8361 * @see #setClass
8362 */
8363 public Intent setClassName(Context packageContext, String className) {
8364 mComponent = new ComponentName(packageContext, className);
8365 return this;
8366 }
8367
8368 /**
8369 * Convenience for calling {@link #setComponent} with an
8370 * explicit application package name and class name.
8371 *
8372 * @param packageName The name of the package implementing the desired
8373 * component.
8374 * @param className The name of a class inside of the application package
8375 * that will be used as the component for this Intent.
8376 *
8377 * @return Returns the same Intent object, for chaining multiple calls
8378 * into a single statement.
8379 *
8380 * @see #setComponent
8381 * @see #setClass
8382 */
8383 public Intent setClassName(String packageName, String className) {
8384 mComponent = new ComponentName(packageName, className);
8385 return this;
8386 }
8387
8388 /**
8389 * Convenience for calling {@link #setComponent(ComponentName)} with the
8390 * name returned by a {@link Class} object.
8391 *
8392 * @param packageContext A Context of the application package implementing
8393 * this class.
8394 * @param cls The class name to set, equivalent to
8395 * <code>setClassName(context, cls.getName())</code>.
8396 *
8397 * @return Returns the same Intent object, for chaining multiple calls
8398 * into a single statement.
8399 *
8400 * @see #setComponent
8401 */
8402 public Intent setClass(Context packageContext, Class<?> cls) {
8403 mComponent = new ComponentName(packageContext, cls);
8404 return this;
8405 }
8406
8407 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008408 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8409 * used as a hint to the receiver for animations and the like. Null means that there
8410 * is no source bounds.
8411 */
8412 public void setSourceBounds(Rect r) {
8413 if (r != null) {
8414 mSourceBounds = new Rect(r);
8415 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008416 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008417 }
8418 }
8419
Tor Norbyed9273d62013-05-30 15:59:53 -07008420 /** @hide */
8421 @IntDef(flag = true,
8422 value = {
8423 FILL_IN_ACTION,
8424 FILL_IN_DATA,
8425 FILL_IN_CATEGORIES,
8426 FILL_IN_COMPONENT,
8427 FILL_IN_PACKAGE,
8428 FILL_IN_SOURCE_BOUNDS,
8429 FILL_IN_SELECTOR,
8430 FILL_IN_CLIP_DATA
8431 })
8432 @Retention(RetentionPolicy.SOURCE)
8433 public @interface FillInFlags {}
8434
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008435 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008436 * Use with {@link #fillIn} to allow the current action value to be
8437 * overwritten, even if it is already set.
8438 */
8439 public static final int FILL_IN_ACTION = 1<<0;
8440
8441 /**
8442 * Use with {@link #fillIn} to allow the current data or type value
8443 * overwritten, even if it is already set.
8444 */
8445 public static final int FILL_IN_DATA = 1<<1;
8446
8447 /**
8448 * Use with {@link #fillIn} to allow the current categories to be
8449 * overwritten, even if they are already set.
8450 */
8451 public static final int FILL_IN_CATEGORIES = 1<<2;
8452
8453 /**
8454 * Use with {@link #fillIn} to allow the current component value to be
8455 * overwritten, even if it is already set.
8456 */
8457 public static final int FILL_IN_COMPONENT = 1<<3;
8458
8459 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008460 * Use with {@link #fillIn} to allow the current package value to be
8461 * overwritten, even if it is already set.
8462 */
8463 public static final int FILL_IN_PACKAGE = 1<<4;
8464
8465 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008466 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008467 * overwritten, even if it is already set.
8468 */
8469 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8470
8471 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008472 * Use with {@link #fillIn} to allow the current selector to be
8473 * overwritten, even if it is already set.
8474 */
8475 public static final int FILL_IN_SELECTOR = 1<<6;
8476
8477 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008478 * Use with {@link #fillIn} to allow the current ClipData to be
8479 * overwritten, even if it is already set.
8480 */
8481 public static final int FILL_IN_CLIP_DATA = 1<<7;
8482
8483 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008484 * Copy the contents of <var>other</var> in to this object, but only
8485 * where fields are not defined by this object. For purposes of a field
8486 * being defined, the following pieces of data in the Intent are
8487 * considered to be separate fields:
8488 *
8489 * <ul>
8490 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008491 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008492 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8493 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008494 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008495 * <li> component, as set by {@link #setComponent(ComponentName)} or
8496 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008497 * <li> source bounds, as set by {@link #setSourceBounds}.
8498 * <li> selector, as set by {@link #setSelector(Intent)}.
8499 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008500 * <li> each top-level name in the associated extras.
8501 * </ul>
8502 *
8503 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008504 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008505 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8506 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8507 * the restriction where the corresponding field will not be replaced if
8508 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008509 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008510 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8511 * is explicitly specified. The selector will only be copied if
8512 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008513 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008514 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8515 * and Intent B with {action="gotit", data-type="some/thing",
8516 * categories="one","two"}.
8517 *
8518 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8519 * containing: {action="gotit", data-type="some/thing",
8520 * categories="bar"}.
8521 *
8522 * @param other Another Intent whose values are to be used to fill in
8523 * the current one.
8524 * @param flags Options to control which fields can be filled in.
8525 *
8526 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008527 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008528 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008529 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008530 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008531 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008532 @FillInFlags
8533 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008534 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008535 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008536 if (other.mAction != null
8537 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008538 mAction = other.mAction;
8539 changes |= FILL_IN_ACTION;
8540 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008541 if ((other.mData != null || other.mType != null)
8542 && ((mData == null && mType == null)
8543 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008544 mData = other.mData;
8545 mType = other.mType;
8546 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008547 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008548 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008549 if (other.mCategories != null
8550 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008551 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008552 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008553 }
8554 changes |= FILL_IN_CATEGORIES;
8555 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008556 if (other.mPackage != null
8557 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008558 // Only do this if mSelector is not set.
8559 if (mSelector == null) {
8560 mPackage = other.mPackage;
8561 changes |= FILL_IN_PACKAGE;
8562 }
8563 }
8564 // Selector is special: it can only be set if explicitly allowed,
8565 // for the same reason as the component name.
8566 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8567 if (mPackage == null) {
8568 mSelector = new Intent(other.mSelector);
8569 mPackage = null;
8570 changes |= FILL_IN_SELECTOR;
8571 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008572 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008573 if (other.mClipData != null
8574 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8575 mClipData = other.mClipData;
8576 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008577 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008578 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008579 // Component is special: it can -only- be set if explicitly allowed,
8580 // since otherwise the sender could force the intent somewhere the
8581 // originator didn't intend.
8582 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 mComponent = other.mComponent;
8584 changes |= FILL_IN_COMPONENT;
8585 }
8586 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008587 if (other.mSourceBounds != null
8588 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8589 mSourceBounds = new Rect(other.mSourceBounds);
8590 changes |= FILL_IN_SOURCE_BOUNDS;
8591 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008592 if (mExtras == null) {
8593 if (other.mExtras != null) {
8594 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008595 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008596 }
8597 } else if (other.mExtras != null) {
8598 try {
8599 Bundle newb = new Bundle(other.mExtras);
8600 newb.putAll(mExtras);
8601 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008602 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008603 } catch (RuntimeException e) {
8604 // Modifying the extras can cause us to unparcel the contents
8605 // of the bundle, and if we do this in the system process that
8606 // may fail. We really should handle this (i.e., the Bundle
8607 // impl shouldn't be on top of a plain map), but for now just
8608 // ignore it and keep the original contents. :(
8609 Log.w("Intent", "Failure filling in extras", e);
8610 }
8611 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008612 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8613 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8614 mContentUserHint = other.mContentUserHint;
8615 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008616 return changes;
8617 }
8618
8619 /**
8620 * Wrapper class holding an Intent and implementing comparisons on it for
8621 * the purpose of filtering. The class implements its
8622 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8623 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8624 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8625 * on the wrapped Intent.
8626 */
8627 public static final class FilterComparison {
8628 private final Intent mIntent;
8629 private final int mHashCode;
8630
8631 public FilterComparison(Intent intent) {
8632 mIntent = intent;
8633 mHashCode = intent.filterHashCode();
8634 }
8635
8636 /**
8637 * Return the Intent that this FilterComparison represents.
8638 * @return Returns the Intent held by the FilterComparison. Do
8639 * not modify!
8640 */
8641 public Intent getIntent() {
8642 return mIntent;
8643 }
8644
8645 @Override
8646 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008647 if (obj instanceof FilterComparison) {
8648 Intent other = ((FilterComparison)obj).mIntent;
8649 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008650 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008651 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008652 }
8653
8654 @Override
8655 public int hashCode() {
8656 return mHashCode;
8657 }
8658 }
8659
8660 /**
8661 * Determine if two intents are the same for the purposes of intent
8662 * resolution (filtering). That is, if their action, data, type,
8663 * class, and categories are the same. This does <em>not</em> compare
8664 * any extra data included in the intents.
8665 *
8666 * @param other The other Intent to compare against.
8667 *
8668 * @return Returns true if action, data, type, class, and categories
8669 * are the same.
8670 */
8671 public boolean filterEquals(Intent other) {
8672 if (other == null) {
8673 return false;
8674 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008675 if (!Objects.equals(this.mAction, other.mAction)) return false;
8676 if (!Objects.equals(this.mData, other.mData)) return false;
8677 if (!Objects.equals(this.mType, other.mType)) return false;
8678 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8679 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8680 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008681
8682 return true;
8683 }
8684
8685 /**
8686 * Generate hash code that matches semantics of filterEquals().
8687 *
8688 * @return Returns the hash value of the action, data, type, class, and
8689 * categories.
8690 *
8691 * @see #filterEquals
8692 */
8693 public int filterHashCode() {
8694 int code = 0;
8695 if (mAction != null) {
8696 code += mAction.hashCode();
8697 }
8698 if (mData != null) {
8699 code += mData.hashCode();
8700 }
8701 if (mType != null) {
8702 code += mType.hashCode();
8703 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008704 if (mPackage != null) {
8705 code += mPackage.hashCode();
8706 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008707 if (mComponent != null) {
8708 code += mComponent.hashCode();
8709 }
8710 if (mCategories != null) {
8711 code += mCategories.hashCode();
8712 }
8713 return code;
8714 }
8715
8716 @Override
8717 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008718 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008719
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008720 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008721 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008722 b.append(" }");
8723
8724 return b.toString();
8725 }
8726
8727 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008728 public String toInsecureString() {
8729 StringBuilder b = new StringBuilder(128);
8730
8731 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008732 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008733 b.append(" }");
8734
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008735 return b.toString();
8736 }
Romain Guy4969af72009-06-17 10:53:19 -07008737
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008738 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008739 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008740 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008741
8742 b.append("Intent { ");
8743 toShortString(b, false, true, true, true);
8744 b.append(" }");
8745
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008746 return b.toString();
8747 }
8748
8749 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008750 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8751 StringBuilder b = new StringBuilder(128);
8752 toShortString(b, secure, comp, extras, clip);
8753 return b.toString();
8754 }
8755
8756 /** @hide */
8757 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8758 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008759 boolean first = true;
8760 if (mAction != null) {
8761 b.append("act=").append(mAction);
8762 first = false;
8763 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008764 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008765 if (!first) {
8766 b.append(' ');
8767 }
8768 first = false;
8769 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008770 for (int i=0; i<mCategories.size(); i++) {
8771 if (i > 0) b.append(',');
8772 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008773 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008774 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008775 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008776 if (mData != null) {
8777 if (!first) {
8778 b.append(' ');
8779 }
8780 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008781 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008782 if (secure) {
8783 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008784 } else {
8785 b.append(mData);
8786 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008787 }
8788 if (mType != null) {
8789 if (!first) {
8790 b.append(' ');
8791 }
8792 first = false;
8793 b.append("typ=").append(mType);
8794 }
8795 if (mFlags != 0) {
8796 if (!first) {
8797 b.append(' ');
8798 }
8799 first = false;
8800 b.append("flg=0x").append(Integer.toHexString(mFlags));
8801 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008802 if (mPackage != null) {
8803 if (!first) {
8804 b.append(' ');
8805 }
8806 first = false;
8807 b.append("pkg=").append(mPackage);
8808 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008809 if (comp && mComponent != null) {
8810 if (!first) {
8811 b.append(' ');
8812 }
8813 first = false;
8814 b.append("cmp=").append(mComponent.flattenToShortString());
8815 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008816 if (mSourceBounds != null) {
8817 if (!first) {
8818 b.append(' ');
8819 }
8820 first = false;
8821 b.append("bnds=").append(mSourceBounds.toShortString());
8822 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008823 if (mClipData != null) {
8824 if (!first) {
8825 b.append(' ');
8826 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008827 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008828 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008829 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008830 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008831 if (mClipData.getDescription() != null) {
8832 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8833 } else {
8834 first = true;
8835 }
8836 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008837 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008838 first = false;
8839 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008840 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008841 if (extras && mExtras != null) {
8842 if (!first) {
8843 b.append(' ');
8844 }
8845 first = false;
8846 b.append("(has extras)");
8847 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008848 if (mContentUserHint != UserHandle.USER_CURRENT) {
8849 if (!first) {
8850 b.append(' ');
8851 }
8852 first = false;
8853 b.append("u=").append(mContentUserHint);
8854 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008855 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008856 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008857 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008858 b.append("}");
8859 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008860 }
8861
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008862 /**
8863 * Call {@link #toUri} with 0 flags.
8864 * @deprecated Use {@link #toUri} instead.
8865 */
8866 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008867 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008868 return toUri(0);
8869 }
8870
8871 /**
8872 * Convert this Intent into a String holding a URI representation of it.
8873 * The returned URI string has been properly URI encoded, so it can be
8874 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8875 * Intent's data as the base URI, with an additional fragment describing
8876 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008877 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008878 * <p>You can convert the returned string back to an Intent with
8879 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008880 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008881 * @param flags Additional operating flags. Either 0,
8882 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008883 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008884 * @return Returns a URI encoding URI string describing the entire contents
8885 * of the Intent.
8886 */
8887 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008888 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008889 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8890 if (mPackage == null) {
8891 throw new IllegalArgumentException(
8892 "Intent must include an explicit package name to build an android-app: "
8893 + this);
8894 }
8895 uri.append("android-app://");
8896 uri.append(mPackage);
8897 String scheme = null;
8898 if (mData != null) {
8899 scheme = mData.getScheme();
8900 if (scheme != null) {
8901 uri.append('/');
8902 uri.append(scheme);
8903 String authority = mData.getEncodedAuthority();
8904 if (authority != null) {
8905 uri.append('/');
8906 uri.append(authority);
8907 String path = mData.getEncodedPath();
8908 if (path != null) {
8909 uri.append(path);
8910 }
8911 String queryParams = mData.getEncodedQuery();
8912 if (queryParams != null) {
8913 uri.append('?');
8914 uri.append(queryParams);
8915 }
8916 String fragment = mData.getEncodedFragment();
8917 if (fragment != null) {
8918 uri.append('#');
8919 uri.append(fragment);
8920 }
8921 }
8922 }
8923 }
8924 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8925 mPackage, flags);
8926 return uri.toString();
8927 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008928 String scheme = null;
8929 if (mData != null) {
8930 String data = mData.toString();
8931 if ((flags&URI_INTENT_SCHEME) != 0) {
8932 final int N = data.length();
8933 for (int i=0; i<N; i++) {
8934 char c = data.charAt(i);
8935 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8936 || c == '.' || c == '-') {
8937 continue;
8938 }
8939 if (c == ':' && i > 0) {
8940 // Valid scheme.
8941 scheme = data.substring(0, i);
8942 uri.append("intent:");
8943 data = data.substring(i+1);
8944 break;
8945 }
Tom Taylord4a47292009-12-21 13:59:18 -08008946
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008947 // No scheme.
8948 break;
8949 }
8950 }
8951 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008952
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008953 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8954 uri.append("intent:");
8955 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008956
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008957 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008958
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008959 return uri.toString();
8960 }
8961
8962 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8963 String defPackage, int flags) {
8964 StringBuilder frag = new StringBuilder(128);
8965
8966 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008967 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008968 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008969 // Note that for now we are not going to try to handle the
8970 // data part; not clear how to represent this as a URI, and
8971 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008972 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8973 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008974 }
8975
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008976 if (frag.length() > 0) {
8977 uri.append("#Intent;");
8978 uri.append(frag);
8979 uri.append("end");
8980 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008981 }
8982
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008983 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8984 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008985 if (scheme != null) {
8986 uri.append("scheme=").append(scheme).append(';');
8987 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008988 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008989 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008990 }
8991 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008992 for (int i=0; i<mCategories.size(); i++) {
8993 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008994 }
8995 }
8996 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008997 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008998 }
8999 if (mFlags != 0) {
9000 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9001 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009002 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009003 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9004 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009005 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009006 uri.append("component=").append(Uri.encode(
9007 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009008 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009009 if (mSourceBounds != null) {
9010 uri.append("sourceBounds=")
9011 .append(Uri.encode(mSourceBounds.flattenToString()))
9012 .append(';');
9013 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009014 if (mExtras != null) {
9015 for (String key : mExtras.keySet()) {
9016 final Object value = mExtras.get(key);
9017 char entryType =
9018 value instanceof String ? 'S' :
9019 value instanceof Boolean ? 'B' :
9020 value instanceof Byte ? 'b' :
9021 value instanceof Character ? 'c' :
9022 value instanceof Double ? 'd' :
9023 value instanceof Float ? 'f' :
9024 value instanceof Integer ? 'i' :
9025 value instanceof Long ? 'l' :
9026 value instanceof Short ? 's' :
9027 '\0';
9028
9029 if (entryType != '\0') {
9030 uri.append(entryType);
9031 uri.append('.');
9032 uri.append(Uri.encode(key));
9033 uri.append('=');
9034 uri.append(Uri.encode(value.toString()));
9035 uri.append(';');
9036 }
9037 }
9038 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009039 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009040
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009041 public int describeContents() {
9042 return (mExtras != null) ? mExtras.describeContents() : 0;
9043 }
9044
9045 public void writeToParcel(Parcel out, int flags) {
9046 out.writeString(mAction);
9047 Uri.writeToParcel(out, mData);
9048 out.writeString(mType);
9049 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009050 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009051 ComponentName.writeToParcel(mComponent, out);
9052
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009053 if (mSourceBounds != null) {
9054 out.writeInt(1);
9055 mSourceBounds.writeToParcel(out, flags);
9056 } else {
9057 out.writeInt(0);
9058 }
9059
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009060 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009061 final int N = mCategories.size();
9062 out.writeInt(N);
9063 for (int i=0; i<N; i++) {
9064 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009065 }
9066 } else {
9067 out.writeInt(0);
9068 }
9069
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009070 if (mSelector != null) {
9071 out.writeInt(1);
9072 mSelector.writeToParcel(out, flags);
9073 } else {
9074 out.writeInt(0);
9075 }
9076
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009077 if (mClipData != null) {
9078 out.writeInt(1);
9079 mClipData.writeToParcel(out, flags);
9080 } else {
9081 out.writeInt(0);
9082 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009083 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009084 out.writeBundle(mExtras);
9085 }
9086
9087 public static final Parcelable.Creator<Intent> CREATOR
9088 = new Parcelable.Creator<Intent>() {
9089 public Intent createFromParcel(Parcel in) {
9090 return new Intent(in);
9091 }
9092 public Intent[] newArray(int size) {
9093 return new Intent[size];
9094 }
9095 };
9096
Dianne Hackborneb034652009-09-07 00:49:58 -07009097 /** @hide */
9098 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009099 readFromParcel(in);
9100 }
9101
9102 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009103 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009104 mData = Uri.CREATOR.createFromParcel(in);
9105 mType = in.readString();
9106 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009107 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009108 mComponent = ComponentName.readFromParcel(in);
9109
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009110 if (in.readInt() != 0) {
9111 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9112 }
9113
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 int N = in.readInt();
9115 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009116 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009117 int i;
9118 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009119 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009120 }
9121 } else {
9122 mCategories = null;
9123 }
9124
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009125 if (in.readInt() != 0) {
9126 mSelector = new Intent(in);
9127 }
9128
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009129 if (in.readInt() != 0) {
9130 mClipData = new ClipData(in);
9131 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009132 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009133 mExtras = in.readBundle();
9134 }
9135
9136 /**
9137 * Parses the "intent" element (and its children) from XML and instantiates
9138 * an Intent object. The given XML parser should be located at the tag
9139 * where parsing should start (often named "intent"), from which the
9140 * basic action, data, type, and package and class name will be
9141 * retrieved. The function will then parse in to any child elements,
9142 * looking for <category android:name="xxx"> tags to add categories and
9143 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9144 * to the intent.
9145 *
9146 * @param resources The Resources to use when inflating resources.
9147 * @param parser The XML parser pointing at an "intent" tag.
9148 * @param attrs The AttributeSet interface for retrieving extended
9149 * attribute data at the current <var>parser</var> location.
9150 * @return An Intent object matching the XML data.
9151 * @throws XmlPullParserException If there was an XML parsing error.
9152 * @throws IOException If there was an I/O error.
9153 */
9154 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9155 throws XmlPullParserException, IOException {
9156 Intent intent = new Intent();
9157
9158 TypedArray sa = resources.obtainAttributes(attrs,
9159 com.android.internal.R.styleable.Intent);
9160
9161 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9162
9163 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9164 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9165 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9166
9167 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9168 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9169 if (packageName != null && className != null) {
9170 intent.setComponent(new ComponentName(packageName, className));
9171 }
9172
9173 sa.recycle();
9174
9175 int outerDepth = parser.getDepth();
9176 int type;
9177 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9178 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9179 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9180 continue;
9181 }
9182
9183 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009184 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009185 sa = resources.obtainAttributes(attrs,
9186 com.android.internal.R.styleable.IntentCategory);
9187 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9188 sa.recycle();
9189
9190 if (cat != null) {
9191 intent.addCategory(cat);
9192 }
9193 XmlUtils.skipCurrentTag(parser);
9194
Craig Mautner21d24a22014-04-23 11:45:37 -07009195 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009196 if (intent.mExtras == null) {
9197 intent.mExtras = new Bundle();
9198 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009199 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009200 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009201
9202 } else {
9203 XmlUtils.skipCurrentTag(parser);
9204 }
9205 }
9206
9207 return intent;
9208 }
Nick Pellyccae4122012-01-09 14:12:58 -08009209
Craig Mautner21d24a22014-04-23 11:45:37 -07009210 /** @hide */
9211 public void saveToXml(XmlSerializer out) throws IOException {
9212 if (mAction != null) {
9213 out.attribute(null, ATTR_ACTION, mAction);
9214 }
9215 if (mData != null) {
9216 out.attribute(null, ATTR_DATA, mData.toString());
9217 }
9218 if (mType != null) {
9219 out.attribute(null, ATTR_TYPE, mType);
9220 }
9221 if (mComponent != null) {
9222 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9223 }
9224 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9225
9226 if (mCategories != null) {
9227 out.startTag(null, TAG_CATEGORIES);
9228 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9229 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9230 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009231 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009232 }
9233 }
9234
9235 /** @hide */
9236 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9237 XmlPullParserException {
9238 Intent intent = new Intent();
9239 final int outerDepth = in.getDepth();
9240
9241 int attrCount = in.getAttributeCount();
9242 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9243 final String attrName = in.getAttributeName(attrNdx);
9244 final String attrValue = in.getAttributeValue(attrNdx);
9245 if (ATTR_ACTION.equals(attrName)) {
9246 intent.setAction(attrValue);
9247 } else if (ATTR_DATA.equals(attrName)) {
9248 intent.setData(Uri.parse(attrValue));
9249 } else if (ATTR_TYPE.equals(attrName)) {
9250 intent.setType(attrValue);
9251 } else if (ATTR_COMPONENT.equals(attrName)) {
9252 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9253 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009254 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009255 } else {
9256 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9257 }
9258 }
9259
9260 int event;
9261 String name;
9262 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9263 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9264 if (event == XmlPullParser.START_TAG) {
9265 name = in.getName();
9266 if (TAG_CATEGORIES.equals(name)) {
9267 attrCount = in.getAttributeCount();
9268 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9269 intent.addCategory(in.getAttributeValue(attrNdx));
9270 }
9271 } else {
9272 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9273 XmlUtils.skipCurrentTag(in);
9274 }
9275 }
9276 }
9277
9278 return intent;
9279 }
9280
Nick Pellyccae4122012-01-09 14:12:58 -08009281 /**
9282 * Normalize a MIME data type.
9283 *
9284 * <p>A normalized MIME type has white-space trimmed,
9285 * content-type parameters removed, and is lower-case.
9286 * This aligns the type with Android best practices for
9287 * intent filtering.
9288 *
9289 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9290 * "text/x-vCard" becomes "text/x-vcard".
9291 *
9292 * <p>All MIME types received from outside Android (such as user input,
9293 * or external sources like Bluetooth, NFC, or the Internet) should
9294 * be normalized before they are used to create an Intent.
9295 *
9296 * @param type MIME data type to normalize
9297 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009298 * @see #setType
9299 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009300 */
9301 public static String normalizeMimeType(String type) {
9302 if (type == null) {
9303 return null;
9304 }
9305
Elliott Hughescb64d432013-08-02 10:00:44 -07009306 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009307
9308 final int semicolonIndex = type.indexOf(';');
9309 if (semicolonIndex != -1) {
9310 type = type.substring(0, semicolonIndex);
9311 }
9312 return type;
9313 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009314
9315 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009316 * Prepare this {@link Intent} to leave an app process.
9317 *
9318 * @hide
9319 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009320 public void prepareToLeaveProcess(Context context) {
9321 final boolean leavingPackage = (mComponent == null)
9322 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9323 prepareToLeaveProcess(leavingPackage);
9324 }
9325
9326 /**
9327 * Prepare this {@link Intent} to leave an app process.
9328 *
9329 * @hide
9330 */
9331 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009332 setAllowFds(false);
9333
9334 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009335 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009336 }
9337 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009338 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009339 }
9340
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009341 if (mExtras != null && !mExtras.isParcelled()) {
9342 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9343 if (intent instanceof Intent) {
9344 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9345 }
9346 }
9347
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009348 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9349 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009350 switch (mAction) {
9351 case ACTION_MEDIA_REMOVED:
9352 case ACTION_MEDIA_UNMOUNTED:
9353 case ACTION_MEDIA_CHECKING:
9354 case ACTION_MEDIA_NOFS:
9355 case ACTION_MEDIA_MOUNTED:
9356 case ACTION_MEDIA_SHARED:
9357 case ACTION_MEDIA_UNSHARED:
9358 case ACTION_MEDIA_BAD_REMOVAL:
9359 case ACTION_MEDIA_UNMOUNTABLE:
9360 case ACTION_MEDIA_EJECT:
9361 case ACTION_MEDIA_SCANNER_STARTED:
9362 case ACTION_MEDIA_SCANNER_FINISHED:
9363 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009364 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9365 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009366 // Ignore legacy actions
9367 break;
9368 default:
9369 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009370 }
9371 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009372
9373 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9374 && leavingPackage) {
9375 switch (mAction) {
9376 case ACTION_PROVIDER_CHANGED:
9377 // Ignore actions that don't need to grant
9378 break;
9379 default:
9380 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9381 }
9382 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009383 }
9384
9385 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009386 * @hide
9387 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009388 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009389 // We just entered destination process, so we should be able to read all
9390 // parcelables inside.
9391 setDefusable(true);
9392
9393 if (mSelector != null) {
9394 mSelector.prepareToEnterProcess();
9395 }
9396 if (mClipData != null) {
9397 mClipData.prepareToEnterProcess();
9398 }
9399
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009400 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009401 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9402 fixUris(mContentUserHint);
9403 mContentUserHint = UserHandle.USER_CURRENT;
9404 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009405 }
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06009406
9407 // If someone is sending us ClipData, but not EXTRA_STREAM, offer to
9408 // downgrade that content for older apps to find
9409 if (mClipData != null && mClipData.getItemCount() > 0 && !hasExtra(EXTRA_STREAM)) {
9410 final String action = getAction();
9411 if (ACTION_SEND.equals(action)) {
9412 putExtra(EXTRA_STREAM, mClipData.getItemAt(0).getUri());
9413 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
9414 final ArrayList<Uri> list = new ArrayList<>();
9415 for (int i = 0; i < mClipData.getItemCount(); i++) {
9416 list.add(mClipData.getItemAt(i).getUri());
9417 }
9418 putExtra(EXTRA_STREAM, list);
9419 }
9420 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009421 }
9422
9423 /**
9424 * @hide
9425 */
9426 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009427 Uri data = getData();
9428 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009429 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009430 }
9431 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009432 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009433 }
9434 String action = getAction();
9435 if (ACTION_SEND.equals(action)) {
9436 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9437 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009438 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009439 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009440 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009441 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9442 if (streams != null) {
9443 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9444 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009445 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009446 }
9447 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9448 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009449 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9450 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9451 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9452 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9453 if (output != null) {
9454 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9455 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009456 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009457 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009458
9459 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009460 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009461 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9462 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009463 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009464 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009465 * @hide
9466 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009467 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009468 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009469 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009470
9471 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009472 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009473
9474 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009475 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009476 // Inspect contained intents to see if we need to migrate extras. We
9477 // don't promote ClipData to the parent, since ChooserActivity will
9478 // already start the picked item as the caller, and we can't combine
9479 // the flags in a safe way.
9480
9481 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009482 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009483 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9484 if (intent != null) {
9485 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009486 }
9487 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009488 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009489 try {
9490 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9491 if (intents != null) {
9492 for (int i = 0; i < intents.length; i++) {
9493 final Intent intent = (Intent) intents[i];
9494 if (intent != null) {
9495 migrated |= intent.migrateExtraStreamToClipData();
9496 }
9497 }
9498 }
9499 } catch (ClassCastException e) {
9500 }
9501 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009502
9503 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009504 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009505 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9506 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9507 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9508 if (stream != null || text != null || htmlText != null) {
9509 final ClipData clipData = new ClipData(
9510 null, new String[] { getType() },
9511 new ClipData.Item(text, htmlText, null, stream));
9512 setClipData(clipData);
9513 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009514 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009515 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009516 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009517 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009518
9519 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009520 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009521 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9522 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9523 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9524 int num = -1;
9525 if (streams != null) {
9526 num = streams.size();
9527 }
9528 if (texts != null) {
9529 if (num >= 0 && num != texts.size()) {
9530 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009531 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009532 }
9533 num = texts.size();
9534 }
9535 if (htmlTexts != null) {
9536 if (num >= 0 && num != htmlTexts.size()) {
9537 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009538 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009539 }
9540 num = htmlTexts.size();
9541 }
9542 if (num > 0) {
9543 final ClipData clipData = new ClipData(
9544 null, new String[] { getType() },
9545 makeClipItem(streams, texts, htmlTexts, 0));
9546
9547 for (int i = 1; i < num; i++) {
9548 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9549 }
9550
9551 setClipData(clipData);
9552 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009553 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009554 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009555 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009556 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009557 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9558 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9559 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9560 final Uri output;
9561 try {
9562 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9563 } catch (ClassCastException e) {
9564 return false;
9565 }
9566 if (output != null) {
9567 setClipData(ClipData.newRawUri("", output));
9568 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9569 return true;
9570 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009571 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009572
9573 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009574 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009575
9576 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9577 ArrayList<String> htmlTexts, int which) {
9578 Uri uri = streams != null ? streams.get(which) : null;
9579 CharSequence text = texts != null ? texts.get(which) : null;
9580 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9581 return new ClipData.Item(text, htmlText, null, uri);
9582 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009583
9584 /** @hide */
9585 public boolean isDocument() {
9586 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9587 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009588}