blob: e4c5d1dcc3b3278301d7ecb3dd7b09e84122a109 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -060019import static android.content.ContentProvider.maybeAddUserId;
20
Tor Norbye7b9c9122013-05-30 16:48:33 -070021import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070022import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import android.annotation.SdkConstant;
25import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050026import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050028import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060029import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.content.pm.PackageManager;
31import android.content.pm.ResolveInfo;
32import android.content.res.Resources;
33import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080034import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070035import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060036import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.os.Bundle;
38import android.os.IBinder;
39import android.os.Parcel;
40import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000041import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050042import android.os.ResultReceiver;
43import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070044import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010045import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070046import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070047import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050048import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070049import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050050import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070051import android.util.AttributeSet;
52import android.util.Log;
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -060053
Dianne Hackborn2269d1572010-02-24 19:54:22 -080054import com.android.internal.util.XmlUtils;
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -060055
Jason Monk2f68e8a2016-02-23 17:57:28 -050056import org.xmlpull.v1.XmlPullParser;
57import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070058import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059
60import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080061import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070063import java.lang.annotation.Retention;
64import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065import java.net.URISyntaxException;
66import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080067import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070068import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080069import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070070import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070071import java.util.Set;
72
73/**
74 * An intent is an abstract description of an operation to be performed. It
75 * can be used with {@link Context#startActivity(Intent) startActivity} to
76 * launch an {@link android.app.Activity},
77 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
78 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
79 * and {@link android.content.Context#startService} or
80 * {@link android.content.Context#bindService} to communicate with a
81 * background {@link android.app.Service}.
82 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070083 * <p>An Intent provides a facility for performing late runtime binding between the code in
84 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070085 * can be thought of as the glue between activities. It is basically a passive data structure
86 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070087 *
88 * <div class="special reference">
89 * <h3>Developer Guides</h3>
90 * <p>For information about how to create and resolve intents, read the
91 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
92 * developer guide.</p>
93 * </div>
94 *
95 * <a name="IntentStructure"></a>
96 * <h3>Intent Structure</h3>
97 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 *
99 * <ul>
100 * <li> <p><b>action</b> -- The general action to be performed, such as
101 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
102 * etc.</p>
103 * </li>
104 * <li> <p><b>data</b> -- The data to operate on, such as a person record
105 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
106 * </li>
107 * </ul>
108 *
109 *
110 * <p>Some examples of action/data pairs are:</p>
111 *
112 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * information about the person whose identifier is "1".</p>
115 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700116 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700117 * the phone dialer with the person filled in.</p>
118 * </li>
119 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
120 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700121 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700122 * a particular URI.</p>
123 * </li>
124 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
125 * the phone dialer with the given number filled in.</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * information about the person whose identifier is "1".</p>
129 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700130 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700131 * a list of people, which the user can browse through. This example is a
132 * typical top-level entry into the Contacts application, showing you the
133 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700134 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700135 * being used to start an activity to display that person.</p>
136 * </li>
137 * </ul>
138 *
139 * <p>In addition to these primary attributes, there are a number of secondary
140 * attributes that you can also include with an intent:</p>
141 *
142 * <ul>
143 * <li> <p><b>category</b> -- Gives additional information about the action
144 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
145 * appear in the Launcher as a top-level application, while
146 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
147 * of alternative actions the user can perform on a piece of data.</p>
148 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
149 * intent data. Normally the type is inferred from the data itself.
150 * By setting this attribute, you disable that evaluation and force
151 * an explicit type.</p>
152 * <li> <p><b>component</b> -- Specifies an explicit name of a component
153 * class to use for the intent. Normally this is determined by looking
154 * at the other information in the intent (the action, data/type, and
155 * categories) and matching that with a component that can handle it.
156 * If this attribute is set then none of the evaluation is performed,
157 * and this component is used exactly as is. By specifying this attribute,
158 * all of the other Intent attributes become optional.</p>
159 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
160 * This can be used to provide extended information to the component.
161 * For example, if we have a action to send an e-mail message, we could
162 * also include extra pieces of data here to supply a subject, body,
163 * etc.</p>
164 * </ul>
165 *
166 * <p>Here are some examples of other operations you can specify as intents
167 * using these additional parameters:</p>
168 *
169 * <ul>
170 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
171 * Launch the home screen.</p>
172 * </li>
173 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
174 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
175 * vnd.android.cursor.item/phone}</i></b>
176 * -- Display the list of people's phone numbers, allowing the user to
177 * browse through them and pick one and return it to the parent activity.</p>
178 * </li>
179 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
180 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
181 * -- Display all pickers for data that can be opened with
182 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
183 * allowing the user to pick one of them and then some data inside of it
184 * and returning the resulting URI to the caller. This can be used,
185 * for example, in an e-mail application to allow the user to pick some
186 * data to include as an attachment.</p>
187 * </li>
188 * </ul>
189 *
190 * <p>There are a variety of standard Intent action and category constants
191 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700192 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700193 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700194 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700195 *
196 * <p>Put together, the set of actions, data types, categories, and extra data
197 * defines a language for the system allowing for the expression of phrases
198 * such as "call john smith's cell". As applications are added to the system,
199 * they can extend this language by adding new actions, types, and categories, or
200 * they can modify the behavior of existing phrases by supplying their own
201 * activities that handle them.</p>
202 *
203 * <a name="IntentResolution"></a>
204 * <h3>Intent Resolution</h3>
205 *
206 * <p>There are two primary forms of intents you will use.
207 *
208 * <ul>
209 * <li> <p><b>Explicit Intents</b> have specified a component (via
210 * {@link #setComponent} or {@link #setClass}), which provides the exact
211 * class to be run. Often these will not include any other information,
212 * simply being a way for an application to launch various internal
213 * activities it has as the user interacts with the application.
214 *
215 * <li> <p><b>Implicit Intents</b> have not specified a component;
216 * instead, they must include enough information for the system to
217 * determine which of the available components is best to run for that
218 * intent.
219 * </ul>
220 *
221 * <p>When using implicit intents, given such an arbitrary intent we need to
222 * know what to do with it. This is handled by the process of <em>Intent
223 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
224 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
225 * more activities/receivers) that can handle it.</p>
226 *
227 * <p>The intent resolution mechanism basically revolves around matching an
228 * Intent against all of the &lt;intent-filter&gt; descriptions in the
229 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
230 * objects explicitly registered with {@link Context#registerReceiver}.) More
231 * details on this can be found in the documentation on the {@link
232 * IntentFilter} class.</p>
233 *
234 * <p>There are three pieces of information in the Intent that are used for
235 * resolution: the action, type, and category. Using this information, a query
236 * is done on the {@link PackageManager} for a component that can handle the
237 * intent. The appropriate component is determined based on the intent
238 * information supplied in the <code>AndroidManifest.xml</code> file as
239 * follows:</p>
240 *
241 * <ul>
242 * <li> <p>The <b>action</b>, if given, must be listed by the component as
243 * one it handles.</p>
244 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
245 * already supplied in the Intent. Like the action, if a type is
246 * included in the intent (either explicitly or implicitly in its
247 * data), then this must be listed by the component as one it handles.</p>
248 * <li> For data that is not a <code>content:</code> URI and where no explicit
249 * type is included in the Intent, instead the <b>scheme</b> of the
250 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
251 * considered. Again like the action, if we are matching a scheme it
252 * must be listed by the component as one it can handle.
253 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
254 * by the activity as categories it handles. That is, if you include
255 * the categories {@link #CATEGORY_LAUNCHER} and
256 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
257 * with an intent that lists <em>both</em> of those categories.
258 * Activities will very often need to support the
259 * {@link #CATEGORY_DEFAULT} so that they can be found by
260 * {@link Context#startActivity Context.startActivity()}.</p>
261 * </ul>
262 *
263 * <p>For example, consider the Note Pad sample application that
264 * allows user to browse through a list of notes data and view details about
265 * individual items. Text in italics indicate places were you would replace a
266 * name with one specific to your own package.</p>
267 *
268 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
269 * package="<i>com.android.notepad</i>"&gt;
270 * &lt;application android:icon="@drawable/app_notes"
271 * android:label="@string/app_name"&gt;
272 *
273 * &lt;provider class=".NotePadProvider"
274 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
275 *
276 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
277 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700278 * &lt;action android:name="android.intent.action.MAIN" /&gt;
279 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700280 * &lt;/intent-filter&gt;
281 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700282 * &lt;action android:name="android.intent.action.VIEW" /&gt;
283 * &lt;action android:name="android.intent.action.EDIT" /&gt;
284 * &lt;action android:name="android.intent.action.PICK" /&gt;
285 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
286 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700289 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
290 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
291 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700292 * &lt;/intent-filter&gt;
293 * &lt;/activity&gt;
294 *
295 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
296 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700297 * &lt;action android:name="android.intent.action.VIEW" /&gt;
298 * &lt;action android:name="android.intent.action.EDIT" /&gt;
299 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
300 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;
302 *
303 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700304 * &lt;action android:name="android.intent.action.INSERT" /&gt;
305 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
306 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700307 * &lt;/intent-filter&gt;
308 *
309 * &lt;/activity&gt;
310 *
311 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
312 * android:theme="@android:style/Theme.Dialog"&gt;
313 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700314 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
315 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
317 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
318 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700319 * &lt;/intent-filter&gt;
320 * &lt;/activity&gt;
321 *
322 * &lt;/application&gt;
323 * &lt;/manifest&gt;</pre>
324 *
325 * <p>The first activity,
326 * <code>com.android.notepad.NotesList</code>, serves as our main
327 * entry into the app. It can do three things as described by its three intent
328 * templates:
329 * <ol>
330 * <li><pre>
331 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700332 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
333 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700334 * &lt;/intent-filter&gt;</pre>
335 * <p>This provides a top-level entry into the NotePad application: the standard
336 * MAIN action is a main entry point (not requiring any other information in
337 * the Intent), and the LAUNCHER category says that this entry point should be
338 * listed in the application launcher.</p>
339 * <li><pre>
340 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700341 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
342 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
343 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
344 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700345 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700346 * &lt;/intent-filter&gt;</pre>
347 * <p>This declares the things that the activity can do on a directory of
348 * notes. The type being supported is given with the &lt;type&gt; tag, where
349 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
350 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
351 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
352 * The activity allows the user to view or edit the directory of data (via
353 * the VIEW and EDIT actions), or to pick a particular note and return it
354 * to the caller (via the PICK action). Note also the DEFAULT category
355 * supplied here: this is <em>required</em> for the
356 * {@link Context#startActivity Context.startActivity} method to resolve your
357 * activity when its component name is not explicitly specified.</p>
358 * <li><pre>
359 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700360 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
361 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
362 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700363 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700364 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700365 * the user without needing to know where it came from. The data type
366 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
367 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
368 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
369 * The GET_CONTENT action is similar to the PICK action, where the activity
370 * will return to its caller a piece of data selected by the user. Here,
371 * however, the caller specifies the type of data they desire instead of
372 * the type of data the user will be picking from.</p>
373 * </ol>
374 *
375 * <p>Given these capabilities, the following intents will resolve to the
376 * NotesList activity:</p>
377 *
378 * <ul>
379 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
380 * activities that can be used as top-level entry points into an
381 * application.</p>
382 * <li> <p><b>{ action=android.app.action.MAIN,
383 * category=android.app.category.LAUNCHER }</b> is the actual intent
384 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700385 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700386 * data=content://com.google.provider.NotePad/notes }</b>
387 * displays a list of all the notes under
388 * "content://com.google.provider.NotePad/notes", which
389 * the user can browse through and see the details on.</p>
390 * <li> <p><b>{ action=android.app.action.PICK
391 * data=content://com.google.provider.NotePad/notes }</b>
392 * provides a list of the notes under
393 * "content://com.google.provider.NotePad/notes", from which
394 * the user can pick a note whose data URL is returned back to the caller.</p>
395 * <li> <p><b>{ action=android.app.action.GET_CONTENT
396 * type=vnd.android.cursor.item/vnd.google.note }</b>
397 * is similar to the pick action, but allows the caller to specify the
398 * kind of data they want back so that the system can find the appropriate
399 * activity to pick something of that data type.</p>
400 * </ul>
401 *
402 * <p>The second activity,
403 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
404 * note entry and allows them to edit it. It can do two things as described
405 * by its two intent templates:
406 * <ol>
407 * <li><pre>
408 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700409 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
410 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
411 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
412 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700413 * &lt;/intent-filter&gt;</pre>
414 * <p>The first, primary, purpose of this activity is to let the user interact
415 * with a single note, as decribed by the MIME type
416 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
417 * either VIEW a note or allow the user to EDIT it. Again we support the
418 * DEFAULT category to allow the activity to be launched without explicitly
419 * specifying its component.</p>
420 * <li><pre>
421 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700422 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
423 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
424 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700425 * &lt;/intent-filter&gt;</pre>
426 * <p>The secondary use of this activity is to insert a new note entry into
427 * an existing directory of notes. This is used when the user creates a new
428 * note: the INSERT action is executed on the directory of notes, causing
429 * this activity to run and have the user create the new note data which
430 * it then adds to the content provider.</p>
431 * </ol>
432 *
433 * <p>Given these capabilities, the following intents will resolve to the
434 * NoteEditor activity:</p>
435 *
436 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700437 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * shows the user the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.EDIT
441 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
442 * allows the user to edit the content of note <var>{ID}</var>.</p>
443 * <li> <p><b>{ action=android.app.action.INSERT
444 * data=content://com.google.provider.NotePad/notes }</b>
445 * creates a new, empty note in the notes list at
446 * "content://com.google.provider.NotePad/notes"
447 * and allows the user to edit it. If they keep their changes, the URI
448 * of the newly created note is returned to the caller.</p>
449 * </ul>
450 *
451 * <p>The last activity,
452 * <code>com.android.notepad.TitleEditor</code>, allows the user to
453 * edit the title of a note. This could be implemented as a class that the
454 * application directly invokes (by explicitly setting its component in
455 * the Intent), but here we show a way you can publish alternative
456 * operations on existing data:</p>
457 *
458 * <pre>
459 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700460 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
463 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
464 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700465 * &lt;/intent-filter&gt;</pre>
466 *
467 * <p>In the single intent template here, we
468 * have created our own private action called
469 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
470 * edit the title of a note. It must be invoked on a specific note
471 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
472 * view and edit actions, but here displays and edits the title contained
473 * in the note data.
474 *
475 * <p>In addition to supporting the default category as usual, our title editor
476 * also supports two other standard categories: ALTERNATIVE and
477 * SELECTED_ALTERNATIVE. Implementing
478 * these categories allows others to find the special action it provides
479 * without directly knowing about it, through the
480 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
481 * more often to build dynamic menu items with
482 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
483 * template here was also supply an explicit name for the template
484 * (via <code>android:label="@string/resolve_title"</code>) to better control
485 * what the user sees when presented with this activity as an alternative
486 * action to the data they are viewing.
487 *
488 * <p>Given these capabilities, the following intent will resolve to the
489 * TitleEditor activity:</p>
490 *
491 * <ul>
492 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
493 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
494 * displays and allows the user to edit the title associated
495 * with note <var>{ID}</var>.</p>
496 * </ul>
497 *
498 * <h3>Standard Activity Actions</h3>
499 *
500 * <p>These are the current standard actions that Intent defines for launching
501 * activities (usually through {@link Context#startActivity}. The most
502 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
503 * {@link #ACTION_EDIT}.
504 *
505 * <ul>
506 * <li> {@link #ACTION_MAIN}
507 * <li> {@link #ACTION_VIEW}
508 * <li> {@link #ACTION_ATTACH_DATA}
509 * <li> {@link #ACTION_EDIT}
510 * <li> {@link #ACTION_PICK}
511 * <li> {@link #ACTION_CHOOSER}
512 * <li> {@link #ACTION_GET_CONTENT}
513 * <li> {@link #ACTION_DIAL}
514 * <li> {@link #ACTION_CALL}
515 * <li> {@link #ACTION_SEND}
516 * <li> {@link #ACTION_SENDTO}
517 * <li> {@link #ACTION_ANSWER}
518 * <li> {@link #ACTION_INSERT}
519 * <li> {@link #ACTION_DELETE}
520 * <li> {@link #ACTION_RUN}
521 * <li> {@link #ACTION_SYNC}
522 * <li> {@link #ACTION_PICK_ACTIVITY}
523 * <li> {@link #ACTION_SEARCH}
524 * <li> {@link #ACTION_WEB_SEARCH}
525 * <li> {@link #ACTION_FACTORY_TEST}
526 * </ul>
527 *
528 * <h3>Standard Broadcast Actions</h3>
529 *
530 * <p>These are the current standard actions that Intent defines for receiving
531 * broadcasts (usually through {@link Context#registerReceiver} or a
532 * &lt;receiver&gt; tag in a manifest).
533 *
534 * <ul>
535 * <li> {@link #ACTION_TIME_TICK}
536 * <li> {@link #ACTION_TIME_CHANGED}
537 * <li> {@link #ACTION_TIMEZONE_CHANGED}
538 * <li> {@link #ACTION_BOOT_COMPLETED}
539 * <li> {@link #ACTION_PACKAGE_ADDED}
540 * <li> {@link #ACTION_PACKAGE_CHANGED}
541 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800542 * <li> {@link #ACTION_PACKAGE_RESTARTED}
543 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000544 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
545 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * <li> {@link #ACTION_UID_REMOVED}
547 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700548 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700549 * <li> {@link #ACTION_POWER_DISCONNECTED}
550 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700551 * </ul>
552 *
553 * <h3>Standard Categories</h3>
554 *
555 * <p>These are the current standard categories that can be used to further
556 * clarify an Intent via {@link #addCategory}.
557 *
558 * <ul>
559 * <li> {@link #CATEGORY_DEFAULT}
560 * <li> {@link #CATEGORY_BROWSABLE}
561 * <li> {@link #CATEGORY_TAB}
562 * <li> {@link #CATEGORY_ALTERNATIVE}
563 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
564 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700566 * <li> {@link #CATEGORY_HOME}
567 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700568 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400569 * <li> {@link #CATEGORY_CAR_DOCK}
570 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500571 * <li> {@link #CATEGORY_LE_DESK_DOCK}
572 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200573 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700574 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800575 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700576 * </ul>
577 *
578 * <h3>Standard Extra Data</h3>
579 *
580 * <p>These are the current standard fields that can be used as extra data via
581 * {@link #putExtra}.
582 *
583 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800584 * <li> {@link #EXTRA_ALARM_COUNT}
585 * <li> {@link #EXTRA_BCC}
586 * <li> {@link #EXTRA_CC}
587 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
588 * <li> {@link #EXTRA_DATA_REMOVED}
589 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500590 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
591 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800592 * <li> {@link #EXTRA_DOCK_STATE_CAR}
593 * <li> {@link #EXTRA_DOCK_STATE_DESK}
594 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
595 * <li> {@link #EXTRA_DONT_KILL_APP}
596 * <li> {@link #EXTRA_EMAIL}
597 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700598 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700600 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800601 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700602 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
604 * <li> {@link #EXTRA_REPLACING}
605 * <li> {@link #EXTRA_SHORTCUT_ICON}
606 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
607 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_SHORTCUT_NAME}
610 * <li> {@link #EXTRA_SUBJECT}
611 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800613 * <li> {@link #EXTRA_TITLE}
614 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 * </ul>
616 *
617 * <h3>Flags</h3>
618 *
619 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800620 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
621 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700622 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800623public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700624 private static final String ATTR_ACTION = "action";
625 private static final String TAG_CATEGORIES = "categories";
626 private static final String ATTR_CATEGORY = "category";
627 private static final String TAG_EXTRA = "extra";
628 private static final String ATTR_TYPE = "type";
629 private static final String ATTR_COMPONENT = "component";
630 private static final String ATTR_DATA = "data";
631 private static final String ATTR_FLAGS = "flags";
632
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700633 // ---------------------------------------------------------------------
634 // ---------------------------------------------------------------------
635 // Standard intent activity actions (see action variable).
636
637 /**
638 * Activity Action: Start as a main entry point, does not expect to
639 * receive data.
640 * <p>Input: nothing
641 * <p>Output: nothing
642 */
643 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
644 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700646 /**
647 * Activity Action: Display the data to the user. This is the most common
648 * action performed on data -- it is the generic action you can use on
649 * a piece of data to get the most reasonable thing to occur. For example,
650 * when used on a contacts entry it will view the entry; when used on a
651 * mailto: URI it will bring up a compose window filled with the information
652 * supplied by the URI; when used with a tel: URI it will invoke the
653 * dialer.
654 * <p>Input: {@link #getData} is URI from which to retrieve data.
655 * <p>Output: nothing.
656 */
657 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
658 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 /**
661 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
662 * performed on a piece of data.
663 */
664 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800665
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700666 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900667 * Activity Action: Quick view the data. Launches a quick viewer for
668 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900669 * <p>Activities handling this intent action should handle the vast majority of
670 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700671 * <p>Quick viewers must render the quick view image locally, and must not send
672 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900673 * <p>Input: {@link #getData} is a mandatory content URI of the item to
674 * preview. {@link #getClipData} contains an optional list of content URIs
675 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
676 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700677 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
678 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700679 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900680 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700681 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700682 */
683 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
684 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
685
686 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700687 * Used to indicate that some piece of data should be attached to some other
688 * place. For example, image data could be attached to a contact. It is up
689 * to the recipient to decide where the data should be attached; the intent
690 * does not specify the ultimate destination.
691 * <p>Input: {@link #getData} is URI of data to be attached.
692 * <p>Output: nothing.
693 */
694 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
695 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800696
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700697 /**
698 * Activity Action: Provide explicit editable access to the given data.
699 * <p>Input: {@link #getData} is URI of data to be edited.
700 * <p>Output: nothing.
701 */
702 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
703 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800704
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700705 /**
706 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
707 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
708 * The extras can contain type specific data to pass through to the editing/creating
709 * activity.
710 * <p>Output: The URI of the item that was picked. This must be a content:
711 * URI so that any receiver can access it.
712 */
713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 /**
717 * Activity Action: Pick an item from the data, returning what was selected.
718 * <p>Input: {@link #getData} is URI containing a directory of data
719 * (vnd.android.cursor.dir/*) from which to pick an item.
720 * <p>Output: The URI of the item that was picked.
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800724
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 /**
726 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800727 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800728 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
729 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700730 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
731 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800732 * (value: ShortcutIconResource).</p>
733 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800734 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700735 * @see #EXTRA_SHORTCUT_INTENT
736 * @see #EXTRA_SHORTCUT_NAME
737 * @see #EXTRA_SHORTCUT_ICON
738 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
739 * @see android.content.Intent.ShortcutIconResource
740 */
741 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
742 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
743
744 /**
745 * The name of the extra used to define the Intent of a shortcut.
746 *
747 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800748 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700749 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800750 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700751 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
752 /**
753 * The name of the extra used to define the name of a shortcut.
754 *
755 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800756 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700757 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800758 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
760 /**
761 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
762 *
763 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800764 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700765 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800766 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
768 /**
769 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
770 *
771 * @see #ACTION_CREATE_SHORTCUT
772 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
777 "android.intent.extra.shortcut.ICON_RESOURCE";
778
779 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500780 * An activity that provides a user interface for adjusting application preferences.
781 * Optional but recommended settings for all applications which have settings.
782 */
783 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
784 public static final String ACTION_APPLICATION_PREFERENCES
785 = "android.intent.action.APPLICATION_PREFERENCES";
786
787 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700788 * Activity Action: Launch an activity showing the app information.
789 * For applications which install other applications (such as app stores), it is recommended
790 * to handle this action for providing the app information to the user.
791 *
792 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
793 * to be displayed.
794 * <p>Output: Nothing.
795 */
796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
797 public static final String ACTION_SHOW_APP_INFO
798 = "android.intent.action.SHOW_APP_INFO";
799
800 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800801 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700802 *
803 * @see Intent#ACTION_CREATE_SHORTCUT
804 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800805 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
806 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700807 */
808 public static class ShortcutIconResource implements Parcelable {
809 /**
810 * The package name of the application containing the icon.
811 */
812 public String packageName;
813
814 /**
815 * The resource name of the icon, including package, name and type.
816 */
817 public String resourceName;
818
819 /**
820 * Creates a new ShortcutIconResource for the specified context and resource
821 * identifier.
822 *
823 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700824 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700825 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700826 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700827 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700828 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700829 ShortcutIconResource icon = new ShortcutIconResource();
830 icon.packageName = context.getPackageName();
831 icon.resourceName = context.getResources().getResourceName(resourceId);
832 return icon;
833 }
834
835 /**
836 * Used to read a ShortcutIconResource from a Parcel.
837 */
838 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
839 new Parcelable.Creator<ShortcutIconResource>() {
840
841 public ShortcutIconResource createFromParcel(Parcel source) {
842 ShortcutIconResource icon = new ShortcutIconResource();
843 icon.packageName = source.readString();
844 icon.resourceName = source.readString();
845 return icon;
846 }
847
848 public ShortcutIconResource[] newArray(int size) {
849 return new ShortcutIconResource[size];
850 }
851 };
852
853 /**
854 * No special parcel contents.
855 */
856 public int describeContents() {
857 return 0;
858 }
859
860 public void writeToParcel(Parcel dest, int flags) {
861 dest.writeString(packageName);
862 dest.writeString(resourceName);
863 }
864
865 @Override
866 public String toString() {
867 return resourceName;
868 }
869 }
870
871 /**
872 * Activity Action: Display an activity chooser, allowing the user to pick
873 * what they want to before proceeding. This can be used as an alternative
874 * to the standard activity picker that is displayed by the system when
875 * you try to start an activity with multiple possible matches, with these
876 * differences in behavior:
877 * <ul>
878 * <li>You can specify the title that will appear in the activity chooser.
879 * <li>The user does not have the option to make one of the matching
880 * activities a preferred activity, and all possible activities will
881 * always be shown even if one of them is currently marked as the
882 * preferred activity.
883 * </ul>
884 * <p>
885 * This action should be used when the user will naturally expect to
886 * select an activity in order to proceed. An example if when not to use
887 * it is when the user clicks on a "mailto:" link. They would naturally
888 * expect to go directly to their mail app, so startActivity() should be
889 * called directly: it will
890 * either launch the current preferred app, or put up a dialog allowing the
891 * user to pick an app to use and optionally marking that as preferred.
892 * <p>
893 * In contrast, if the user is selecting a menu item to send a picture
894 * they are viewing to someone else, there are many different things they
895 * may want to do at this point: send it through e-mail, upload it to a
896 * web service, etc. In this case the CHOOSER action should be used, to
897 * always present to the user a list of the things they can do, with a
898 * nice title given by the caller such as "Send this photo with:".
899 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700900 * If you need to grant URI permissions through a chooser, you must specify
901 * the permissions to be granted on the ACTION_CHOOSER Intent
902 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
903 * {@link #setClipData} to specify the URIs to be granted as well as
904 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
905 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
906 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700907 * As a convenience, an Intent of this form can be created with the
908 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700909 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700910 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700911 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
912 * and can optionally have a {@link #EXTRA_TITLE} field containing the
913 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700914 * <p>
915 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700916 */
917 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
918 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
919
920 /**
921 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
922 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700923 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
924 * target intent, also optionally supplying a title. If the target
925 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
926 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
927 * set in the returned chooser intent, with its ClipData set appropriately:
928 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500929 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700930 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700931 * @param target The Intent that the user will be selecting an activity
932 * to perform.
933 * @param title Optional title that will be displayed in the chooser.
934 * @return Return a new Intent object that you can hand to
935 * {@link Context#startActivity(Intent) Context.startActivity()} and
936 * related methods.
937 */
938 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700939 return createChooser(target, title, null);
940 }
941
942 /**
943 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
944 *
945 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
946 * target intent, also optionally supplying a title. If the target
947 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
948 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
949 * set in the returned chooser intent, with its ClipData set appropriately:
950 * either a direct reflection of {@link #getClipData()} if that is non-null,
951 * or a new ClipData built from {@link #getData()}.</p>
952 *
953 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
954 * when the user makes a choice. This can be useful if the calling application wants
955 * to remember the last chosen target and surface it as a more prominent or one-touch
956 * affordance elsewhere in the UI for next time.</p>
957 *
958 * @param target The Intent that the user will be selecting an activity
959 * to perform.
960 * @param title Optional title that will be displayed in the chooser.
961 * @param sender Optional IntentSender to be called when a choice is made.
962 * @return Return a new Intent object that you can hand to
963 * {@link Context#startActivity(Intent) Context.startActivity()} and
964 * related methods.
965 */
966 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700967 Intent intent = new Intent(ACTION_CHOOSER);
968 intent.putExtra(EXTRA_INTENT, target);
969 if (title != null) {
970 intent.putExtra(EXTRA_TITLE, title);
971 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700972
Adam Powell0b3c1122014-10-09 12:50:14 -0700973 if (sender != null) {
974 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
975 }
976
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700977 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700978 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
979 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
980 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700981 if (permFlags != 0) {
982 ClipData targetClipData = target.getClipData();
983 if (targetClipData == null && target.getData() != null) {
984 ClipData.Item item = new ClipData.Item(target.getData());
985 String[] mimeTypes;
986 if (target.getType() != null) {
987 mimeTypes = new String[] { target.getType() };
988 } else {
989 mimeTypes = new String[] { };
990 }
991 targetClipData = new ClipData(null, mimeTypes, item);
992 }
993 if (targetClipData != null) {
994 intent.setClipData(targetClipData);
995 intent.addFlags(permFlags);
996 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700997 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700998
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700999 return intent;
1000 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001001
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001002 /**
1003 * Activity Action: Allow the user to select a particular kind of data and
1004 * return it. This is different than {@link #ACTION_PICK} in that here we
1005 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001006 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001007 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001008 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001009 * etc.
1010 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001011 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001012 * of data, such as a person contact, you set the MIME type to the kind of
1013 * data you want and launch it with {@link Context#startActivity(Intent)}.
1014 * The system will then launch the best application to select that kind
1015 * of data for you.
1016 * <p>
1017 * You may also be interested in any of a set of types of content the user
1018 * can pick. For example, an e-mail application that wants to allow the
1019 * user to add an attachment to an e-mail message can use this action to
1020 * bring up a list of all of the types of content the user can attach.
1021 * <p>
1022 * In this case, you should wrap the GET_CONTENT intent with a chooser
1023 * (through {@link #createChooser}), which will give the proper interface
1024 * for the user to pick how to send your data and allow you to specify
1025 * a prompt indicating what they are doing. You will usually specify a
1026 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1027 * broad range of content types the user can select from.
1028 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001029 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001030 * only pick from data that can be represented as a stream. This is
1031 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1032 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001033 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001034 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001035 * is locally available on the device. For example, if this extra is set
1036 * to true then an image picker should not show any pictures that are available
1037 * from a remote server but not already on the local device (thus requiring
1038 * they be downloaded when opened).
1039 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001040 * If the caller can handle multiple returned items (the user performing
1041 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1042 * to indicate this.
1043 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001044 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1045 * that no URI is supplied in the intent, as there are no constraints on
1046 * where the returned data originally comes from. You may also include the
1047 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001048 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001049 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1050 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001051 * <p>
1052 * Output: The URI of the item that was picked. This must be a content:
1053 * URI so that any receiver can access it.
1054 */
1055 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1056 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1057 /**
1058 * Activity Action: Dial a number as specified by the data. This shows a
1059 * UI with the number being dialed, allowing the user to explicitly
1060 * initiate the call.
1061 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1062 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1063 * number.
1064 * <p>Output: nothing.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1068 /**
1069 * Activity Action: Perform a call to someone specified by the data.
1070 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1071 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1072 * number.
1073 * <p>Output: nothing.
1074 *
1075 * <p>Note: there will be restrictions on which applications can initiate a
1076 * call; most applications should use the {@link #ACTION_DIAL}.
1077 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1078 * numbers. Applications can <strong>dial</strong> emergency numbers using
1079 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001080 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001081 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001082 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001083 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001084 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001085 */
1086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1087 public static final String ACTION_CALL = "android.intent.action.CALL";
1088 /**
1089 * Activity Action: Perform a call to an emergency number specified by the
1090 * data.
1091 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1092 * tel: URI of an explicit phone number.
1093 * <p>Output: nothing.
1094 * @hide
1095 */
1096 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1097 /**
1098 * Activity action: Perform a call to any number (emergency or not)
1099 * specified by the data.
1100 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1101 * tel: URI of an explicit phone number.
1102 * <p>Output: nothing.
1103 * @hide
1104 */
1105 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001106
Santos Cordon15a13782015-03-31 18:32:31 -07001107 /**
fionaxuadfe7002017-02-17 17:20:46 -08001108 * Activity Action: Main entry point for carrier setup apps.
1109 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1110 * carrier service and typically require
1111 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1112 * fulfill their duties.
1113 */
1114 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1115 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1116 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001117 * Activity Action: Send a message to someone specified by the data.
1118 * <p>Input: {@link #getData} is URI describing the target.
1119 * <p>Output: nothing.
1120 */
1121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1122 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1123 /**
1124 * Activity Action: Deliver some data to someone else. Who the data is
1125 * being delivered to is not specified; it is up to the receiver of this
1126 * action to ask the user where the data should be sent.
1127 * <p>
1128 * When launching a SEND intent, you should usually wrap it in a chooser
1129 * (through {@link #createChooser}), which will give the proper interface
1130 * for the user to pick how to send your data and allow you to specify
1131 * a prompt indicating what they are doing.
1132 * <p>
1133 * Input: {@link #getType} is the MIME type of the data being sent.
1134 * get*Extra can have either a {@link #EXTRA_TEXT}
1135 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1136 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1137 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1138 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001139 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1140 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1141 * your text with HTML formatting.
1142 * <p>
1143 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1144 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1145 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1146 * content: URIs and other advanced features of {@link ClipData}. If
1147 * using this approach, you still must supply the same data through the
1148 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1149 * for compatibility with old applications. If you don't set a ClipData,
1150 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001151 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001152 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1153 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1154 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1155 * be openable only as asset typed files using
1156 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1157 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001158 * Optional standard extras, which may be interpreted by some recipients as
1159 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1160 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1161 * <p>
1162 * Output: nothing.
1163 */
1164 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1165 public static final String ACTION_SEND = "android.intent.action.SEND";
1166 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001167 * Activity Action: Deliver multiple data to someone else.
1168 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001169 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001170 * <p>
1171 * Input: {@link #getType} is the MIME type of the data being sent.
1172 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001173 * #EXTRA_STREAM} field, containing the data to be sent. If using
1174 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1175 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001176 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001177 * Multiple types are supported, and receivers should handle mixed types
1178 * whenever possible. The right way for the receiver to check them is to
1179 * use the content resolver on each URI. The intent sender should try to
1180 * put the most concrete mime type in the intent type, but it can fall
1181 * back to {@literal <type>/*} or {@literal *}/* as needed.
1182 * <p>
1183 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1184 * be image/jpg, but if you are sending image/jpg and image/png, then the
1185 * intent's type should be image/*.
1186 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001187 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1188 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1189 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1190 * content: URIs and other advanced features of {@link ClipData}. If
1191 * using this approach, you still must supply the same data through the
1192 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1193 * for compatibility with old applications. If you don't set a ClipData,
1194 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1195 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001196 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1197 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1198 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1199 * be openable only as asset typed files using
1200 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1201 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001202 * Optional standard extras, which may be interpreted by some recipients as
1203 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1204 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1205 * <p>
1206 * Output: nothing.
1207 */
1208 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1209 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1210 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001211 * Activity Action: Handle an incoming phone call.
1212 * <p>Input: nothing.
1213 * <p>Output: nothing.
1214 */
1215 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1216 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1217 /**
1218 * Activity Action: Insert an empty item into the given container.
1219 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1220 * in which to place the data.
1221 * <p>Output: URI of the new data that was created.
1222 */
1223 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1224 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1225 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001226 * Activity Action: Create a new item in the given container, initializing it
1227 * from the current contents of the clipboard.
1228 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1229 * in which to place the data.
1230 * <p>Output: URI of the new data that was created.
1231 */
1232 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1233 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1234 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001235 * Activity Action: Delete the given data from its container.
1236 * <p>Input: {@link #getData} is URI of data to be deleted.
1237 * <p>Output: nothing.
1238 */
1239 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1240 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1241 /**
1242 * Activity Action: Run the data, whatever that means.
1243 * <p>Input: ? (Note: this is currently specific to the test harness.)
1244 * <p>Output: nothing.
1245 */
1246 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1247 public static final String ACTION_RUN = "android.intent.action.RUN";
1248 /**
1249 * Activity Action: Perform a data synchronization.
1250 * <p>Input: ?
1251 * <p>Output: ?
1252 */
1253 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1254 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1255 /**
1256 * Activity Action: Pick an activity given an intent, returning the class
1257 * selected.
1258 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1259 * used with {@link PackageManager#queryIntentActivities} to determine the
1260 * set of activities from which to pick.
1261 * <p>Output: Class name of the activity that was selected.
1262 */
1263 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1264 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1265 /**
1266 * Activity Action: Perform a search.
1267 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1268 * is the text to search for. If empty, simply
1269 * enter your search results Activity with the search UI activated.
1270 * <p>Output: nothing.
1271 */
1272 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1273 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1274 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001275 * Activity Action: Start the platform-defined tutorial
1276 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1277 * is the text to search for. If empty, simply
1278 * enter your search results Activity with the search UI activated.
1279 * <p>Output: nothing.
1280 */
1281 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1282 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1283 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001284 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001285 * <p>
1286 * Input: {@link android.app.SearchManager#QUERY
1287 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1288 * a url starts with http or https, the site will be opened. If it is plain
1289 * text, Google search will be applied.
1290 * <p>
1291 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001292 */
1293 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1294 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001295
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001296 /**
Jim Miller07994402012-05-02 14:22:27 -07001297 * Activity Action: Perform assist action.
1298 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001299 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1300 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001301 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1302 * information.
Jim Miller07994402012-05-02 14:22:27 -07001303 * Output: nothing.
1304 */
1305 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1306 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001307
1308 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001309 * Activity Action: Perform voice assist action.
1310 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001311 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1312 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001313 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001314 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001315 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001316 */
Amith Yamasani16452032017-03-03 10:15:57 -08001317 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1320
1321 /**
Adam Skory7140a252013-09-11 12:04:58 +01001322 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1323 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001324 */
1325 public static final String EXTRA_ASSIST_PACKAGE
1326 = "android.intent.extra.ASSIST_PACKAGE";
1327
1328 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001329 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1330 * application package at the time the assist was invoked.
1331 */
1332 public static final String EXTRA_ASSIST_UID
1333 = "android.intent.extra.ASSIST_UID";
1334
1335 /**
Adam Skory7140a252013-09-11 12:04:58 +01001336 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1337 * information supplied by the current foreground app at the time of the assist request.
1338 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001339 */
1340 public static final String EXTRA_ASSIST_CONTEXT
1341 = "android.intent.extra.ASSIST_CONTEXT";
1342
Jim Miller07994402012-05-02 14:22:27 -07001343 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001344 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1345 * keyboard as the primary input device for assistance.
1346 */
1347 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1348 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1349
1350 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001351 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1352 * that was used to invoke the assist.
1353 */
1354 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1355 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1356
1357 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001358 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001359 * <p>Input: Nothing.
1360 * <p>Output: nothing.
1361 */
1362 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1363 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1364 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001365 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001366 * <p>Input: Nothing.
1367 * <p>Output: Nothing.
1368 */
1369 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1370 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1371
1372 /**
1373 * Activity Action: Show activity for reporting a bug.
1374 * <p>Input: Nothing.
1375 * <p>Output: Nothing.
1376 */
1377 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1378 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1379
1380 /**
1381 * Activity Action: Main entry point for factory tests. Only used when
1382 * the device is booting in factory test node. The implementing package
1383 * must be installed in the system image.
1384 * <p>Input: nothing
1385 * <p>Output: nothing
1386 */
1387 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1388
1389 /**
1390 * Activity Action: The user pressed the "call" button to go to the dialer
1391 * or other appropriate UI for placing a call.
1392 * <p>Input: Nothing.
1393 * <p>Output: Nothing.
1394 */
1395 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1396 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1397
1398 /**
1399 * Activity Action: Start Voice Command.
1400 * <p>Input: Nothing.
1401 * <p>Output: Nothing.
1402 */
1403 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1404 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001405
1406 /**
1407 * Activity Action: Start action associated with long pressing on the
1408 * search key.
1409 * <p>Input: Nothing.
1410 * <p>Output: Nothing.
1411 */
1412 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1413 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001414
Jacek Surazski86b6c532009-05-13 14:38:28 +02001415 /**
1416 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1417 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001418 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001419 * <p>Input: No data is specified. The bug report is passed in using
1420 * an {@link #EXTRA_BUG_REPORT} field.
1421 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001422 *
1423 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001424 */
1425 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1426 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001427
1428 /**
1429 * Activity Action: Show power usage information to the user.
1430 * <p>Input: Nothing.
1431 * <p>Output: Nothing.
1432 */
1433 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1434 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001435
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001436 /**
1437 * Activity Action: Setup wizard to launch after a platform update. This
1438 * activity should have a string meta-data field associated with it,
1439 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1440 * the platform for setup. The activity will be launched only if
1441 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1442 * same value.
1443 * <p>Input: Nothing.
1444 * <p>Output: Nothing.
1445 * @hide
1446 */
1447 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1448 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001449
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001450 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001451 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1452 * <p>Input: Nothing.
1453 * <p>Output: Nothing.
1454 * @hide
1455 */
1456 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1457 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001458 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001459
1460 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001461 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1462 * <p>Input: Nothing.
1463 * <p>Output: Nothing.
1464 * @hide
1465 */
1466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1467 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001468 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001469
1470 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001471 * Activity Action: Show settings for managing network data usage of a
1472 * specific application. Applications should define an activity that offers
1473 * options to control data usage.
1474 */
1475 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1476 public static final String ACTION_MANAGE_NETWORK_USAGE =
1477 "android.intent.action.MANAGE_NETWORK_USAGE";
1478
1479 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001480 * Activity Action: Launch application installer.
1481 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001482 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001483 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1484 * you can also use "package:<package-name>" to install an application for the
1485 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001486 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1487 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1488 * <p>
1489 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1490 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001491 * <p>
1492 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1493 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1494 * in order to launch the application installer.
1495 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001496 *
1497 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1498 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1499 * @see #EXTRA_RETURN_RESULT
1500 */
1501 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1502 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1503
1504 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001505 * Activity Action: Launch ephemeral installer.
1506 * <p>
1507 * Input: The data must be a http: URI that the ephemeral application is registered
1508 * to handle.
1509 * <p class="note">
1510 * This is a protected intent that can only be sent by the system.
1511 * </p>
1512 *
1513 * @hide
1514 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001515 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1516 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1517 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1518
1519 /**
1520 * Service Action: Resolve ephemeral application.
1521 * <p>
1522 * The system will have a persistent connection to this service.
1523 * This is a protected intent that can only be sent by the system.
1524 * </p>
1525 *
1526 * @hide
1527 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001528 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1529 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1530 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1531
1532 /**
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001533 * Activity Action: Launch ephemeral settings.
1534 *
1535 * <p class="note">
1536 * This is a protected intent that can only be sent by the system.
1537 * </p>
1538 *
1539 * @hide
1540 */
1541 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1542 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1543 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1544
1545 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001546 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1547 * package. Specifies the installer package name; this package will receive the
1548 * {@link #ACTION_APP_ERROR} intent.
1549 */
1550 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1551 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1552
1553 /**
1554 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1555 * package. Specifies that the application being installed should not be
1556 * treated as coming from an unknown source, but as coming from the app
1557 * invoking the Intent. For this to work you must start the installer with
1558 * startActivityForResult().
1559 */
1560 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1561 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1562
1563 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001564 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1565 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001566 * data field originated from.
1567 */
rich cannings706e8ba2012-08-20 13:20:14 -07001568 public static final String EXTRA_ORIGINATING_URI
1569 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001570
1571 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001572 * This extra can be used with any Intent used to launch an activity, supplying information
1573 * about who is launching that activity. This field contains a {@link android.net.Uri}
1574 * object, typically an http: or https: URI of the web site that the referral came from;
1575 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1576 * a native application that it came from.
1577 *
1578 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1579 * instead of directly retrieving the extra. It is also valid for applications to
1580 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1581 * a string, not a Uri; the field here, if supplied, will always take precedence,
1582 * however.</p>
1583 *
1584 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001585 */
1586 public static final String EXTRA_REFERRER
1587 = "android.intent.extra.REFERRER";
1588
1589 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001590 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1591 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1592 * not be created, in particular when Intent extras are supplied through the
1593 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1594 * schemes.
1595 *
1596 * @see #EXTRA_REFERRER
1597 */
1598 public static final String EXTRA_REFERRER_NAME
1599 = "android.intent.extra.REFERRER_NAME";
1600
1601 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001602 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001603 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001604 * @hide
1605 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001606 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001607 public static final String EXTRA_ORIGINATING_UID
1608 = "android.intent.extra.ORIGINATING_UID";
1609
1610 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001611 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1612 * package. Tells the installer UI to skip the confirmation with the user
1613 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001614 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1615 * will no longer show an interstitial message about updating existing
1616 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001617 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001618 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001619 public static final String EXTRA_ALLOW_REPLACE
1620 = "android.intent.extra.ALLOW_REPLACE";
1621
1622 /**
1623 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1624 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1625 * return to the application the result code of the install/uninstall. The returned result
1626 * code will be {@link android.app.Activity#RESULT_OK} on success or
1627 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1628 */
1629 public static final String EXTRA_RETURN_RESULT
1630 = "android.intent.extra.RETURN_RESULT";
1631
1632 /**
1633 * Package manager install result code. @hide because result codes are not
1634 * yet ready to be exposed.
1635 */
1636 public static final String EXTRA_INSTALL_RESULT
1637 = "android.intent.extra.INSTALL_RESULT";
1638
1639 /**
1640 * Activity Action: Launch application uninstaller.
1641 * <p>
1642 * Input: The data must be a package: URI whose scheme specific part is
1643 * the package name of the current installed package to be uninstalled.
1644 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1645 * <p>
1646 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1647 * succeeded.
1648 */
1649 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1650 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1651
1652 /**
msnider3c191b82017-01-23 14:23:16 -08001653 * Activity Action: Launch application uninstaller.
1654 * <p>
1655 * Input: The data must be a package: URI whose scheme specific part is
1656 * the package name of the current installed package to be uninstalled.
1657 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1658 * <p>
1659 * Output: Nothing.
1660 * </p>
1661 */
1662 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1663 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1664
1665 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001666 * Specify whether the package should be uninstalled for all users.
1667 * @hide because these should not be part of normal application flow.
1668 */
1669 public static final String EXTRA_UNINSTALL_ALL_USERS
1670 = "android.intent.extra.UNINSTALL_ALL_USERS";
1671
1672 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001673 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1674 * describing the last run version of the platform that was setup.
1675 * @hide
1676 */
1677 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1678
Svet Ganov3695b8a2015-03-24 16:30:25 -07001679 /**
1680 * Activity action: Launch UI to manage the permissions of an app.
1681 * <p>
1682 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1683 * will be managed by the launched UI.
1684 * </p>
1685 * <p>
1686 * Output: Nothing.
1687 * </p>
1688 *
1689 * @see #EXTRA_PACKAGE_NAME
1690 *
1691 * @hide
1692 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001693 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001694 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1695 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1696 "android.intent.action.MANAGE_APP_PERMISSIONS";
1697
1698 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001699 * Activity action: Launch UI to manage permissions.
1700 * <p>
1701 * Input: Nothing.
1702 * </p>
1703 * <p>
1704 * Output: Nothing.
1705 * </p>
1706 *
1707 * @hide
1708 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001709 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1711 public static final String ACTION_MANAGE_PERMISSIONS =
1712 "android.intent.action.MANAGE_PERMISSIONS";
1713
1714 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001715 * Activity action: Launch UI to review permissions for an app.
1716 * The system uses this intent if permission review for apps not
1717 * supporting the new runtime permissions model is enabled. In
1718 * this mode a permission review is required before any of the
1719 * app components can run.
1720 * <p>
1721 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1722 * permissions will be reviewed (mandatory).
1723 * </p>
1724 * <p>
1725 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1726 * be fired after the permission review (optional).
1727 * </p>
1728 * <p>
1729 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1730 * be invoked after the permission review (optional).
1731 * </p>
1732 * <p>
1733 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1734 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1735 * </p>
1736 * <p>
1737 * Output: Nothing.
1738 * </p>
1739 *
1740 * @see #EXTRA_PACKAGE_NAME
1741 * @see #EXTRA_INTENT
1742 * @see #EXTRA_REMOTE_CALLBACK
1743 * @see #EXTRA_RESULT_NEEDED
1744 *
1745 * @hide
1746 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001747 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001748 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1749 public static final String ACTION_REVIEW_PERMISSIONS =
1750 "android.intent.action.REVIEW_PERMISSIONS";
1751
1752 /**
1753 * Intent extra: A callback for reporting remote result as a bundle.
1754 * <p>
1755 * Type: IRemoteCallback
1756 * </p>
1757 *
1758 * @hide
1759 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001760 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001761 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1762
1763 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001764 * Intent extra: An app package name.
1765 * <p>
1766 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001767 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001768 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001769 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001770 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1771
1772 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001773 * Intent extra: An app split name.
1774 * <p>
1775 * Type: String
1776 * </p>
1777 * @hide
1778 */
1779 @SystemApi
1780 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1781
1782 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001783 * Intent extra: An extra for specifying whether a result is needed.
1784 * <p>
1785 * Type: boolean
1786 * </p>
1787 *
1788 * @hide
1789 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001790 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001791 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1792
1793 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001794 * Activity action: Launch UI to manage which apps have a given permission.
1795 * <p>
1796 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1797 * to which will be managed by the launched UI.
1798 * </p>
1799 * <p>
1800 * Output: Nothing.
1801 * </p>
1802 *
1803 * @see #EXTRA_PERMISSION_NAME
1804 *
1805 * @hide
1806 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001807 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001808 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1809 public static final String ACTION_MANAGE_PERMISSION_APPS =
1810 "android.intent.action.MANAGE_PERMISSION_APPS";
1811
1812 /**
1813 * Intent extra: The name of a permission.
1814 * <p>
1815 * Type: String
1816 * </p>
1817 *
1818 * @hide
1819 */
1820 @SystemApi
1821 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1822
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001823 // ---------------------------------------------------------------------
1824 // ---------------------------------------------------------------------
1825 // Standard intent broadcast actions (see action variable).
1826
1827 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001828 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1829 * <p>
1830 * For historical reasons, the name of this broadcast action refers to the power
1831 * state of the screen but it is actually sent in response to changes in the
1832 * overall interactive state of the device.
1833 * </p><p>
1834 * This broadcast is sent when the device becomes non-interactive which may have
1835 * nothing to do with the screen turning off. To determine the
1836 * actual state of the screen, use {@link android.view.Display#getState}.
1837 * </p><p>
1838 * See {@link android.os.PowerManager#isInteractive} for details.
1839 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001840 * You <em>cannot</em> receive this through components declared in
1841 * manifests, only by explicitly registering for it with
1842 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1843 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001844 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001845 * <p class="note">This is a protected intent that can only be sent
1846 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001847 */
1848 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1849 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001850
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001851 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001852 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1853 * <p>
1854 * For historical reasons, the name of this broadcast action refers to the power
1855 * state of the screen but it is actually sent in response to changes in the
1856 * overall interactive state of the device.
1857 * </p><p>
1858 * This broadcast is sent when the device becomes interactive which may have
1859 * nothing to do with the screen turning on. To determine the
1860 * actual state of the screen, use {@link android.view.Display#getState}.
1861 * </p><p>
1862 * See {@link android.os.PowerManager#isInteractive} for details.
1863 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001864 * You <em>cannot</em> receive this through components declared in
1865 * manifests, only by explicitly registering for it with
1866 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1867 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001868 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001869 * <p class="note">This is a protected intent that can only be sent
1870 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001871 */
1872 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1873 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001874
1875 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001876 * Broadcast Action: Sent after the system stops dreaming.
1877 *
1878 * <p class="note">This is a protected intent that can only be sent by the system.
1879 * It is only sent to registered receivers.</p>
1880 */
1881 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1882 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1883
1884 /**
1885 * Broadcast Action: Sent after the system starts dreaming.
1886 *
1887 * <p class="note">This is a protected intent that can only be sent by the system.
1888 * It is only sent to registered receivers.</p>
1889 */
1890 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1891 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1892
1893 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001894 * 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 -07001895 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001896 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001897 * <p class="note">This is a protected intent that can only be sent
1898 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001899 */
1900 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001901 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001902
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001903 /**
1904 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001905 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001906 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001907 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1908 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001909 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001910 * <p class="note">This is a protected intent that can only be sent
1911 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001912 */
1913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1914 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1915 /**
1916 * Broadcast Action: The time was set.
1917 */
1918 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1919 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1920 /**
1921 * Broadcast Action: The date has changed.
1922 */
1923 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1924 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1925 /**
1926 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1927 * <ul>
1928 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1929 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001930 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001931 * <p class="note">This is a protected intent that can only be sent
1932 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001933 */
1934 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1935 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1936 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001937 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1938 * DNS entries should be tossed.
1939 * @hide
1940 */
1941 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1942 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1943 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001944 * Alarm Changed Action: This is broadcast when the AlarmClock
1945 * application's alarm is set or unset. It is used by the
1946 * AlarmClock application and the StatusBar service.
1947 * @hide
1948 */
1949 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1950 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001951
1952 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001953 * Broadcast Action: This is broadcast once, after the user has finished
1954 * booting, but while still in the "locked" state. It can be used to perform
1955 * application-specific initialization, such as installing alarms. You must
1956 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1957 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001958 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001959 * This broadcast is sent immediately at boot by all devices (regardless of
1960 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1961 * higher. Upon receipt of this broadcast, the user is still locked and only
1962 * device-protected storage can be accessed safely. If you want to access
1963 * credential-protected storage, you need to wait for the user to be
1964 * unlocked (typically by entering their lock pattern or PIN for the first
1965 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1966 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1967 * <p>
1968 * To receive this broadcast, your receiver component must be marked as
1969 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001970 * <p class="note">
1971 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001972 *
1973 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001974 */
1975 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1976 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1977
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001978 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001979 * Broadcast Action: This is broadcast once, after the user has finished
1980 * booting. It can be used to perform application-specific initialization,
1981 * such as installing alarms. You must hold the
1982 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1983 * order to receive this broadcast.
1984 * <p>
1985 * This broadcast is sent at boot by all devices (both with and without
1986 * direct boot support). Upon receipt of this broadcast, the user is
1987 * unlocked and both device-protected and credential-protected storage can
1988 * accessed safely.
1989 * <p>
1990 * If you need to run while the user is still locked (before they've entered
1991 * their lock pattern or PIN for the first time), you can listen for the
1992 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1993 * <p class="note">
1994 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001995 */
1996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07001997 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001998 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001999
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002000 /**
2001 * Broadcast Action: This is broadcast when a user action should request a
2002 * temporary system dialog to dismiss. Some examples of temporary system
2003 * dialogs are the notification window-shade and the recent tasks dialog.
2004 */
2005 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2006 /**
2007 * Broadcast Action: Trigger the download and eventual installation
2008 * of a package.
2009 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002010 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002011 * <p class="note">This is a protected intent that can only be sent
2012 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002013 *
2014 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002015 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002016 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002017 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2018 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2019 /**
2020 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002021 * device. The data contains the name of the package. Note that the
2022 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002023 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002024 * <ul>
2025 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2026 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2027 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2028 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002029 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002030 * <p class="note">This is a protected intent that can only be sent
2031 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002032 */
2033 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2034 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2035 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002036 * Broadcast Action: A new version of an application package has been
2037 * installed, replacing an existing version that was previously installed.
2038 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002039 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002040 * <ul>
2041 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2042 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002043 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002044 * <p class="note">This is a protected intent that can only be sent
2045 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002046 */
2047 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2048 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2049 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002050 * Broadcast Action: A new version of your application has been installed
2051 * over an existing one. This is only sent to the application that was
2052 * replaced. It does not contain any additional data; to receive it, just
2053 * use an intent filter for this action.
2054 *
2055 * <p class="note">This is a protected intent that can only be sent
2056 * by the system.
2057 */
2058 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2059 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2060 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002061 * Broadcast Action: An existing application package has been removed from
2062 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002063 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002064 * <ul>
2065 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2066 * to the package.
2067 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2068 * application -- data and code -- is being removed.
2069 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2070 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2071 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002072 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002073 * <p class="note">This is a protected intent that can only be sent
2074 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002075 */
2076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2077 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2078 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002079 * Broadcast Action: An existing application package has been completely
2080 * removed from the device. The data contains the name of the package.
2081 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2082 * {@link #EXTRA_DATA_REMOVED} is true and
2083 * {@link #EXTRA_REPLACING} is false of that broadcast.
2084 *
2085 * <ul>
2086 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2087 * to the package.
2088 * </ul>
2089 *
2090 * <p class="note">This is a protected intent that can only be sent
2091 * by the system.
2092 */
2093 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2094 public static final String ACTION_PACKAGE_FULLY_REMOVED
2095 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2096 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002097 * Broadcast Action: An existing application package has been changed (for
2098 * example, a component has been enabled or disabled). The data contains
2099 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002100 * <ul>
2101 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002102 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002103 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002104 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2105 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002106 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002107 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002108 * <p class="note">This is a protected intent that can only be sent
2109 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002110 */
2111 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2112 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2113 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002114 * @hide
2115 * Broadcast Action: Ask system services if there is any reason to
2116 * restart the given package. The data contains the name of the
2117 * package.
2118 * <ul>
2119 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2120 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2121 * </ul>
2122 *
2123 * <p class="note">This is a protected intent that can only be sent
2124 * by the system.
2125 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002126 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002127 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2128 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2129 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002130 * Broadcast Action: The user has restarted a package, and all of its
2131 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002132 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002133 * be removed. Note that the restarted package does <em>not</em>
2134 * receive this broadcast.
2135 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002136 * <ul>
2137 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2138 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002139 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002140 * <p class="note">This is a protected intent that can only be sent
2141 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002142 */
2143 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2144 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2145 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002146 * Broadcast Action: The user has cleared the data of a package. This should
2147 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002148 * its persistent data is erased and this broadcast sent.
2149 * Note that the cleared package does <em>not</em>
2150 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002151 * <ul>
2152 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2153 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002154 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002155 * <p class="note">This is a protected intent that can only be sent
2156 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002157 */
2158 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2159 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2160 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002161 * Broadcast Action: Packages have been suspended.
2162 * <p>Includes the following extras:
2163 * <ul>
2164 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2165 * </ul>
2166 *
2167 * <p class="note">This is a protected intent that can only be sent
2168 * by the system. It is only sent to registered receivers.
2169 */
2170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2171 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2172 /**
2173 * Broadcast Action: Packages have been unsuspended.
2174 * <p>Includes the following extras:
2175 * <ul>
2176 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2177 * </ul>
2178 *
2179 * <p class="note">This is a protected intent that can only be sent
2180 * by the system. It is only sent to registered receivers.
2181 */
2182 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2183 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2184 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002185 * Broadcast Action: A user ID has been removed from the system. The user
2186 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002187 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002188 * <p class="note">This is a protected intent that can only be sent
2189 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002190 */
2191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2192 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002193
2194 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002195 * Broadcast Action: Sent to the installer package of an application when
2196 * that application is first launched (that is the first time it is moved
2197 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002198 *
2199 * <p class="note">This is a protected intent that can only be sent
2200 * by the system.
2201 */
2202 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2203 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2204
2205 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002206 * Broadcast Action: Sent to the system package verifier when a package
2207 * needs to be verified. The data contains the package URI.
2208 * <p class="note">
2209 * This is a protected intent that can only be sent by the system.
2210 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002211 */
2212 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2213 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2214
2215 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002216 * Broadcast Action: Sent to the system package verifier when a package is
2217 * verified. The data contains the package URI.
2218 * <p class="note">
2219 * This is a protected intent that can only be sent by the system.
2220 */
2221 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2222 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2223
2224 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002225 * Broadcast Action: Sent to the system intent filter verifier when an
2226 * intent filter needs to be verified. The data contains the filter data
2227 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002228 * <p class="note">
2229 * This is a protected intent that can only be sent by the system.
2230 * </p>
2231 *
2232 * @hide
2233 */
2234 @SystemApi
2235 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2236 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2237
2238 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002239 * Broadcast Action: Resources for a set of packages (which were
2240 * previously unavailable) are currently
2241 * available since the media on which they exist is available.
2242 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2243 * list of packages whose availability changed.
2244 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2245 * list of uids of packages whose availability changed.
2246 * Note that the
2247 * packages in this list do <em>not</em> receive this broadcast.
2248 * The specified set of packages are now available on the system.
2249 * <p>Includes the following extras:
2250 * <ul>
2251 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2252 * whose resources(were previously unavailable) are currently available.
2253 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2254 * packages whose resources(were previously unavailable)
2255 * are currently available.
2256 * </ul>
2257 *
2258 * <p class="note">This is a protected intent that can only be sent
2259 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002260 */
2261 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002262 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2263 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002264
2265 /**
2266 * Broadcast Action: Resources for a set of packages are currently
2267 * unavailable since the media on which they exist is unavailable.
2268 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2269 * list of packages whose availability changed.
2270 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2271 * list of uids of packages whose availability changed.
2272 * The specified set of packages can no longer be
2273 * launched and are practically unavailable on the system.
2274 * <p>Inclues the following extras:
2275 * <ul>
2276 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2277 * whose resources are no longer available.
2278 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2279 * whose resources are no longer available.
2280 * </ul>
2281 *
2282 * <p class="note">This is a protected intent that can only be sent
2283 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002284 */
2285 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002286 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002287 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002288
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002289 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002290 * Broadcast Action: preferred activities have changed *explicitly*.
2291 *
2292 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2293 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2294 * be sent.
2295 *
2296 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2297 *
2298 * @hide
2299 */
2300 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2301 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2302 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2303
2304
2305 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002306 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002307 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002308 * This should <em>only</em> be used to determine when the wallpaper
2309 * has changed to show the new wallpaper to the user. You should certainly
2310 * never, in response to this, change the wallpaper or other attributes of
2311 * it such as the suggested size. That would be crazy, right? You'd cause
2312 * all kinds of loops, especially if other apps are doing similar things,
2313 * right? Of course. So please don't do this.
2314 *
2315 * @deprecated Modern applications should use
2316 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2317 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2318 * shown behind their UI, rather than watching for this broadcast and
2319 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002320 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002321 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002322 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2323 /**
2324 * Broadcast Action: The current device {@link android.content.res.Configuration}
2325 * (orientation, locale, etc) has changed. When such a change happens, the
2326 * UIs (view hierarchy) will need to be rebuilt based on this new
2327 * information; for the most part, applications don't need to worry about
2328 * this, because the system will take care of stopping and restarting the
2329 * application to make sure it sees the new changes. Some system code that
2330 * can not be restarted will need to watch for this action and handle it
2331 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002332 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002333 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002334 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002335 * in manifests, only by explicitly registering for it with
2336 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2337 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002338 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002339 * <p class="note">This is a protected intent that can only be sent
2340 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002341 *
2342 * @see android.content.res.Configuration
2343 */
2344 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2345 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2346 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002347 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002348 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002349 * <p class="note">This is a protected intent that can only be sent
2350 * by the system.
2351 */
2352 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2353 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2354 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002355 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2356 * charging state, level, and other information about the battery.
2357 * See {@link android.os.BatteryManager} for documentation on the
2358 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002359 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002360 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002361 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002362 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002363 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002364 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2365 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2366 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2367 * broadcasts that are sent and can be received through manifest
2368 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002369 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002370 * <p class="note">This is a protected intent that can only be sent
2371 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002372 */
2373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2374 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2375 /**
2376 * Broadcast Action: Indicates low battery condition on the device.
2377 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002378 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002379 * <p class="note">This is a protected intent that can only be sent
2380 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002381 */
2382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2383 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2384 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002385 * Broadcast Action: Indicates the battery is now okay after being low.
2386 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2387 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002388 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002389 * <p class="note">This is a protected intent that can only be sent
2390 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002391 */
2392 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2393 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2394 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002395 * Broadcast Action: External power has been connected to the device.
2396 * This is intended for applications that wish to register specifically to this notification.
2397 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2398 * stay active to receive this notification. This action can be used to implement actions
2399 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002400 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002401 * <p class="note">This is a protected intent that can only be sent
2402 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002403 */
2404 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002405 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002406 /**
2407 * Broadcast Action: External power has been removed from the device.
2408 * This is intended for applications that wish to register specifically to this notification.
2409 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2410 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002411 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002412 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002413 * <p class="note">This is a protected intent that can only be sent
2414 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002415 */
2416 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002417 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002418 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002419 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002420 * Broadcast Action: Device is shutting down.
2421 * This is broadcast when the device is being shut down (completely turned
2422 * off, not sleeping). Once the broadcast is complete, the final shutdown
2423 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002424 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002425 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002426 * <p class="note">This is a protected intent that can only be sent
2427 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002428 * <p>May include the following extras:
2429 * <ul>
2430 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2431 * shutdown is only for userspace processes. If not set, assumed to be false.
2432 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002433 */
2434 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002435 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002436 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002437 * Activity Action: Start this activity to request system shutdown.
2438 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002439 * to request confirmation from the user before shutting down. The optional boolean
2440 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2441 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002442 *
2443 * <p class="note">This is a protected intent that can only be sent
2444 * by the system.
2445 *
2446 * {@hide}
2447 */
2448 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2449 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002450 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002451 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002452 * <p class="note">
2453 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002454 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002455 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2456 * or above, this broadcast will no longer be delivered to any
2457 * {@link BroadcastReceiver} defined in your manifest. Instead,
2458 * apps are strongly encouraged to use the improved
2459 * {@link Context#getCacheDir()} behavior so the system can
2460 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002461 */
2462 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002463 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002464 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2465 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002466 * Broadcast Action: Indicates low storage space condition on the device no
2467 * longer exists
2468 * <p class="note">
2469 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002470 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002471 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2472 * or above, this broadcast will no longer be delivered to any
2473 * {@link BroadcastReceiver} defined in your manifest. Instead,
2474 * apps are strongly encouraged to use the improved
2475 * {@link Context#getCacheDir()} behavior so the system can
2476 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002477 */
2478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002479 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002480 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2481 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002482 * Broadcast Action: A sticky broadcast that indicates a storage space full
2483 * condition on the device. This is intended for activities that want to be
2484 * able to fill the data partition completely, leaving only enough free
2485 * space to prevent system-wide SQLite failures.
2486 * <p class="note">
2487 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002488 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002489 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2490 * or above, this broadcast will no longer be delivered to any
2491 * {@link BroadcastReceiver} defined in your manifest. Instead,
2492 * apps are strongly encouraged to use the improved
2493 * {@link Context#getCacheDir()} behavior so the system can
2494 * automatically free up storage when needed.
2495 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002498 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002499 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2500 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002501 * Broadcast Action: Indicates storage space full condition on the device no
2502 * longer exists.
2503 * <p class="note">
2504 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002505 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002506 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2507 * or above, this broadcast will no longer be delivered to any
2508 * {@link BroadcastReceiver} defined in your manifest. Instead,
2509 * apps are strongly encouraged to use the improved
2510 * {@link Context#getCacheDir()} behavior so the system can
2511 * automatically free up storage when needed.
2512 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002513 */
2514 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002515 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002516 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2517 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002518 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2519 * and package management should be started.
2520 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2521 * notification.
2522 */
2523 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2524 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2525 /**
2526 * Broadcast Action: The device has entered USB Mass Storage mode.
2527 * This is used mainly for the USB Settings panel.
2528 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2529 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002530 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002531 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002532 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002533 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2534
2535 /**
2536 * Broadcast Action: The device has exited USB Mass Storage mode.
2537 * This is used mainly for the USB Settings panel.
2538 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2539 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002540 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002541 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002542 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002543 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2544
2545 /**
2546 * Broadcast Action: External media has been removed.
2547 * The path to the mount point for the removed media is contained in the Intent.mData field.
2548 */
2549 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2550 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2551
2552 /**
2553 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002554 * 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 -07002555 */
2556 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2557 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2558
2559 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002560 * Broadcast Action: External media is present, and being disk-checked
2561 * 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 -08002562 */
2563 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2564 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2565
2566 /**
2567 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2568 * 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 -08002569 */
2570 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2571 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2572
2573 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002574 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002575 * 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 -07002576 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2577 * media was mounted read only.
2578 */
2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2580 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2581
2582 /**
2583 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002584 * 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 -07002585 */
2586 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2587 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2588
2589 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002590 * Broadcast Action: External media is no longer being shared via USB mass storage.
2591 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2592 *
2593 * @hide
2594 */
2595 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2596
2597 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002598 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2599 * The path to the mount point for the removed media is contained in the Intent.mData field.
2600 */
2601 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2602 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2603
2604 /**
2605 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002606 * 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 -07002607 */
2608 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2609 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2610
2611 /**
2612 * Broadcast Action: User has expressed the desire to remove the external storage media.
2613 * Applications should close all files they have open within the mount point when they receive this intent.
2614 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2615 */
2616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2617 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2618
2619 /**
2620 * Broadcast Action: The media scanner has started scanning a directory.
2621 * The path to the directory being scanned is contained in the Intent.mData field.
2622 */
2623 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2624 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2625
2626 /**
2627 * Broadcast Action: The media scanner has finished scanning a directory.
2628 * The path to the scanned directory is contained in the Intent.mData field.
2629 */
2630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2631 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2632
2633 /**
2634 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2635 * The path to the file is contained in the Intent.mData field.
2636 */
2637 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2638 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2639
2640 /**
2641 * Broadcast Action: The "Media Button" was pressed. Includes a single
2642 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2643 * caused the broadcast.
2644 */
2645 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2646 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2647
2648 /**
2649 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2650 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2651 * caused the broadcast.
2652 */
2653 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2654 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2655
2656 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2657 // location; they are not general-purpose actions.
2658
2659 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002660 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002661 */
2662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2663 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2664 "android.intent.action.GTALK_CONNECTED";
2665
2666 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002667 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002668 */
2669 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2670 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2671 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002672
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002673 /**
2674 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002675 */
2676 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2677 public static final String ACTION_INPUT_METHOD_CHANGED =
2678 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002679
2680 /**
2681 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2682 * more radios have been turned off or on. The intent will have the following extra value:</p>
2683 * <ul>
2684 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2685 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2686 * turned off</li>
2687 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002688 *
Peng Xua35b5532016-01-20 00:05:45 -08002689 * <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 -07002690 */
2691 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2692 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2693
2694 /**
2695 * Broadcast Action: Some content providers have parts of their namespace
2696 * where they publish new events or items that the user may be especially
2697 * interested in. For these things, they may broadcast this action when the
2698 * set of interesting items change.
2699 *
2700 * For example, GmailProvider sends this notification when the set of unread
2701 * mail in the inbox changes.
2702 *
2703 * <p>The data of the intent identifies which part of which provider
2704 * changed. When queried through the content resolver, the data URI will
2705 * return the data set in question.
2706 *
2707 * <p>The intent will have the following extra values:
2708 * <ul>
2709 * <li><em>count</em> - The number of items in the data set. This is the
2710 * same as the number of items in the cursor returned by querying the
2711 * data URI. </li>
2712 * </ul>
2713 *
2714 * This intent will be sent at boot (if the count is non-zero) and when the
2715 * data set changes. It is possible for the data set to change without the
2716 * count changing (for example, if a new unread message arrives in the same
2717 * sync operation in which a message is archived). The phone should still
2718 * ring/vibrate/etc as normal in this case.
2719 */
2720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2721 public static final String ACTION_PROVIDER_CHANGED =
2722 "android.intent.action.PROVIDER_CHANGED";
2723
2724 /**
2725 * Broadcast Action: Wired Headset plugged in or unplugged.
2726 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002727 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2728 * and documentation.
2729 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002730 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002731 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002732 */
2733 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002734 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002735
2736 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002737 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2738 * <ul>
2739 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2740 * </ul>
2741 *
2742 * <p class="note">This is a protected intent that can only be sent
2743 * by the system.
2744 *
2745 * @hide
2746 */
2747 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2748 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2749 = "android.intent.action.ADVANCED_SETTINGS";
2750
2751 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002752 * Broadcast Action: Sent after application restrictions are changed.
2753 *
2754 * <p class="note">This is a protected intent that can only be sent
2755 * by the system.</p>
2756 */
2757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2758 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2759 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2760
2761 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002762 * Broadcast Action: An outgoing call is about to be placed.
2763 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002764 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002765 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002766 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767 * the phone number originally intended to be dialed.</li>
2768 * </ul>
2769 * <p>Once the broadcast is finished, the resultData is used as the actual
2770 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002771 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002772 * outgoing call in turn: for example, a parental control application
2773 * might verify that the user is authorized to place the call at that
2774 * time, then a number-rewriting application might add an area code if
2775 * one was not specified.</p>
2776 * <p>For consistency, any receiver whose purpose is to prohibit phone
2777 * calls should have a priority of 0, to ensure it will see the final
2778 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002779 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002780 * should have a positive priority.
2781 * Negative priorities are reserved for the system for this broadcast;
2782 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002783 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2784 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002785 * <p>Emergency calls cannot be intercepted using this mechanism, and
2786 * other calls cannot be modified to call emergency numbers using this
2787 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002788 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2789 * call to use their own service instead. Those apps should first prevent
2790 * the call from being placed by setting resultData to <code>null</code>
2791 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002792 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002793 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2794 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002795 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002796 * <p class="note">This is a protected intent that can only be sent
2797 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002798 */
2799 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2800 public static final String ACTION_NEW_OUTGOING_CALL =
2801 "android.intent.action.NEW_OUTGOING_CALL";
2802
2803 /**
2804 * Broadcast Action: Have the device reboot. This is only for use by
2805 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002806 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002807 * <p class="note">This is a protected intent that can only be sent
2808 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002809 */
2810 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2811 public static final String ACTION_REBOOT =
2812 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002813
Wei Huang97ecc9c2009-05-11 17:44:20 -07002814 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002815 * Broadcast Action: A sticky broadcast for changes in the physical
2816 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002817 *
2818 * <p>The intent will have the following extra values:
2819 * <ul>
2820 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002821 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002822 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002823 * <p>This is intended for monitoring the current physical dock state.
2824 * See {@link android.app.UiModeManager} for the normal API dealing with
2825 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002826 */
2827 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2828 public static final String ACTION_DOCK_EVENT =
2829 "android.intent.action.DOCK_EVENT";
2830
2831 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002832 * Broadcast Action: A broadcast when idle maintenance can be started.
2833 * This means that the user is not interacting with the device and is
2834 * not expected to do so soon. Typical use of the idle maintenance is
2835 * to perform somehow expensive tasks that can be postponed at a moment
2836 * when they will not degrade user experience.
2837 * <p>
2838 * <p class="note">In order to keep the device responsive in case of an
2839 * unexpected user interaction, implementations of a maintenance task
2840 * should be interruptible. In such a scenario a broadcast with action
2841 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2842 * should not do the maintenance work in
2843 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2844 * maintenance service by {@link Context#startService(Intent)}. Also
2845 * you should hold a wake lock while your maintenance service is running
2846 * to prevent the device going to sleep.
2847 * </p>
2848 * <p>
2849 * <p class="note">This is a protected intent that can only be sent by
2850 * the system.
2851 * </p>
2852 *
2853 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002854 *
2855 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002856 */
2857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2858 public static final String ACTION_IDLE_MAINTENANCE_START =
2859 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2860
2861 /**
2862 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2863 * This means that the user was not interacting with the device as a result
2864 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2865 * was sent and now the user started interacting with the device. Typical
2866 * use of the idle maintenance is to perform somehow expensive tasks that
2867 * can be postponed at a moment when they will not degrade user experience.
2868 * <p>
2869 * <p class="note">In order to keep the device responsive in case of an
2870 * unexpected user interaction, implementations of a maintenance task
2871 * should be interruptible. Hence, on receiving a broadcast with this
2872 * action, the maintenance task should be interrupted as soon as possible.
2873 * In other words, you should not do the maintenance work in
2874 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2875 * maintenance service that was started on receiving of
2876 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2877 * lock you acquired when your maintenance service started.
2878 * </p>
2879 * <p class="note">This is a protected intent that can only be sent
2880 * by the system.
2881 *
2882 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002883 *
2884 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002885 */
2886 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2887 public static final String ACTION_IDLE_MAINTENANCE_END =
2888 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2889
2890 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002891 * Broadcast Action: a remote intent is to be broadcasted.
2892 *
2893 * A remote intent is used for remote RPC between devices. The remote intent
2894 * is serialized and sent from one device to another device. The receiving
2895 * device parses the remote intent and broadcasts it. Note that anyone can
2896 * broadcast a remote intent. However, if the intent receiver of the remote intent
2897 * does not trust intent broadcasts from arbitrary intent senders, it should require
2898 * the sender to hold certain permissions so only trusted sender's broadcast will be
2899 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002900 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002901 */
2902 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002903 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002904
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002905 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002906 * Broadcast Action: This is broadcast once when the user is booting after a
2907 * system update. It can be used to perform cleanup or upgrades after a
2908 * system update.
2909 * <p>
2910 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2911 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2912 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2913 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002914 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002915 * @hide
2916 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002917 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002918 public static final String ACTION_PRE_BOOT_COMPLETED =
2919 "android.intent.action.PRE_BOOT_COMPLETED";
2920
Amith Yamasani13593602012-03-22 16:16:17 -07002921 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002922 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002923 * on restricted users. The broadcast intent contains an extra
2924 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2925 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2926 * String[] depending on the restriction type.<p/>
2927 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002928 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2929 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2930 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002931 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2932 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002933 * @see RestrictionEntry
2934 */
2935 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2936 "android.intent.action.GET_RESTRICTION_ENTRIES";
2937
2938 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002939 * Sent the first time a user is starting, to allow system apps to
2940 * perform one time initialization. (This will not be seen by third
2941 * party applications because a newly initialized user does not have any
2942 * third party applications installed for it.) This is sent early in
2943 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002944 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2945 * broadcast, since it is part of a visible user interaction; be as quick
2946 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002947 */
2948 public static final String ACTION_USER_INITIALIZE =
2949 "android.intent.action.USER_INITIALIZE";
2950
2951 /**
2952 * Sent when a user switch is happening, causing the process's user to be
2953 * brought to the foreground. This is only sent to receivers registered
2954 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2955 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002956 * foreground. This is sent as a foreground
2957 * broadcast, since it is part of a visible user interaction; be as quick
2958 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002959 */
2960 public static final String ACTION_USER_FOREGROUND =
2961 "android.intent.action.USER_FOREGROUND";
2962
2963 /**
2964 * Sent when a user switch is happening, causing the process's user to be
2965 * sent to the background. This is only sent to receivers registered
2966 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2967 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002968 * background. This is sent as a foreground
2969 * broadcast, since it is part of a visible user interaction; be as quick
2970 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002971 */
2972 public static final String ACTION_USER_BACKGROUND =
2973 "android.intent.action.USER_BACKGROUND";
2974
2975 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002976 * Broadcast sent to the system when a user is added. Carries an extra
2977 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2978 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002979 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002980 * @hide
2981 */
2982 public static final String ACTION_USER_ADDED =
2983 "android.intent.action.USER_ADDED";
2984
2985 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002986 * Broadcast sent by the system when a user is started. Carries an extra
2987 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002988 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002989 * that has been started. This is sent as a foreground
2990 * broadcast, since it is part of a visible user interaction; be as quick
2991 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002992 * @hide
2993 */
2994 public static final String ACTION_USER_STARTED =
2995 "android.intent.action.USER_STARTED";
2996
2997 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002998 * Broadcast sent when a user is in the process of starting. Carries an extra
2999 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3000 * sent to registered receivers, not manifest receivers. It is sent to all
3001 * users (including the one that is being started). You must hold
3002 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3003 * this broadcast. This is sent as a background broadcast, since
3004 * its result is not part of the primary UX flow; to safely keep track of
3005 * started/stopped state of a user you can use this in conjunction with
3006 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3007 * other user state broadcasts since those are foreground broadcasts so can
3008 * execute in a different order.
3009 * @hide
3010 */
3011 public static final String ACTION_USER_STARTING =
3012 "android.intent.action.USER_STARTING";
3013
3014 /**
3015 * Broadcast sent when a user is going to be stopped. Carries an extra
3016 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3017 * sent to registered receivers, not manifest receivers. It is sent to all
3018 * users (including the one that is being stopped). You must hold
3019 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3020 * this broadcast. The user will not stop until all receivers have
3021 * handled the broadcast. This is sent as a background broadcast, since
3022 * its result is not part of the primary UX flow; to safely keep track of
3023 * started/stopped state of a user you can use this in conjunction with
3024 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3025 * other user state broadcasts since those are foreground broadcasts so can
3026 * execute in a different order.
3027 * @hide
3028 */
3029 public static final String ACTION_USER_STOPPING =
3030 "android.intent.action.USER_STOPPING";
3031
3032 /**
3033 * Broadcast sent to the system when a user is stopped. Carries an extra
3034 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3035 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3036 * specific package. This is only sent to registered receivers, not manifest
3037 * receivers. It is sent to all running users <em>except</em> the one that
3038 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003039 * @hide
3040 */
3041 public static final String ACTION_USER_STOPPED =
3042 "android.intent.action.USER_STOPPED";
3043
3044 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003045 * 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 -07003046 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003047 * one that has been removed. The user will not be completely removed until all receivers have
3048 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003049 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003050 * @hide
3051 */
3052 public static final String ACTION_USER_REMOVED =
3053 "android.intent.action.USER_REMOVED";
3054
3055 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003056 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003057 * the userHandle of the user to become the current one. This is only sent to
3058 * registered receivers, not manifest receivers. It is sent to all running users.
3059 * You must hold
3060 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003061 * @hide
3062 */
3063 public static final String ACTION_USER_SWITCHED =
3064 "android.intent.action.USER_SWITCHED";
3065
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003066 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003067 * Broadcast Action: Sent when the credential-encrypted private storage has
3068 * become unlocked for the target user. This is only sent to registered
3069 * receivers, not manifest receivers.
3070 */
3071 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3072 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3073
3074 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003075 * Broadcast sent to the system when a user's information changes. Carries an extra
3076 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003077 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003078 * @hide
3079 */
3080 public static final String ACTION_USER_INFO_CHANGED =
3081 "android.intent.action.USER_INFO_CHANGED";
3082
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003083 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003084 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3085 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003086 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3087 * that need to display merged content across both primary and managed profiles need to
3088 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003089 * not manifest receivers.
3090 */
3091 public static final String ACTION_MANAGED_PROFILE_ADDED =
3092 "android.intent.action.MANAGED_PROFILE_ADDED";
3093
3094 /**
3095 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003096 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3097 * Only applications (for example Launchers) that need to display merged content across both
3098 * primary and managed profiles need to worry about this broadcast. This is only sent to
3099 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003100 */
3101 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3102 "android.intent.action.MANAGED_PROFILE_REMOVED";
3103
3104 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003105 * Broadcast sent to the primary user when the credential-encrypted private storage for
3106 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3107 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3108 * Launchers) that need to display merged content across both primary and managed profiles
3109 * need to worry about this broadcast. This is only sent to registered receivers,
3110 * not manifest receivers.
3111 */
3112 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3113 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3114
3115 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003116 * Broadcast sent to the primary user when an associated managed profile has become available.
3117 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003118 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3119 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3120 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003121 */
Rubin Xue95057a2016-04-01 16:49:25 +01003122 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3123 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3124
3125 /**
3126 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3127 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3128 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3129 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3130 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3131 */
3132 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3133 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003134
3135 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003136 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3137 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3138 * the device was locked or unlocked.
3139 *
3140 * This is only sent to registered receivers.
3141 *
3142 * @hide
3143 */
3144 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3145 "android.intent.action.DEVICE_LOCKED_CHANGED";
3146
3147 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003148 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3149 */
3150 public static final String ACTION_QUICK_CLOCK =
3151 "android.intent.action.QUICK_CLOCK";
3152
Michael Wright0087a142013-02-05 16:29:39 -08003153 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003154 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003155 * @hide
3156 */
3157 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003158 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003159
Justin Kohd378ad72013-04-01 12:18:26 -07003160 /**
3161 * Broadcast Action: A global button was pressed. Includes a single
3162 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3163 * caused the broadcast.
3164 * @hide
3165 */
3166 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3167
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003168 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003169 * Broadcast Action: Sent when media resource is granted.
3170 * <p>
3171 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3172 * granted.
3173 * </p>
3174 * <p class="note">
3175 * This is a protected intent that can only be sent by the system.
3176 * </p>
3177 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003178 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003179 * </p>
3180 *
3181 * @hide
3182 */
3183 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3184 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3185
3186 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003187 * Broadcast Action: An overlay package has been installed. The data
3188 * contains the name of the added overlay package.
3189 * @hide
3190 */
3191 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3192
3193 /**
3194 * Broadcast Action: An overlay package has changed. The data contains the
3195 * name of the overlay package which has changed. This is broadcast on all
3196 * changes to the OverlayInfo returned by {@link
3197 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3198 * most common change is a state change that will change whether the
3199 * overlay is enabled or not.
3200 * @hide
3201 */
3202 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3203
3204 /**
3205 * Broadcast Action: An overlay package has been removed. The data contains
3206 * the name of the overlay package which has been removed.
3207 * @hide
3208 */
3209 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3210
3211 /**
3212 * Broadcast Action: The order of a package's list of overlay packages has
3213 * changed. The data contains the package name of the overlay package that
3214 * had its position in the list adjusted.
3215 * @hide
3216 */
3217 public static final String
3218 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3219
3220 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003221 * Activity Action: Allow the user to select and return one or more existing
3222 * documents. When invoked, the system will display the various
3223 * {@link DocumentsProvider} instances installed on the device, letting the
3224 * user interactively navigate through them. These documents include local
3225 * media, such as photos and video, and documents provided by installed
3226 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003227 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003228 * Each document is represented as a {@code content://} URI backed by a
3229 * {@link DocumentsProvider}, which can be opened as a stream with
3230 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3231 * {@link android.provider.DocumentsContract.Document} metadata.
3232 * <p>
3233 * All selected documents are returned to the calling application with
3234 * persistable read and write permission grants. If you want to maintain
3235 * access to the documents across device reboots, you need to explicitly
3236 * take the persistable permissions using
3237 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3238 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003239 * Callers must indicate the acceptable document MIME types through
3240 * {@link #setType(String)}. For example, to select photos, use
3241 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3242 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3243 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003244 * <p>
3245 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003246 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3247 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003248 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003249 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3250 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003251 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003252 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003253 * Callers can set a document URI through
3254 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3255 * location of documents navigator. System will do its best to launch the
3256 * navigator in the specified document if it's a folder, or the folder that
3257 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003258 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003259 * Output: The URI of the item that was picked, returned in
3260 * {@link #getData()}. This must be a {@code content://} URI so that any
3261 * receiver can access it. If multiple documents were selected, they are
3262 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003263 *
3264 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003265 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003266 * @see #ACTION_CREATE_DOCUMENT
3267 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003268 */
3269 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3270 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3271
3272 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003273 * Activity Action: Allow the user to create a new document. When invoked,
3274 * the system will display the various {@link DocumentsProvider} instances
3275 * installed on the device, letting the user navigate through them. The
3276 * returned document may be a newly created document with no content, or it
3277 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003278 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003279 * Each document is represented as a {@code content://} URI backed by a
3280 * {@link DocumentsProvider}, which can be opened as a stream with
3281 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3282 * {@link android.provider.DocumentsContract.Document} metadata.
3283 * <p>
3284 * Callers must indicate the concrete MIME type of the document being
3285 * created by setting {@link #setType(String)}. This MIME type cannot be
3286 * changed after the document is created.
3287 * <p>
3288 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3289 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003290 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003291 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3292 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003293 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003294 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003295 * Callers can set a document URI through
3296 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3297 * location of documents navigator. System will do its best to launch the
3298 * navigator in the specified document if it's a folder, or the folder that
3299 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003300 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003301 * Output: The URI of the item that was created. This must be a
3302 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003303 *
3304 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003305 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003306 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003307 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003308 */
3309 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3310 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3311
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003312 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003313 * Activity Action: Allow the user to pick a directory subtree. When
3314 * invoked, the system will display the various {@link DocumentsProvider}
3315 * instances installed on the device, letting the user navigate through
3316 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003317 * <p>
3318 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003319 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3320 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3321 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003322 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003323 * Callers can set a document URI through
3324 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3325 * location of documents navigator. System will do its best to launch the
3326 * navigator in the specified document if it's a folder, or the folder that
3327 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003328 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003329 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003330 *
3331 * @see DocumentsContract
3332 */
3333 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003334 public static final String
3335 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003336
Felipe Lemec7b1f892016-01-15 15:02:31 -08003337 /**
Peng Xua35b5532016-01-20 00:05:45 -08003338 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3339 * exisiting sensor being disconnected.
3340 *
3341 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3342 *
3343 * {@hide}
3344 */
3345 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3346 public static final String
3347 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3348
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003349 /**
3350 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3351 *
3352 * {@hide}
3353 */
3354 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003355 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3356
Christopher Tate6597e342015-02-17 12:15:25 -08003357 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003358 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3359 * is about to be performed.
3360 * @hide
3361 */
3362 @SystemApi
3363 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3364 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3365 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3366
3367 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003368 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3369 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3370 *
3371 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3372 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003373 * @hide
3374 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003375 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003376 public static final String EXTRA_FORCE_MASTER_CLEAR =
3377 "android.intent.extra.FORCE_MASTER_CLEAR";
3378
3379 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003380 * A broadcast action to trigger a factory reset.
3381 *
3382 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3383 *
3384 * <p>Not for use by third-party applications.
3385 *
3386 * @see #EXTRA_FORCE_MASTER_CLEAR
3387 *
3388 * {@hide}
3389 */
3390 @SystemApi
3391 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3392 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3393
3394 /**
3395 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3396 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3397 *
3398 * <p>Not for use by third-party applications.
3399 *
3400 * @hide
3401 */
3402 @SystemApi
3403 public static final String EXTRA_FORCE_FACTORY_RESET =
3404 "android.intent.extra.FORCE_FACTORY_RESET";
3405
3406 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003407 * Broadcast action: report that a settings element is being restored from backup. The intent
3408 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3409 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3410 * is the value of that settings entry prior to the restore operation. All of these values are
3411 * represented as strings.
3412 *
3413 * <p>This broadcast is sent only for settings provider entries known to require special handling
3414 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3415 * the provider's backup agent implementation.
3416 *
3417 * @see #EXTRA_SETTING_NAME
3418 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3419 * @see #EXTRA_SETTING_NEW_VALUE
3420 * {@hide}
3421 */
3422 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3423
3424 /** {@hide} */
3425 public static final String EXTRA_SETTING_NAME = "setting_name";
3426 /** {@hide} */
3427 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3428 /** {@hide} */
3429 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3430
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003431 /**
3432 * Activity Action: Process a piece of text.
3433 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3434 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3435 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3436 */
3437 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3438 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003439
3440 /**
3441 * Broadcast Action: The sim card state has changed.
3442 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3443 * because TelephonyIntents is an internal class.
3444 * @hide
3445 */
3446 @SystemApi
3447 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3448 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3449
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003450 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003451 * The name of the extra used to define the text to be processed, as a
3452 * CharSequence. Note that this may be a styled CharSequence, so you must use
3453 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003454 */
3455 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3456 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003457 * 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 +00003458 */
3459 public static final String EXTRA_PROCESS_TEXT_READONLY =
3460 "android.intent.extra.PROCESS_TEXT_READONLY";
3461
Bryce Leebc58f592015-09-25 16:43:01 -07003462 /**
3463 * Broadcast action: reports when a new thermal event has been reached. When the device
3464 * is reaching its maximum temperatue, the thermal level reported
3465 * {@hide}
3466 */
3467 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3468 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3469
3470 /** {@hide} */
3471 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3472
3473 /**
3474 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003475 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003476 * {@hide}
3477 */
3478 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3479
3480 /**
3481 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003482 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003483 * {@hide}
3484 */
3485 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3486
3487 /**
3488 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003489 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003490 * {@hide}
3491 */
3492 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3493
3494
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003495 // ---------------------------------------------------------------------
3496 // ---------------------------------------------------------------------
3497 // Standard intent categories (see addCategory()).
3498
3499 /**
3500 * Set if the activity should be an option for the default action
3501 * (center press) to perform on a piece of data. Setting this will
3502 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003503 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003504 * Intent when initiating an action -- it is for use in intent filters
3505 * specified in packages.
3506 */
3507 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3508 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3509 /**
3510 * Activities that can be safely invoked from a browser must support this
3511 * category. For example, if the user is viewing a web page or an e-mail
3512 * and clicks on a link in the text, the Intent generated execute that
3513 * link will require the BROWSABLE category, so that only activities
3514 * supporting this category will be considered as possible actions. By
3515 * supporting this category, you are promising that there is nothing
3516 * damaging (without user intervention) that can happen by invoking any
3517 * matching Intent.
3518 */
3519 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3520 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3521 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003522 * Categories for activities that can participate in voice interaction.
3523 * An activity that supports this category must be prepared to run with
3524 * no UI shown at all (though in some case it may have a UI shown), and
3525 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3526 */
3527 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3528 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3529 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003530 * Set if the activity should be considered as an alternative action to
3531 * the data the user is currently viewing. See also
3532 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3533 * applies to the selection in a list of items.
3534 *
3535 * <p>Supporting this category means that you would like your activity to be
3536 * displayed in the set of alternative things the user can do, usually as
3537 * part of the current activity's options menu. You will usually want to
3538 * include a specific label in the &lt;intent-filter&gt; of this action
3539 * describing to the user what it does.
3540 *
3541 * <p>The action of IntentFilter with this category is important in that it
3542 * describes the specific action the target will perform. This generally
3543 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3544 * a specific name such as "com.android.camera.action.CROP. Only one
3545 * alternative of any particular action will be shown to the user, so using
3546 * a specific action like this makes sure that your alternative will be
3547 * displayed while also allowing other applications to provide their own
3548 * overrides of that particular action.
3549 */
3550 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3551 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3552 /**
3553 * Set if the activity should be considered as an alternative selection
3554 * action to the data the user has currently selected. This is like
3555 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3556 * of items from which the user can select, giving them alternatives to the
3557 * default action that will be performed on it.
3558 */
3559 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3560 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3561 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003562 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003563 */
3564 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3565 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3566 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003567 * Should be displayed in the top-level launcher.
3568 */
3569 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3570 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3571 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003572 * Indicates an activity optimized for Leanback mode, and that should
3573 * be displayed in the Leanback launcher.
3574 */
3575 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3576 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3577 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003578 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3579 * @hide
3580 */
3581 @SystemApi
3582 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3583 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003584 * Provides information about the package it is in; typically used if
3585 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3586 * a front-door to the user without having to be shown in the all apps list.
3587 */
3588 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3589 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3590 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003591 * This is the home activity, that is the first activity that is displayed
3592 * when the device boots.
3593 */
3594 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3595 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3596 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003597 * This is the home activity that is displayed when the device is finished setting up and ready
3598 * for use.
3599 * @hide
3600 */
3601 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3602 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3603 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003604 * This is the setup wizard activity, that is the first activity that is displayed
3605 * when the user sets up the device for the first time.
3606 * @hide
3607 */
3608 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3609 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3610 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003611 * This activity is a preference panel.
3612 */
3613 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3614 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3615 /**
3616 * This activity is a development preference panel.
3617 */
3618 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3619 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3620 /**
3621 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003622 */
3623 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3624 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3625 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003626 * This activity allows the user to browse and download new applications.
3627 */
3628 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3629 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3630 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003631 * This activity may be exercised by the monkey or other automated test tools.
3632 */
3633 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3634 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3635 /**
3636 * To be used as a test (not part of the normal user experience).
3637 */
3638 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3639 /**
3640 * To be used as a unit test (run through the Test Harness).
3641 */
3642 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3643 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003644 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003645 * experience).
3646 */
3647 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003648
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003649 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003650 * Used to indicate that an intent only wants URIs that can be opened with
3651 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3652 * must support at least the columns defined in {@link OpenableColumns} when
3653 * queried.
3654 *
3655 * @see #ACTION_GET_CONTENT
3656 * @see #ACTION_OPEN_DOCUMENT
3657 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003658 */
3659 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3660 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3661
3662 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003663 * Used to indicate that an intent filter can accept files which are not necessarily
3664 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3665 * at least streamable via
3666 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3667 * using one of the stream types exposed via
3668 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3669 *
3670 * @see #ACTION_SEND
3671 * @see #ACTION_SEND_MULTIPLE
3672 */
3673 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3674 public static final String CATEGORY_TYPED_OPENABLE =
3675 "android.intent.category.TYPED_OPENABLE";
3676
3677 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003678 * To be used as code under test for framework instrumentation tests.
3679 */
3680 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3681 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003682 /**
3683 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003684 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3685 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003686 */
3687 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3688 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3689 /**
3690 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003691 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3692 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003693 */
3694 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3695 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003696 /**
3697 * An activity to run when device is inserted into a analog (low end) dock.
3698 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3699 * information, see {@link android.app.UiModeManager}.
3700 */
3701 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3702 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3703
3704 /**
3705 * An activity to run when device is inserted into a digital (high end) dock.
3706 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3707 * information, see {@link android.app.UiModeManager}.
3708 */
3709 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3710 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003711
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003712 /**
3713 * Used to indicate that the activity can be used in a car environment.
3714 */
3715 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3716 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3717
Zak Cohendb6ca492017-01-26 14:09:00 -08003718 /**
3719 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3720 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3721 * information, see {@link android.app.UiModeManager}.
3722 */
3723 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3724 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003725 // ---------------------------------------------------------------------
3726 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003727 // Application launch intent categories (see addCategory()).
3728
3729 /**
3730 * Used with {@link #ACTION_MAIN} to launch the browser application.
3731 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003732 * <p>NOTE: This should not be used as the primary key of an Intent,
3733 * since it will not result in the app launching with the correct
3734 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003735 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003736 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003737 */
3738 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3739 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3740
3741 /**
3742 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3743 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003744 * <p>NOTE: This should not be used as the primary key of an Intent,
3745 * since it will not result in the app launching with the correct
3746 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003747 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003748 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003749 */
3750 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3751 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3752
3753 /**
3754 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3755 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003756 * <p>NOTE: This should not be used as the primary key of an Intent,
3757 * since it will not result in the app launching with the correct
3758 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003759 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003760 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003761 */
3762 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3763 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3764
3765 /**
3766 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3767 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003768 * <p>NOTE: This should not be used as the primary key of an Intent,
3769 * since it will not result in the app launching with the correct
3770 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003771 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003772 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003773 */
3774 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3775 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3776
3777 /**
3778 * Used with {@link #ACTION_MAIN} to launch the email application.
3779 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003780 * <p>NOTE: This should not be used as the primary key of an Intent,
3781 * since it will not result in the app launching with the correct
3782 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003783 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003784 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003785 */
3786 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3787 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3788
3789 /**
3790 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3791 * The activity should be able to view and manipulate image and video files
3792 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003793 * <p>NOTE: This should not be used as the primary key of an Intent,
3794 * since it will not result in the app launching with the correct
3795 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003796 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003797 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003798 */
3799 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3800 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3801
3802 /**
3803 * Used with {@link #ACTION_MAIN} to launch the maps application.
3804 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003805 * <p>NOTE: This should not be used as the primary key of an Intent,
3806 * since it will not result in the app launching with the correct
3807 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003808 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003809 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003810 */
3811 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3812 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3813
3814 /**
3815 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3816 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003817 * <p>NOTE: This should not be used as the primary key of an Intent,
3818 * since it will not result in the app launching with the correct
3819 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003820 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003821 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003822 */
3823 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3824 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3825
3826 /**
3827 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003828 * The activity should be able to play, browse, or manipulate music files
3829 * stored on the device.
3830 * <p>NOTE: This should not be used as the primary key of an Intent,
3831 * since it will not result in the app launching with the correct
3832 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003833 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003834 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003835 */
3836 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3837 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3838
3839 // ---------------------------------------------------------------------
3840 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003841 // Standard extra data keys.
3842
3843 /**
3844 * The initial data to place in a newly created record. Use with
3845 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3846 * fields as would be given to the underlying ContentProvider.insert()
3847 * call.
3848 */
3849 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3850
3851 /**
3852 * A constant CharSequence that is associated with the Intent, used with
3853 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3854 * this may be a styled CharSequence, so you must use
3855 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3856 * retrieve it.
3857 */
3858 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3859
3860 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003861 * A constant String that is associated with the Intent, used with
3862 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3863 * as HTML formatted text. Note that you <em>must</em> also supply
3864 * {@link #EXTRA_TEXT}.
3865 */
3866 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3867
3868 /**
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003869 * A content: URI holding a stream of data associated with the Intent, used
3870 * with {@link #ACTION_SEND} to supply the data being sent.
3871 * <p>
3872 * Starting in {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this value
3873 * will be automatically promoted to {@link Intent#setClipData(ClipData)}
3874 * when that value is not already defined.
3875 * <p>
3876 * Starting in {@link android.os.Build.VERSION_CODES#O} this value will be
3877 * automatically demoted from {@link Intent#getClipData()} when this value
3878 * is not already defined.
3879 *
3880 * @deprecated apps should use {@link Intent#setClipData(ClipData)} and
3881 * {@link Intent#getClipData()} instead of this extra, since
3882 * only those APIs can extend temporary permission grants to the
3883 * underlying resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003884 */
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06003885 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003886 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3887
3888 /**
3889 * A String[] holding e-mail addresses that should be delivered to.
3890 */
3891 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3892
3893 /**
3894 * A String[] holding e-mail addresses that should be carbon copied.
3895 */
3896 public static final String EXTRA_CC = "android.intent.extra.CC";
3897
3898 /**
3899 * A String[] holding e-mail addresses that should be blind carbon copied.
3900 */
3901 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3902
3903 /**
3904 * A constant string holding the desired subject line of a message.
3905 */
3906 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3907
3908 /**
3909 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003910 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003911 */
3912 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3913
3914 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003915 * An int representing the user id to be used.
3916 *
3917 * @hide
3918 */
3919 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3920
3921 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003922 * An int representing the task id to be retrieved. This is used when a launch from recents is
3923 * intercepted by another action such as credentials confirmation to remember which task should
3924 * be resumed when complete.
3925 *
3926 * @hide
3927 */
3928 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3929
3930 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003931 * An Intent[] describing additional, alternate choices you would like shown with
3932 * {@link #ACTION_CHOOSER}.
3933 *
3934 * <p>An app may be capable of providing several different payload types to complete a
3935 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3936 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3937 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3938 * photo data or a hosted link where the photos can be viewed.</p>
3939 *
3940 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3941 * first/primary/preferred intent in the set. Additional intents specified in
3942 * this extra are ordered; by default intents that appear earlier in the array will be
3943 * preferred over intents that appear later in the array as matches for the same
3944 * target component. To alter this preference, a calling app may also supply
3945 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3946 */
3947 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3948
3949 /**
Adam Powell52c39212016-04-07 15:14:18 -07003950 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3951 * and omitted from a list of components presented to the user.
3952 *
3953 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3954 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3955 * from your own package or other apps from your organization if the idea of sending to those
3956 * targets would be redundant with other app functionality. Filtered components will not
3957 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3958 */
3959 public static final String EXTRA_EXCLUDE_COMPONENTS
3960 = "android.intent.extra.EXCLUDE_COMPONENTS";
3961
3962 /**
3963 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3964 * describing additional high-priority deep-link targets for the chooser to present to the user.
3965 *
3966 * <p>Targets provided in this way will be presented inline with all other targets provided
3967 * by services from other apps. They will be prioritized before other service targets, but
3968 * after those targets provided by sources that the user has manually pinned to the front.</p>
3969 *
3970 * @see #ACTION_CHOOSER
3971 */
3972 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3973
3974 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003975 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3976 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3977 *
3978 * <p>An app preparing an action for another app to complete may wish to allow the user to
3979 * disambiguate between several options for completing the action based on the chosen target
3980 * or otherwise refine the action before it is invoked.
3981 * </p>
3982 *
3983 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3984 * <ul>
3985 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3986 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3987 * chosen target beyond the first</li>
3988 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3989 * should fill in and send once the disambiguation is complete</li>
3990 * </ul>
3991 */
3992 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3993 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3994
3995 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003996 * An {@code ArrayList} of {@code String} annotations describing content for
3997 * {@link #ACTION_CHOOSER}.
3998 *
3999 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4000 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4001 *
4002 * <p>Annotations should describe the major components or topics of the content. It is up to
4003 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4004 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4005 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4006 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4007 * use the following annotations when applicable:</p>
4008 * <ul>
4009 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
4010 * health & beauty, and office supplies.</li>
4011 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4012 * happy, and sad.</li>
4013 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4014 * face, finger, standing, and walking.</li>
4015 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
4016 * child, and baby.</li>
4017 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4018 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4019 * <li>"party": represents that the topic of the content is mainly about parties.</li>
4020 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
4021 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4022 * flowers.</li>
4023 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4024 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4025 * sunglasses, jewelry, handbags and clothing.</li>
4026 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4027 * paper, and silk.</li>
4028 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4029 * cars, and boats.</li>
4030 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
4031 * posters.</li>
4032 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4033 * and designs of houses.</li>
4034 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4035 * Christmas and Thanksgiving.</li>
4036 * </ul>
4037 */
4038 public static final String EXTRA_CONTENT_ANNOTATIONS
4039 = "android.intent.extra.CONTENT_ANNOTATIONS";
4040
4041 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004042 * A {@link ResultReceiver} used to return data back to the sender.
4043 *
4044 * <p>Used to complete an app-specific
4045 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4046 *
4047 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4048 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4049 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4050 * when the user selects a target component from the chooser. It is up to the recipient
4051 * to send a result to this ResultReceiver to signal that disambiguation is complete
4052 * and that the chooser should invoke the user's choice.</p>
4053 *
4054 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4055 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4056 * to match and fill in the final Intent or ChooserTarget before starting it.
4057 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4058 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4059 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4060 *
4061 * <p>The result code passed to the ResultReceiver should be
4062 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4063 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4064 * the chooser should finish without starting a target.</p>
4065 */
4066 public static final String EXTRA_RESULT_RECEIVER
4067 = "android.intent.extra.RESULT_RECEIVER";
4068
4069 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004070 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004071 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004072 */
4073 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4074
4075 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004076 * A Parcelable[] of {@link Intent} or
4077 * {@link android.content.pm.LabeledIntent} objects as set with
4078 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4079 * a the front of the list of choices, when shown to the user with a
4080 * {@link #ACTION_CHOOSER}.
4081 */
4082 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4083
4084 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004085 * A {@link IntentSender} to start after ephemeral installation success.
4086 * @hide
4087 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004088 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4089
4090 /**
4091 * A {@link IntentSender} to start after ephemeral installation failure.
4092 * @hide
4093 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004094 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4095
4096 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004097 * The host name that triggered an ephemeral resolution.
4098 * @hide
4099 */
4100 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4101
4102 /**
4103 * An opaque token to track ephemeral resolution.
4104 * @hide
4105 */
4106 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4107
4108 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004109 * The version code of the app to install components from.
4110 * @hide
4111 */
4112 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4113
4114 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004115 * A Bundle forming a mapping of potential target package names to different extras Bundles
4116 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4117 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4118 * be currently installed on the device.
4119 *
4120 * <p>An application may choose to provide alternate extras for the case where a user
4121 * selects an activity from a predetermined set of target packages. If the activity
4122 * the user selects from the chooser belongs to a package with its package name as
4123 * a key in this bundle, the corresponding extras for that package will be merged with
4124 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4125 * extra has the same key as an extra already present in the intent it will overwrite
4126 * the extra from the intent.</p>
4127 *
4128 * <p><em>Examples:</em>
4129 * <ul>
4130 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4131 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4132 * parameters for that target.</li>
4133 * <li>An application may offer additional metadata for known targets of a given intent
4134 * to pass along information only relevant to that target such as account or content
4135 * identifiers already known to that application.</li>
4136 * </ul></p>
4137 */
4138 public static final String EXTRA_REPLACEMENT_EXTRAS =
4139 "android.intent.extra.REPLACEMENT_EXTRAS";
4140
4141 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004142 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4143 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4144 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4145 * {@link ComponentName} of the chosen component.
4146 *
4147 * <p>In some situations this callback may never come, for example if the user abandons
4148 * the chooser, switches to another task or any number of other reasons. Apps should not
4149 * be written assuming that this callback will always occur.</p>
4150 */
4151 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4152 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4153
4154 /**
4155 * The {@link ComponentName} chosen by the user to complete an action.
4156 *
4157 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4158 */
4159 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4160
4161 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004162 * A {@link android.view.KeyEvent} object containing the event that
4163 * triggered the creation of the Intent it is in.
4164 */
4165 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4166
4167 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004168 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4169 * before shutting down.
4170 *
4171 * {@hide}
4172 */
4173 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4174
4175 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004176 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4177 * requested by the user.
4178 *
4179 * {@hide}
4180 */
4181 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4182 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4183
4184 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004185 * 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 -07004186 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4187 * of restarting the application.
4188 */
4189 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4190
4191 /**
4192 * A String holding the phone number originally entered in
4193 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4194 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4195 */
4196 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004197
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004198 /**
4199 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4200 * intents to supply the uid the package had been assigned. Also an optional
4201 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4202 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4203 * purpose.
4204 */
4205 public static final String EXTRA_UID = "android.intent.extra.UID";
4206
4207 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004208 * @hide String array of package names.
4209 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004210 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004211 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4212
4213 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004214 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4215 * intents to indicate whether this represents a full uninstall (removing
4216 * both the code and its data) or a partial uninstall (leaving its data,
4217 * implying that this is an update).
4218 */
4219 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004220
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004221 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004222 * @hide
4223 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4224 * intents to indicate that at this point the package has been removed for
4225 * all users on the device.
4226 */
4227 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4228 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4229
4230 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004231 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4232 * intents to indicate that this is a replacement of the package, so this
4233 * broadcast will immediately be followed by an add broadcast for a
4234 * different version of the same package.
4235 */
4236 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004237
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004238 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004239 * Used as an int extra field in {@link android.app.AlarmManager} intents
4240 * to tell the application being invoked how many pending alarms are being
4241 * delievered with the intent. For one-shot alarms this will always be 1.
4242 * For recurring alarms, this might be greater than 1 if the device was
4243 * asleep or powered off at the time an earlier alarm would have been
4244 * delivered.
4245 */
4246 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004247
Jacek Surazski86b6c532009-05-13 14:38:28 +02004248 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004249 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4250 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004251 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4252 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004253 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4254 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4255 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004256 */
4257 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4258
4259 /**
4260 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4261 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004262 */
4263 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4264
4265 /**
4266 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4267 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004268 */
4269 public static final int EXTRA_DOCK_STATE_DESK = 1;
4270
4271 /**
4272 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4273 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004274 */
4275 public static final int EXTRA_DOCK_STATE_CAR = 2;
4276
4277 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004278 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4279 * to represent that the phone is in a analog (low end) dock.
4280 */
4281 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4282
4283 /**
4284 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4285 * to represent that the phone is in a digital (high end) dock.
4286 */
4287 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4288
4289 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004290 * Boolean that can be supplied as meta-data with a dock activity, to
4291 * indicate that the dock should take over the home key when it is active.
4292 */
4293 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004294
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004295 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004296 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4297 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004298 */
4299 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4300
4301 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004302 * Used in the extra field in the remote intent. It's astring token passed with the
4303 * remote intent.
4304 */
4305 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4306 "android.intent.extra.remote_intent_token";
4307
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004308 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004309 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004310 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004311 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004312 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004313 "android.intent.extra.changed_component_name";
4314
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004315 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004316 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004317 * and contains a string array of all of the components that have changed. If
4318 * the state of the overall package has changed, then it will contain an entry
4319 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004320 */
4321 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4322 "android.intent.extra.changed_component_name_list";
4323
4324 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004325 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004326 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004327 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4328 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4329 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004330 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004331 */
4332 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4333 "android.intent.extra.changed_package_list";
4334
4335 /**
4336 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004337 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4338 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004339 * and contains an integer array of uids of all of the components
4340 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004341 */
4342 public static final String EXTRA_CHANGED_UID_LIST =
4343 "android.intent.extra.changed_uid_list";
4344
4345 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004346 * @hide
4347 * Magic extra system code can use when binding, to give a label for
4348 * who it is that has bound to a service. This is an integer giving
4349 * a framework string resource that can be displayed to the user.
4350 */
4351 public static final String EXTRA_CLIENT_LABEL =
4352 "android.intent.extra.client_label";
4353
4354 /**
4355 * @hide
4356 * Magic extra system code can use when binding, to give a PendingIntent object
4357 * that can be launched for the user to disable the system's use of this
4358 * service.
4359 */
4360 public static final String EXTRA_CLIENT_INTENT =
4361 "android.intent.extra.client_intent";
4362
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004363 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004364 * Extra used to indicate that an intent should only return data that is on
4365 * the local device. This is a boolean extra; the default is false. If true,
4366 * an implementation should only allow the user to select data that is
4367 * already on the device, not requiring it be downloaded from a remote
4368 * service when opened.
4369 *
4370 * @see #ACTION_GET_CONTENT
4371 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004372 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004373 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004374 */
4375 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004376 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004377
Amith Yamasani13593602012-03-22 16:16:17 -07004378 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004379 * Extra used to indicate that an intent can allow the user to select and
4380 * return multiple items. This is a boolean extra; the default is false. If
4381 * true, an implementation is allowed to present the user with a UI where
4382 * they can pick multiple items that are all returned to the caller. When
4383 * this happens, they should be returned as the {@link #getClipData()} part
4384 * of the result Intent.
4385 *
4386 * @see #ACTION_GET_CONTENT
4387 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004388 */
4389 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004390 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004391
4392 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004393 * The integer userHandle carried with broadcast intents related to addition, removal and
4394 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4395 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4396 *
Amith Yamasani13593602012-03-22 16:16:17 -07004397 * @hide
4398 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004399 public static final String EXTRA_USER_HANDLE =
4400 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004401
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004402 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004403 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4404 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4405 */
4406 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004407 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004408
4409 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004410 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004411 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4412 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004413 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004414 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4415
4416 /**
4417 * Extra sent in the intent to the BroadcastReceiver that handles
4418 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4419 * the restrictions as key/value pairs.
4420 */
4421 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4422 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004423
Amith Yamasani86118ba2013-03-28 14:33:16 -07004424 /**
4425 * Extra used in the response from a BroadcastReceiver that handles
4426 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4427 */
4428 public static final String EXTRA_RESTRICTIONS_INTENT =
4429 "android.intent.extra.restrictions_intent";
4430
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004431 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004432 * Extra used to communicate a set of acceptable MIME types. The type of the
4433 * extra is {@code String[]}. Values may be a combination of concrete MIME
4434 * types (such as "image/png") and/or partial MIME types (such as
4435 * "audio/*").
4436 *
4437 * @see #ACTION_GET_CONTENT
4438 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004439 */
4440 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4441
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004442 /**
4443 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4444 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004445 * When this is true, hardware devices can use this information to determine that
4446 * they shouldn't do a complete shutdown of their device since this is not a
4447 * complete shutdown down to the kernel, but only user space restarting.
4448 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004449 */
4450 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4451 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4452
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004453 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004454 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4455 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4456 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4457 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004458 *
4459 * @hide for internal use only.
4460 */
4461 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4462 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004463 /** @hide */
4464 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4465 /** @hide */
4466 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4467 /** @hide */
4468 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004469
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004470 /** {@hide} */
4471 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4472
Rubin Xue8490f12015-06-25 12:17:48 +01004473 /** {@hide} */
4474 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4475
Santos Cordon15a13782015-03-31 18:32:31 -07004476 /**
4477 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4478 * activation request.
4479 * TODO: Add information about the structure and response data used with the pending intent.
4480 * @hide
4481 */
4482 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4483 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4484
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004485 /**
4486 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004487 *
4488 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004489 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004490 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004491 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4492
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004493 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004494 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4495 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4496 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004497 *
4498 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004499 * @see #ACTION_QUICK_VIEW
4500 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004501 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004502 @Deprecated
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 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004507 * An optional extra of {@code String[]} indicating which quick view features should be made
4508 * available to the user in the quick view UI while handing a
4509 * {@link Intent#ACTION_QUICK_VIEW} intent.
4510 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4511 * Quick viewer can implement features not listed below.
4512 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4513 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4514 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4515 * <p>
4516 * Requirements:
4517 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4518 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4519 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4520 * internal policies.
4521 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4522 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4523 * disable or hide features.
4524 *
4525 * @see #ACTION_QUICK_VIEW
4526 */
4527 public static final String EXTRA_QUICK_VIEW_FEATURES =
4528 "android.intent.extra.QUICK_VIEW_FEATURES";
4529
4530 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004531 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004532 * When a profile goes into quiet mode, all apps in the profile are killed and the
4533 * profile user is stopped. Widgets originating from the profile are masked, and app
4534 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004535 */
4536 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004537
4538 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004539 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004540 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004541 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4542 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004543 *
4544 * @hide
4545 */
4546 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4547 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4548
4549 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004550 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4551 * whether to show the chooser or not when there is only one application available
4552 * to choose from.
4553 *
4554 * @hide
4555 */
4556 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4557 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4558
4559 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004560 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004561 * to represent that a video codec is allowed to use.
4562 *
4563 * @hide
4564 */
4565 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4566
4567 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004568 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004569 * to represent that a audio codec is allowed to use.
4570 *
4571 * @hide
4572 */
4573 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4574
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004575 // ---------------------------------------------------------------------
4576 // ---------------------------------------------------------------------
4577 // Intent flags (see mFlags variable).
4578
Tor Norbyed9273d62013-05-30 15:59:53 -07004579 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004580 @IntDef(flag = true, value = {
4581 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4582 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004583 @Retention(RetentionPolicy.SOURCE)
4584 public @interface GrantUriMode {}
4585
Jeff Sharkey846318a2014-04-04 12:12:41 -07004586 /** @hide */
4587 @IntDef(flag = true, value = {
4588 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4589 @Retention(RetentionPolicy.SOURCE)
4590 public @interface AccessUriMode {}
4591
4592 /**
4593 * Test if given mode flags specify an access mode, which must be at least
4594 * read and/or write.
4595 *
4596 * @hide
4597 */
4598 public static boolean isAccessUriMode(int modeFlags) {
4599 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4600 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4601 }
4602
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004603 /**
4604 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004605 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004606 * specified in its ClipData. When applying to an Intent's ClipData,
4607 * all URIs as well as recursive traversals through data or other ClipData
4608 * in Intent items will be granted; only the grant flags of the top-level
4609 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004610 */
4611 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4612 /**
4613 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004614 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004615 * specified in its ClipData. When applying to an Intent's ClipData,
4616 * all URIs as well as recursive traversals through data or other ClipData
4617 * in Intent items will be granted; only the grant flags of the top-level
4618 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004619 */
4620 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4621 /**
4622 * Can be set by the caller to indicate that this Intent is coming from
4623 * a background operation, not from direct user interaction.
4624 */
4625 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4626 /**
4627 * A flag you can enable for debugging: when set, log messages will be
4628 * printed during the resolution of this intent to show you what has
4629 * been found to create the final resolved list.
4630 */
4631 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004632 /**
4633 * If set, this intent will not match any components in packages that
4634 * are currently stopped. If this is not set, then the default behavior
4635 * is to include such applications in the result.
4636 */
4637 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4638 /**
4639 * If set, this intent will always match any components in packages that
4640 * are currently stopped. This is the default behavior when
4641 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4642 * flags are set, this one wins (it allows overriding of exclude for
4643 * places where the framework may automatically set the exclude flag).
4644 */
4645 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004646
4647 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004648 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004649 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004650 * persisted across device reboots until explicitly revoked with
4651 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4652 * grant for possible persisting; the receiving application must call
4653 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4654 * actually persist.
4655 *
4656 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4657 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4658 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004659 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004660 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004661 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004662
4663 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004664 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4665 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4666 * applies to any URI that is a prefix match against the original granted
4667 * URI. (Without this flag, the URI must match exactly for access to be
4668 * granted.) Another URI is considered a prefix match only when scheme,
4669 * authority, and all path segments defined by the prefix are an exact
4670 * match.
4671 */
4672 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4673
4674 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004675 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004676 * homework and verified that they correctly handle packages and components
4677 * that come and go over time. In particular:
4678 * <ul>
4679 * <li>Apps installed on external storage, which will appear to be
4680 * uninstalled while the the device is ejected.
4681 * <li>Apps with encryption unaware components, which will appear to not
4682 * exist while the device is locked.
4683 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004684 *
4685 * @hide
4686 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004687 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004688
4689 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004690 * Internal flag used to indicate ephemeral applications should not be
4691 * considered when resolving the intent.
4692 *
4693 * @hide
4694 */
4695 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4696
4697 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004698 * If set, the new activity is not kept in the history stack. As soon as
4699 * the user navigates away from it, the activity is finished. This may also
4700 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4701 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004702 *
4703 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4704 * is never invoked when the current activity starts a new activity which
4705 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004706 */
4707 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4708 /**
4709 * If set, the activity will not be launched if it is already running
4710 * at the top of the history stack.
4711 */
4712 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4713 /**
4714 * If set, this activity will become the start of a new task on this
4715 * history stack. A task (from the activity that started it to the
4716 * next task activity) defines an atomic group of activities that the
4717 * user can move to. Tasks can be moved to the foreground and background;
4718 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004719 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004720 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4721 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004722 *
4723 * <p>This flag is generally used by activities that want
4724 * to present a "launcher" style behavior: they give the user a list of
4725 * separate things that can be done, which otherwise run completely
4726 * independently of the activity launching them.
4727 *
4728 * <p>When using this flag, if a task is already running for the activity
4729 * you are now starting, then a new activity will not be started; instead,
4730 * the current task will simply be brought to the front of the screen with
4731 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4732 * to disable this behavior.
4733 *
4734 * <p>This flag can not be used when the caller is requesting a result from
4735 * the activity being launched.
4736 */
4737 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4738 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004739 * This flag is used to create a new task and launch an activity into it.
4740 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4741 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4742 * search through existing tasks for ones matching this Intent. Only if no such
4743 * task is found would a new task be created. When paired with
4744 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4745 * the search for a matching task and unconditionally start a new task.
4746 *
4747 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4748 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004749 * top-level application launcher.</strong> Used in conjunction with
4750 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4751 * behavior of bringing an existing task to the foreground. When set,
4752 * a new task is <em>always</em> started to host the Activity for the
4753 * Intent, regardless of whether there is already an existing task running
4754 * the same thing.
4755 *
4756 * <p><strong>Because the default system does not include graphical task management,
4757 * you should not use this flag unless you provide some way for a user to
4758 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004759 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004760 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4761 * creating new document tasks.
4762 *
4763 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004764 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004765 *
Scott Main7aee61f2011-02-08 11:25:01 -08004766 * <p>See
4767 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4768 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004769 *
4770 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4771 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004772 */
4773 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4774 /**
4775 * If set, and the activity being launched is already running in the
4776 * current task, then instead of launching a new instance of that activity,
4777 * all of the other activities on top of it will be closed and this Intent
4778 * will be delivered to the (now on top) old activity as a new Intent.
4779 *
4780 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4781 * If D calls startActivity() with an Intent that resolves to the component
4782 * of activity B, then C and D will be finished and B receive the given
4783 * Intent, resulting in the stack now being: A, B.
4784 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004785 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004786 * either receive the new intent you are starting here in its
4787 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004788 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004789 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4790 * the same intent, then it will be finished and re-created; for all other
4791 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4792 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004793 *
4794 * <p>This launch mode can also be used to good effect in conjunction with
4795 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4796 * of a task, it will bring any currently running instance of that task
4797 * to the foreground, and then clear it to its root state. This is
4798 * especially useful, for example, when launching an activity from the
4799 * notification manager.
4800 *
Scott Main7aee61f2011-02-08 11:25:01 -08004801 * <p>See
4802 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4803 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004804 */
4805 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4806 /**
4807 * If set and this intent is being used to launch a new activity from an
4808 * existing one, then the reply target of the existing activity will be
4809 * transfered to the new activity. This way the new activity can call
4810 * {@link android.app.Activity#setResult} and have that result sent back to
4811 * the reply target of the original activity.
4812 */
4813 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4814 /**
4815 * If set and this intent is being used to launch a new activity from an
4816 * existing one, the current activity will not be counted as the top
4817 * activity for deciding whether the new intent should be delivered to
4818 * the top instead of starting a new one. The previous activity will
4819 * be used as the top, with the assumption being that the current activity
4820 * will finish itself immediately.
4821 */
4822 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4823 /**
4824 * If set, the new activity is not kept in the list of recently launched
4825 * activities.
4826 */
4827 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4828 /**
4829 * This flag is not normally set by application code, but set for you by
4830 * the system as described in the
4831 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4832 * launchMode} documentation for the singleTask mode.
4833 */
4834 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4835 /**
4836 * If set, and this activity is either being started in a new task or
4837 * bringing to the top an existing task, then it will be launched as
4838 * the front door of the task. This will result in the application of
4839 * any affinities needed to have that task in the proper state (either
4840 * moving activities to or from it), or simply resetting that task to
4841 * its initial state if needed.
4842 */
4843 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4844 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004845 * This flag is not normally set by application code, but set for you by
4846 * the system if this activity is being launched from history
4847 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004848 */
4849 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004850 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004851 * @deprecated As of API 21 this performs identically to
4852 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004853 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004854 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004855 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004856 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004857 * This flag is used to open a document into a new task rooted at the activity launched
4858 * by this Intent. Through the use of this flag, or its equivalent attribute,
4859 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004860 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004861 *
Craig Mautner026596b2014-05-21 15:35:44 -07004862 * <p>The use of the activity attribute form of this,
4863 * {@link android.R.attr#documentLaunchMode}, is
4864 * preferred over the Intent flag described here. The attribute form allows the
4865 * Activity to specify multiple document behavior for all launchers of the Activity
4866 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004867 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004868 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4869 * it is kept after the activity is finished is different than the use of
4870 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4871 * this flag is being used to create a new recents entry, then by default that entry
4872 * will be removed once the activity is finished. You can modify this behavior with
4873 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4874 *
Craig Mautner026596b2014-05-21 15:35:44 -07004875 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4876 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4877 * equivalent of the Activity manifest specifying {@link
4878 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4879 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4880 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004881 *
Craig Mautner026596b2014-05-21 15:35:44 -07004882 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004883 *
Craig Mautner026596b2014-05-21 15:35:44 -07004884 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004885 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4886 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004887 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004888 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004889 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004890 * callback from occurring on the current frontmost activity before it is
4891 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004892 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004893 * <p>Typically, an activity can rely on that callback to indicate that an
4894 * explicit user action has caused their activity to be moved out of the
4895 * foreground. The callback marks an appropriate point in the activity's
4896 * lifecycle for it to dismiss any notifications that it intends to display
4897 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004898 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004899 * <p>If an activity is ever started via any non-user-driven events such as
4900 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4901 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004902 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004903 */
4904 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004905 /**
4906 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4907 * this flag will cause the launched activity to be brought to the front of its
4908 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004909 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004910 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4911 * If D calls startActivity() with an Intent that resolves to the component
4912 * of activity B, then B will be brought to the front of the history stack,
4913 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004914 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004915 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004916 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004917 */
4918 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004919 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004920 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4921 * this flag will prevent the system from applying an activity transition
4922 * animation to go to the next activity state. This doesn't mean an
4923 * animation will never run -- if another activity change happens that doesn't
4924 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004925 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004926 * when you are going to do a series of activity operations but the
4927 * animation seen by the user shouldn't be driven by the first activity
4928 * change but rather a later one.
4929 */
4930 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4931 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004932 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4933 * this flag will cause any existing task that would be associated with the
4934 * activity to be cleared before the activity is started. That is, the activity
4935 * becomes the new root of an otherwise empty task, and any old activities
4936 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4937 */
4938 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4939 /**
4940 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4941 * this flag will cause a newly launching task to be placed on top of the current
4942 * home activity task (if there is one). That is, pressing back from the task
4943 * will always return the user to home even if that was not the last activity they
4944 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4945 */
4946 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4947 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004948 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4949 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004950 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004951 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004952 * this flag. When set and the task's activity is finished, the recents
4953 * entry will remain in the interface for the user to re-launch it, like a
4954 * recents entry for a top-level application.
4955 * <p>
4956 * The receiving activity can override this request with
4957 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4958 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004959 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004960 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004961 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004962
4963 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004964 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4965 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004966 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4967 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004968 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004969 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004970
4971 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004972 * If set, when sending a broadcast only registered receivers will be
4973 * called -- no BroadcastReceiver components will be launched.
4974 */
4975 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004976 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004977 * If set, when sending a broadcast the new broadcast will replace
4978 * any existing pending broadcast that matches it. Matching is defined
4979 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4980 * true for the intents of the two broadcasts. When a match is found,
4981 * the new broadcast (and receivers associated with it) will replace the
4982 * existing one in the pending broadcast list, remaining at the same
4983 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004984 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004985 * <p>This flag is most typically used with sticky broadcasts, which
4986 * only care about delivering the most recent values of the broadcast
4987 * to their receivers.
4988 */
4989 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4990 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004991 * If set, when sending a broadcast the recipient is allowed to run at
4992 * foreground priority, with a shorter timeout interval. During normal
4993 * broadcasts the receivers are not automatically hoisted out of the
4994 * background priority class.
4995 */
4996 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4997 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004998 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4999 * They can still propagate results through to later receivers, but they can not prevent
5000 * later receivers from seeing the broadcast.
5001 */
5002 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5003 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005004 * If set, when sending a broadcast <i>before boot has completed</i> only
5005 * registered receivers will be called -- no BroadcastReceiver components
5006 * will be launched. Sticky intent state will be recorded properly even
5007 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5008 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005009 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005010 * <p>This flag is only for use by system sevices as a convenience to
5011 * avoid having to implement a more complex mechanism around detection
5012 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005013 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005014 * @hide
5015 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005016 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005017 /**
5018 * Set when this broadcast is for a boot upgrade, a special mode that
5019 * allows the broadcast to be sent before the system is ready and launches
5020 * the app process with no providers running in it.
5021 * @hide
5022 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005023 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005024 /**
5025 * If set, the broadcast will always go to manifest receivers in background (cached
5026 * or not running) apps, regardless of whether that would be done by default. By
5027 * default they will only receive broadcasts if the broadcast has specified an
5028 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005029 *
5030 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5031 * the broadcast code there must also be changed to match.
5032 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005033 * @hide
5034 */
5035 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5036 /**
5037 * If set, the broadcast will never go to manifest receivers in background (cached
5038 * or not running) apps, regardless of whether that would be done by default. By
5039 * default they will receive broadcasts if the broadcast has specified an
5040 * explicit component or package name.
5041 * @hide
5042 */
5043 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005044 /**
5045 * If set, this broadcast is being sent from the shell.
5046 * @hide
5047 */
5048 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005049
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005050 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005051 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5052 * will not receive broadcasts.
5053 *
5054 * <em>This flag has no effect when used by an Instant App.</em>
5055 */
5056 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5057
5058 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005059 * @hide Flags that can't be changed with PendingIntent.
5060 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005061 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5062 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5063 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005064
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005065 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005066 // ---------------------------------------------------------------------
5067 // toUri() and parseUri() options.
5068
5069 /**
5070 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5071 * always has the "intent:" scheme. This syntax can be used when you want
5072 * to later disambiguate between URIs that are intended to describe an
5073 * Intent vs. all others that should be treated as raw URIs. When used
5074 * with {@link #parseUri}, any other scheme will result in a generic
5075 * VIEW action for that raw URI.
5076 */
5077 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005078
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005079 /**
5080 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5081 * always has the "android-app:" scheme. This is a variation of
5082 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5083 * http/https URI being delivered to a specific package name. The format
5084 * is:
5085 *
5086 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005087 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005088 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005089 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5090 * you must also include a scheme; including a path also requires both a host and a scheme.
5091 * The final #Intent; fragment can be used without a scheme, host, or path.
5092 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005093 * used with intents that have a {@link #setSelector}, since the base intent
5094 * will always have an explicit package name.</p>
5095 *
5096 * <p>Some examples of how this scheme maps to Intent objects:</p>
5097 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5098 * <colgroup align="left" />
5099 * <colgroup align="left" />
5100 * <thead>
5101 * <tr><th>URI</th> <th>Intent</th></tr>
5102 * </thead>
5103 *
5104 * <tbody>
5105 * <tr><td><code>android-app://com.example.app</code></td>
5106 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5107 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5108 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5109 * </table></td>
5110 * </tr>
5111 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5112 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5113 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5114 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5115 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5116 * </table></td>
5117 * </tr>
5118 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5119 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5120 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5121 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5122 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5123 * </table></td>
5124 * </tr>
5125 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5126 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5127 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5128 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5129 * </table></td>
5130 * </tr>
5131 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5132 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5133 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5134 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5135 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5136 * </table></td>
5137 * </tr>
5138 * <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>
5139 * <td><table border="" style="margin:0" >
5140 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5141 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5142 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5143 * </table></td>
5144 * </tr>
5145 * </tbody>
5146 * </table>
5147 */
5148 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5149
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005150 /**
5151 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5152 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5153 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5154 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5155 * generated Intent can not cause unexpected data access to happen.
5156 *
5157 * <p>If you do not trust the source of the URI being parsed, you should still do further
5158 * processing to protect yourself from it. In particular, when using it to start an
5159 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5160 * that can handle it.</p>
5161 */
5162 public static final int URI_ALLOW_UNSAFE = 1<<2;
5163
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005164 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005165
5166 private String mAction;
5167 private Uri mData;
5168 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005169 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005170 private ComponentName mComponent;
5171 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005172 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005173 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005174 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005175 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005176 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005177 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005178 /** Token to track instant app launches. Local only; do not copy cross-process. */
5179 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005180
5181 // ---------------------------------------------------------------------
5182
5183 /**
5184 * Create an empty intent.
5185 */
5186 public Intent() {
5187 }
5188
5189 /**
5190 * Copy constructor.
5191 */
5192 public Intent(Intent o) {
5193 this.mAction = o.mAction;
5194 this.mData = o.mData;
5195 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005196 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005197 this.mComponent = o.mComponent;
5198 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005199 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005200 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005201 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005202 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005203 }
5204 if (o.mExtras != null) {
5205 this.mExtras = new Bundle(o.mExtras);
5206 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005207 if (o.mSourceBounds != null) {
5208 this.mSourceBounds = new Rect(o.mSourceBounds);
5209 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005210 if (o.mSelector != null) {
5211 this.mSelector = new Intent(o.mSelector);
5212 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005213 if (o.mClipData != null) {
5214 this.mClipData = new ClipData(o.mClipData);
5215 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005216 }
5217
5218 @Override
5219 public Object clone() {
5220 return new Intent(this);
5221 }
5222
5223 private Intent(Intent o, boolean all) {
5224 this.mAction = o.mAction;
5225 this.mData = o.mData;
5226 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005227 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005228 this.mComponent = o.mComponent;
5229 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005230 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005231 }
5232 }
5233
5234 /**
5235 * Make a clone of only the parts of the Intent that are relevant for
5236 * filter matching: the action, data, type, component, and categories.
5237 */
5238 public Intent cloneFilter() {
5239 return new Intent(this, false);
5240 }
5241
5242 /**
5243 * Create an intent with a given action. All other fields (data, type,
5244 * class) are null. Note that the action <em>must</em> be in a
5245 * namespace because Intents are used globally in the system -- for
5246 * example the system VIEW action is android.intent.action.VIEW; an
5247 * application's custom action would be something like
5248 * com.google.app.myapp.CUSTOM_ACTION.
5249 *
5250 * @param action The Intent action, such as ACTION_VIEW.
5251 */
5252 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005253 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005254 }
5255
5256 /**
5257 * Create an intent with a given action and for a given data url. Note
5258 * that the action <em>must</em> be in a namespace because Intents are
5259 * used globally in the system -- for example the system VIEW action is
5260 * android.intent.action.VIEW; an application's custom action would be
5261 * something like com.google.app.myapp.CUSTOM_ACTION.
5262 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005263 * <p><em>Note: scheme and host name matching in the Android framework is
5264 * case-sensitive, unlike the formal RFC. As a result,
5265 * you should always ensure that you write your Uri with these elements
5266 * using lower case letters, and normalize any Uris you receive from
5267 * outside of Android to ensure the scheme and host is lower case.</em></p>
5268 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005269 * @param action The Intent action, such as ACTION_VIEW.
5270 * @param uri The Intent data URI.
5271 */
5272 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005273 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005274 mData = uri;
5275 }
5276
5277 /**
5278 * Create an intent for a specific component. All other fields (action, data,
5279 * type, class) are null, though they can be modified later with explicit
5280 * calls. This provides a convenient way to create an intent that is
5281 * intended to execute a hard-coded class name, rather than relying on the
5282 * system to find an appropriate class for you; see {@link #setComponent}
5283 * for more information on the repercussions of this.
5284 *
5285 * @param packageContext A Context of the application package implementing
5286 * this class.
5287 * @param cls The component class that is to be used for the intent.
5288 *
5289 * @see #setClass
5290 * @see #setComponent
5291 * @see #Intent(String, android.net.Uri , Context, Class)
5292 */
5293 public Intent(Context packageContext, Class<?> cls) {
5294 mComponent = new ComponentName(packageContext, cls);
5295 }
5296
5297 /**
5298 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005299 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005300 * construct the Intent and then calling {@link #setClass} to set its
5301 * class.
5302 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005303 * <p><em>Note: scheme and host name matching in the Android framework is
5304 * case-sensitive, unlike the formal RFC. As a result,
5305 * you should always ensure that you write your Uri with these elements
5306 * using lower case letters, and normalize any Uris you receive from
5307 * outside of Android to ensure the scheme and host is lower case.</em></p>
5308 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005309 * @param action The Intent action, such as ACTION_VIEW.
5310 * @param uri The Intent data URI.
5311 * @param packageContext A Context of the application package implementing
5312 * this class.
5313 * @param cls The component class that is to be used for the intent.
5314 *
5315 * @see #Intent(String, android.net.Uri)
5316 * @see #Intent(Context, Class)
5317 * @see #setClass
5318 * @see #setComponent
5319 */
5320 public Intent(String action, Uri uri,
5321 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005322 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005323 mData = uri;
5324 mComponent = new ComponentName(packageContext, cls);
5325 }
5326
5327 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005328 * Create an intent to launch the main (root) activity of a task. This
5329 * is the Intent that is started when the application's is launched from
5330 * Home. For anything else that wants to launch an application in the
5331 * same way, it is important that they use an Intent structured the same
5332 * way, and can use this function to ensure this is the case.
5333 *
5334 * <p>The returned Intent has the given Activity component as its explicit
5335 * component, {@link #ACTION_MAIN} as its action, and includes the
5336 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5337 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5338 * to do that through {@link #addFlags(int)} on the returned Intent.
5339 *
5340 * @param mainActivity The main activity component that this Intent will
5341 * launch.
5342 * @return Returns a newly created Intent that can be used to launch the
5343 * activity as a main application entry.
5344 *
5345 * @see #setClass
5346 * @see #setComponent
5347 */
5348 public static Intent makeMainActivity(ComponentName mainActivity) {
5349 Intent intent = new Intent(ACTION_MAIN);
5350 intent.setComponent(mainActivity);
5351 intent.addCategory(CATEGORY_LAUNCHER);
5352 return intent;
5353 }
5354
5355 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005356 * Make an Intent for the main activity of an application, without
5357 * specifying a specific activity to run but giving a selector to find
5358 * the activity. This results in a final Intent that is structured
5359 * the same as when the application is launched from
5360 * Home. For anything else that wants to launch an application in the
5361 * same way, it is important that they use an Intent structured the same
5362 * way, and can use this function to ensure this is the case.
5363 *
5364 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5365 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5366 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5367 * to do that through {@link #addFlags(int)} on the returned Intent.
5368 *
5369 * @param selectorAction The action name of the Intent's selector.
5370 * @param selectorCategory The name of a category to add to the Intent's
5371 * selector.
5372 * @return Returns a newly created Intent that can be used to launch the
5373 * activity as a main application entry.
5374 *
5375 * @see #setSelector(Intent)
5376 */
5377 public static Intent makeMainSelectorActivity(String selectorAction,
5378 String selectorCategory) {
5379 Intent intent = new Intent(ACTION_MAIN);
5380 intent.addCategory(CATEGORY_LAUNCHER);
5381 Intent selector = new Intent();
5382 selector.setAction(selectorAction);
5383 selector.addCategory(selectorCategory);
5384 intent.setSelector(selector);
5385 return intent;
5386 }
5387
5388 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005389 * Make an Intent that can be used to re-launch an application's task
5390 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5391 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5392 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5393 *
5394 * @param mainActivity The activity component that is the root of the
5395 * task; this is the activity that has been published in the application's
5396 * manifest as the main launcher icon.
5397 *
5398 * @return Returns a newly created Intent that can be used to relaunch the
5399 * activity's task in its root state.
5400 */
5401 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5402 Intent intent = makeMainActivity(mainActivity);
5403 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5404 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5405 return intent;
5406 }
5407
5408 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005409 * Call {@link #parseUri} with 0 flags.
5410 * @deprecated Use {@link #parseUri} instead.
5411 */
5412 @Deprecated
5413 public static Intent getIntent(String uri) throws URISyntaxException {
5414 return parseUri(uri, 0);
5415 }
Tom Taylord4a47292009-12-21 13:59:18 -08005416
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005417 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005418 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005419 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005420 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005421 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005422 *
5423 * <p>The URI given here must not be relative -- that is, it must include
5424 * the scheme and full path.
5425 *
5426 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005427 * @param flags Additional processing flags. Either 0,
5428 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005429 *
5430 * @return Intent The newly created Intent object.
5431 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005432 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5433 * it bad (as parsed by the Uri class) or the Intent data within the
5434 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005435 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005436 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005437 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005438 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005439 int i = 0;
5440 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005441 final boolean androidApp = uri.startsWith("android-app:");
5442
5443 // Validate intent scheme if requested.
5444 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5445 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005446 Intent intent = new Intent(ACTION_VIEW);
5447 try {
5448 intent.setData(Uri.parse(uri));
5449 } catch (IllegalArgumentException e) {
5450 throw new URISyntaxException(uri, e.getMessage());
5451 }
5452 return intent;
5453 }
5454 }
Tom Taylord4a47292009-12-21 13:59:18 -08005455
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005456 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005457 // simple case
5458 if (i == -1) {
5459 if (!androidApp) {
5460 return new Intent(ACTION_VIEW, Uri.parse(uri));
5461 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005462
5463 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005464 } else if (!uri.startsWith("#Intent;", i)) {
5465 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005466 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005467 } else {
5468 i = -1;
5469 }
5470 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005471
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005472 // new format
5473 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005474 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005475 boolean explicitAction = false;
5476 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005477
5478 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005479 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005480 String data;
5481 if (i >= 0) {
5482 data = uri.substring(0, i);
5483 i += 8; // length of "#Intent;"
5484 } else {
5485 data = uri;
5486 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005487
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005488 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005489 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005490 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005491 if (eq < 0) eq = i-1;
5492 int semi = uri.indexOf(';', i);
5493 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005494
5495 // action
5496 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005497 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005498 if (!inSelector) {
5499 explicitAction = true;
5500 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005501 }
5502
5503 // categories
5504 else if (uri.startsWith("category=", i)) {
5505 intent.addCategory(value);
5506 }
5507
5508 // type
5509 else if (uri.startsWith("type=", i)) {
5510 intent.mType = value;
5511 }
5512
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005513 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005514 else if (uri.startsWith("launchFlags=", i)) {
5515 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005516 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5517 intent.mFlags &= ~IMMUTABLE_FLAGS;
5518 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005519 }
5520
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005521 // package
5522 else if (uri.startsWith("package=", i)) {
5523 intent.mPackage = value;
5524 }
5525
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005526 // component
5527 else if (uri.startsWith("component=", i)) {
5528 intent.mComponent = ComponentName.unflattenFromString(value);
5529 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005530
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005531 // scheme
5532 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005533 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005534 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005535 } else {
5536 scheme = value;
5537 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005538 }
5539
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005540 // source bounds
5541 else if (uri.startsWith("sourceBounds=", i)) {
5542 intent.mSourceBounds = Rect.unflattenFromString(value);
5543 }
5544
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005545 // selector
5546 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5547 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005548 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005549 }
5550
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005551 // extra
5552 else {
5553 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005554 // create Bundle if it doesn't already exist
5555 if (intent.mExtras == null) intent.mExtras = new Bundle();
5556 Bundle b = intent.mExtras;
5557 // add EXTRA
5558 if (uri.startsWith("S.", i)) b.putString(key, value);
5559 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5560 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5561 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5562 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5563 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5564 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5565 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5566 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5567 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5568 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005569
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005570 // move to the next item
5571 i = semi + 1;
5572 }
5573
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005574 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005575 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005576 if (baseIntent.mPackage == null) {
5577 baseIntent.setSelector(intent);
5578 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005579 intent = baseIntent;
5580 }
5581
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005582 if (data != null) {
5583 if (data.startsWith("intent:")) {
5584 data = data.substring(7);
5585 if (scheme != null) {
5586 data = scheme + ':' + data;
5587 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005588 } else if (data.startsWith("android-app:")) {
5589 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5590 // Correctly formed android-app, first part is package name.
5591 int end = data.indexOf('/', 14);
5592 if (end < 0) {
5593 // All we have is a package name.
5594 intent.mPackage = data.substring(14);
5595 if (!explicitAction) {
5596 intent.setAction(ACTION_MAIN);
5597 }
5598 data = "";
5599 } else {
5600 // Target the Intent at the given package name always.
5601 String authority = null;
5602 intent.mPackage = data.substring(14, end);
5603 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005604 if ((end+1) < data.length()) {
5605 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5606 // Found a scheme, remember it.
5607 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005608 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005609 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5610 // Found a authority, remember it.
5611 authority = data.substring(end+1, newEnd);
5612 end = newEnd;
5613 }
5614 } else {
5615 // All we have is a scheme.
5616 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005617 }
5618 }
5619 if (scheme == null) {
5620 // If there was no scheme, then this just targets the package.
5621 if (!explicitAction) {
5622 intent.setAction(ACTION_MAIN);
5623 }
5624 data = "";
5625 } else if (authority == null) {
5626 data = scheme + ":";
5627 } else {
5628 data = scheme + "://" + authority + data.substring(end);
5629 }
5630 }
5631 } else {
5632 data = "";
5633 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005634 }
Tom Taylord4a47292009-12-21 13:59:18 -08005635
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005636 if (data.length() > 0) {
5637 try {
5638 intent.mData = Uri.parse(data);
5639 } catch (IllegalArgumentException e) {
5640 throw new URISyntaxException(uri, e.getMessage());
5641 }
5642 }
5643 }
Tom Taylord4a47292009-12-21 13:59:18 -08005644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005645 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005646
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005647 } catch (IndexOutOfBoundsException e) {
5648 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5649 }
5650 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005651
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005652 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005653 return getIntentOld(uri, 0);
5654 }
5655
5656 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005657 Intent intent;
5658
5659 int i = uri.lastIndexOf('#');
5660 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005661 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005662 final int intentFragmentStart = i;
5663 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005664
5665 i++;
5666
5667 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005668 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005669 i += 7;
5670 int j = uri.indexOf(')', i);
5671 action = uri.substring(i, j);
5672 i = j + 1;
5673 }
5674
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005675 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005676
5677 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005678 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005679 i += 11;
5680 int j = uri.indexOf(')', i);
5681 while (i < j) {
5682 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005683 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005684 if (i < sep) {
5685 intent.addCategory(uri.substring(i, sep));
5686 }
5687 i = sep + 1;
5688 }
5689 i = j + 1;
5690 }
5691
5692 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005693 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005694 i += 5;
5695 int j = uri.indexOf(')', i);
5696 intent.mType = uri.substring(i, j);
5697 i = j + 1;
5698 }
5699
5700 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005701 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005702 i += 12;
5703 int j = uri.indexOf(')', i);
5704 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005705 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5706 intent.mFlags &= ~IMMUTABLE_FLAGS;
5707 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005708 i = j + 1;
5709 }
5710
5711 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005712 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005713 i += 10;
5714 int j = uri.indexOf(')', i);
5715 int sep = uri.indexOf('!', i);
5716 if (sep >= 0 && sep < j) {
5717 String pkg = uri.substring(i, sep);
5718 String cls = uri.substring(sep + 1, j);
5719 intent.mComponent = new ComponentName(pkg, cls);
5720 }
5721 i = j + 1;
5722 }
5723
5724 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005725 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005726 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005727
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005728 final int closeParen = uri.indexOf(')', i);
5729 if (closeParen == -1) throw new URISyntaxException(uri,
5730 "EXTRA missing trailing ')'", i);
5731
5732 while (i < closeParen) {
5733 // fetch the key value
5734 int j = uri.indexOf('=', i);
5735 if (j <= i + 1 || i >= closeParen) {
5736 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5737 }
5738 char type = uri.charAt(i);
5739 i++;
5740 String key = uri.substring(i, j);
5741 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005742
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005743 // get type-value
5744 j = uri.indexOf('!', i);
5745 if (j == -1 || j >= closeParen) j = closeParen;
5746 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5747 String value = uri.substring(i, j);
5748 i = j;
5749
5750 // create Bundle if it doesn't already exist
5751 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005752
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005753 // add item to bundle
5754 try {
5755 switch (type) {
5756 case 'S':
5757 intent.mExtras.putString(key, Uri.decode(value));
5758 break;
5759 case 'B':
5760 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5761 break;
5762 case 'b':
5763 intent.mExtras.putByte(key, Byte.parseByte(value));
5764 break;
5765 case 'c':
5766 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5767 break;
5768 case 'd':
5769 intent.mExtras.putDouble(key, Double.parseDouble(value));
5770 break;
5771 case 'f':
5772 intent.mExtras.putFloat(key, Float.parseFloat(value));
5773 break;
5774 case 'i':
5775 intent.mExtras.putInt(key, Integer.parseInt(value));
5776 break;
5777 case 'l':
5778 intent.mExtras.putLong(key, Long.parseLong(value));
5779 break;
5780 case 's':
5781 intent.mExtras.putShort(key, Short.parseShort(value));
5782 break;
5783 default:
5784 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5785 }
5786 } catch (NumberFormatException e) {
5787 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5788 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005789
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005790 char ch = uri.charAt(i);
5791 if (ch == ')') break;
5792 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5793 i++;
5794 }
5795 }
5796
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005797 if (isIntentFragment) {
5798 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5799 } else {
5800 intent.mData = Uri.parse(uri);
5801 }
Tom Taylord4a47292009-12-21 13:59:18 -08005802
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005803 if (intent.mAction == null) {
5804 // By default, if no action is specified, then use VIEW.
5805 intent.mAction = ACTION_VIEW;
5806 }
5807
5808 } else {
5809 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5810 }
5811
5812 return intent;
5813 }
5814
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005815 /** @hide */
5816 public interface CommandOptionHandler {
5817 boolean handleOption(String opt, ShellCommand cmd);
5818 }
5819
5820 /** @hide */
5821 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5822 throws URISyntaxException {
5823 Intent intent = new Intent();
5824 Intent baseIntent = intent;
5825 boolean hasIntentInfo = false;
5826
5827 Uri data = null;
5828 String type = null;
5829
5830 String opt;
5831 while ((opt=cmd.getNextOption()) != null) {
5832 switch (opt) {
5833 case "-a":
5834 intent.setAction(cmd.getNextArgRequired());
5835 if (intent == baseIntent) {
5836 hasIntentInfo = true;
5837 }
5838 break;
5839 case "-d":
5840 data = Uri.parse(cmd.getNextArgRequired());
5841 if (intent == baseIntent) {
5842 hasIntentInfo = true;
5843 }
5844 break;
5845 case "-t":
5846 type = cmd.getNextArgRequired();
5847 if (intent == baseIntent) {
5848 hasIntentInfo = true;
5849 }
5850 break;
5851 case "-c":
5852 intent.addCategory(cmd.getNextArgRequired());
5853 if (intent == baseIntent) {
5854 hasIntentInfo = true;
5855 }
5856 break;
5857 case "-e":
5858 case "--es": {
5859 String key = cmd.getNextArgRequired();
5860 String value = cmd.getNextArgRequired();
5861 intent.putExtra(key, value);
5862 }
5863 break;
5864 case "--esn": {
5865 String key = cmd.getNextArgRequired();
5866 intent.putExtra(key, (String) null);
5867 }
5868 break;
5869 case "--ei": {
5870 String key = cmd.getNextArgRequired();
5871 String value = cmd.getNextArgRequired();
5872 intent.putExtra(key, Integer.decode(value));
5873 }
5874 break;
5875 case "--eu": {
5876 String key = cmd.getNextArgRequired();
5877 String value = cmd.getNextArgRequired();
5878 intent.putExtra(key, Uri.parse(value));
5879 }
5880 break;
5881 case "--ecn": {
5882 String key = cmd.getNextArgRequired();
5883 String value = cmd.getNextArgRequired();
5884 ComponentName cn = ComponentName.unflattenFromString(value);
5885 if (cn == null)
5886 throw new IllegalArgumentException("Bad component name: " + value);
5887 intent.putExtra(key, cn);
5888 }
5889 break;
5890 case "--eia": {
5891 String key = cmd.getNextArgRequired();
5892 String value = cmd.getNextArgRequired();
5893 String[] strings = value.split(",");
5894 int[] list = new int[strings.length];
5895 for (int i = 0; i < strings.length; i++) {
5896 list[i] = Integer.decode(strings[i]);
5897 }
5898 intent.putExtra(key, list);
5899 }
5900 break;
5901 case "--eial": {
5902 String key = cmd.getNextArgRequired();
5903 String value = cmd.getNextArgRequired();
5904 String[] strings = value.split(",");
5905 ArrayList<Integer> list = new ArrayList<>(strings.length);
5906 for (int i = 0; i < strings.length; i++) {
5907 list.add(Integer.decode(strings[i]));
5908 }
5909 intent.putExtra(key, list);
5910 }
5911 break;
5912 case "--el": {
5913 String key = cmd.getNextArgRequired();
5914 String value = cmd.getNextArgRequired();
5915 intent.putExtra(key, Long.valueOf(value));
5916 }
5917 break;
5918 case "--ela": {
5919 String key = cmd.getNextArgRequired();
5920 String value = cmd.getNextArgRequired();
5921 String[] strings = value.split(",");
5922 long[] list = new long[strings.length];
5923 for (int i = 0; i < strings.length; i++) {
5924 list[i] = Long.valueOf(strings[i]);
5925 }
5926 intent.putExtra(key, list);
5927 hasIntentInfo = true;
5928 }
5929 break;
5930 case "--elal": {
5931 String key = cmd.getNextArgRequired();
5932 String value = cmd.getNextArgRequired();
5933 String[] strings = value.split(",");
5934 ArrayList<Long> list = new ArrayList<>(strings.length);
5935 for (int i = 0; i < strings.length; i++) {
5936 list.add(Long.valueOf(strings[i]));
5937 }
5938 intent.putExtra(key, list);
5939 hasIntentInfo = true;
5940 }
5941 break;
5942 case "--ef": {
5943 String key = cmd.getNextArgRequired();
5944 String value = cmd.getNextArgRequired();
5945 intent.putExtra(key, Float.valueOf(value));
5946 hasIntentInfo = true;
5947 }
5948 break;
5949 case "--efa": {
5950 String key = cmd.getNextArgRequired();
5951 String value = cmd.getNextArgRequired();
5952 String[] strings = value.split(",");
5953 float[] list = new float[strings.length];
5954 for (int i = 0; i < strings.length; i++) {
5955 list[i] = Float.valueOf(strings[i]);
5956 }
5957 intent.putExtra(key, list);
5958 hasIntentInfo = true;
5959 }
5960 break;
5961 case "--efal": {
5962 String key = cmd.getNextArgRequired();
5963 String value = cmd.getNextArgRequired();
5964 String[] strings = value.split(",");
5965 ArrayList<Float> list = new ArrayList<>(strings.length);
5966 for (int i = 0; i < strings.length; i++) {
5967 list.add(Float.valueOf(strings[i]));
5968 }
5969 intent.putExtra(key, list);
5970 hasIntentInfo = true;
5971 }
5972 break;
5973 case "--esa": {
5974 String key = cmd.getNextArgRequired();
5975 String value = cmd.getNextArgRequired();
5976 // Split on commas unless they are preceeded by an escape.
5977 // The escape character must be escaped for the string and
5978 // again for the regex, thus four escape characters become one.
5979 String[] strings = value.split("(?<!\\\\),");
5980 intent.putExtra(key, strings);
5981 hasIntentInfo = true;
5982 }
5983 break;
5984 case "--esal": {
5985 String key = cmd.getNextArgRequired();
5986 String value = cmd.getNextArgRequired();
5987 // Split on commas unless they are preceeded by an escape.
5988 // The escape character must be escaped for the string and
5989 // again for the regex, thus four escape characters become one.
5990 String[] strings = value.split("(?<!\\\\),");
5991 ArrayList<String> list = new ArrayList<>(strings.length);
5992 for (int i = 0; i < strings.length; i++) {
5993 list.add(strings[i]);
5994 }
5995 intent.putExtra(key, list);
5996 hasIntentInfo = true;
5997 }
5998 break;
5999 case "--ez": {
6000 String key = cmd.getNextArgRequired();
6001 String value = cmd.getNextArgRequired().toLowerCase();
6002 // Boolean.valueOf() results in false for anything that is not "true", which is
6003 // error-prone in shell commands
6004 boolean arg;
6005 if ("true".equals(value) || "t".equals(value)) {
6006 arg = true;
6007 } else if ("false".equals(value) || "f".equals(value)) {
6008 arg = false;
6009 } else {
6010 try {
6011 arg = Integer.decode(value) != 0;
6012 } catch (NumberFormatException ex) {
6013 throw new IllegalArgumentException("Invalid boolean value: " + value);
6014 }
6015 }
6016
6017 intent.putExtra(key, arg);
6018 }
6019 break;
6020 case "-n": {
6021 String str = cmd.getNextArgRequired();
6022 ComponentName cn = ComponentName.unflattenFromString(str);
6023 if (cn == null)
6024 throw new IllegalArgumentException("Bad component name: " + str);
6025 intent.setComponent(cn);
6026 if (intent == baseIntent) {
6027 hasIntentInfo = true;
6028 }
6029 }
6030 break;
6031 case "-p": {
6032 String str = cmd.getNextArgRequired();
6033 intent.setPackage(str);
6034 if (intent == baseIntent) {
6035 hasIntentInfo = true;
6036 }
6037 }
6038 break;
6039 case "-f":
6040 String str = cmd.getNextArgRequired();
6041 intent.setFlags(Integer.decode(str).intValue());
6042 break;
6043 case "--grant-read-uri-permission":
6044 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6045 break;
6046 case "--grant-write-uri-permission":
6047 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6048 break;
6049 case "--grant-persistable-uri-permission":
6050 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6051 break;
6052 case "--grant-prefix-uri-permission":
6053 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6054 break;
6055 case "--exclude-stopped-packages":
6056 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6057 break;
6058 case "--include-stopped-packages":
6059 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6060 break;
6061 case "--debug-log-resolution":
6062 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6063 break;
6064 case "--activity-brought-to-front":
6065 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6066 break;
6067 case "--activity-clear-top":
6068 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6069 break;
6070 case "--activity-clear-when-task-reset":
6071 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6072 break;
6073 case "--activity-exclude-from-recents":
6074 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6075 break;
6076 case "--activity-launched-from-history":
6077 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6078 break;
6079 case "--activity-multiple-task":
6080 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6081 break;
6082 case "--activity-no-animation":
6083 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6084 break;
6085 case "--activity-no-history":
6086 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6087 break;
6088 case "--activity-no-user-action":
6089 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6090 break;
6091 case "--activity-previous-is-top":
6092 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6093 break;
6094 case "--activity-reorder-to-front":
6095 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6096 break;
6097 case "--activity-reset-task-if-needed":
6098 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6099 break;
6100 case "--activity-single-top":
6101 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6102 break;
6103 case "--activity-clear-task":
6104 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6105 break;
6106 case "--activity-task-on-home":
6107 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6108 break;
6109 case "--receiver-registered-only":
6110 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6111 break;
6112 case "--receiver-replace-pending":
6113 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6114 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006115 case "--receiver-foreground":
6116 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6117 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006118 case "--receiver-no-abort":
6119 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6120 break;
6121 case "--receiver-include-background":
6122 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6123 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006124 case "--selector":
6125 intent.setDataAndType(data, type);
6126 intent = new Intent();
6127 break;
6128 default:
6129 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6130 // Okay, caller handled this option.
6131 } else {
6132 throw new IllegalArgumentException("Unknown option: " + opt);
6133 }
6134 break;
6135 }
6136 }
6137 intent.setDataAndType(data, type);
6138
6139 final boolean hasSelector = intent != baseIntent;
6140 if (hasSelector) {
6141 // A selector was specified; fix up.
6142 baseIntent.setSelector(intent);
6143 intent = baseIntent;
6144 }
6145
6146 String arg = cmd.getNextArg();
6147 baseIntent = null;
6148 if (arg == null) {
6149 if (hasSelector) {
6150 // If a selector has been specified, and no arguments
6151 // have been supplied for the main Intent, then we can
6152 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6153 // need to have a component name specified yet, the
6154 // selector will take care of that.
6155 baseIntent = new Intent(Intent.ACTION_MAIN);
6156 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6157 }
6158 } else if (arg.indexOf(':') >= 0) {
6159 // The argument is a URI. Fully parse it, and use that result
6160 // to fill in any data not specified so far.
6161 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6162 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6163 } else if (arg.indexOf('/') >= 0) {
6164 // The argument is a component name. Build an Intent to launch
6165 // it.
6166 baseIntent = new Intent(Intent.ACTION_MAIN);
6167 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6168 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6169 } else {
6170 // Assume the argument is a package name.
6171 baseIntent = new Intent(Intent.ACTION_MAIN);
6172 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6173 baseIntent.setPackage(arg);
6174 }
6175 if (baseIntent != null) {
6176 Bundle extras = intent.getExtras();
6177 intent.replaceExtras((Bundle)null);
6178 Bundle uriExtras = baseIntent.getExtras();
6179 baseIntent.replaceExtras((Bundle)null);
6180 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6181 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6182 for (String c : cats) {
6183 baseIntent.removeCategory(c);
6184 }
6185 }
6186 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6187 if (extras == null) {
6188 extras = uriExtras;
6189 } else if (uriExtras != null) {
6190 uriExtras.putAll(extras);
6191 extras = uriExtras;
6192 }
6193 intent.replaceExtras(extras);
6194 hasIntentInfo = true;
6195 }
6196
6197 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6198 return intent;
6199 }
6200
6201 /** @hide */
6202 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6203 final String[] lines = new String[] {
6204 "<INTENT> specifications include these flags and arguments:",
6205 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6206 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6207 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6208 " [--esn <EXTRA_KEY> ...]",
6209 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6210 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6211 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6212 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6213 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6214 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6215 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6216 " (mutiple extras passed as Integer[])",
6217 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6218 " (mutiple extras passed as List<Integer>)",
6219 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6220 " (mutiple extras passed as Long[])",
6221 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6222 " (mutiple extras passed as List<Long>)",
6223 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6224 " (mutiple extras passed as Float[])",
6225 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6226 " (mutiple extras passed as List<Float>)",
6227 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6228 " (mutiple extras passed as String[]; to embed a comma into a string,",
6229 " escape it using \"\\,\")",
6230 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6231 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6232 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006233 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006234 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6235 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6236 " [--debug-log-resolution] [--exclude-stopped-packages]",
6237 " [--include-stopped-packages]",
6238 " [--activity-brought-to-front] [--activity-clear-top]",
6239 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6240 " [--activity-launched-from-history] [--activity-multiple-task]",
6241 " [--activity-no-animation] [--activity-no-history]",
6242 " [--activity-no-user-action] [--activity-previous-is-top]",
6243 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6244 " [--activity-single-top] [--activity-clear-task]",
6245 " [--activity-task-on-home]",
6246 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006247 " [--receiver-foreground] [--receiver-no-abort]",
6248 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006249 " [--selector]",
6250 " [<URI> | <PACKAGE> | <COMPONENT>]"
6251 };
6252 for (String line : lines) {
6253 pw.print(prefix);
6254 pw.println(line);
6255 }
6256 }
6257
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006258 /**
6259 * Retrieve the general action to be performed, such as
6260 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6261 * the information in the intent should be interpreted -- most importantly,
6262 * what to do with the data returned by {@link #getData}.
6263 *
6264 * @return The action of this intent or null if none is specified.
6265 *
6266 * @see #setAction
6267 */
6268 public String getAction() {
6269 return mAction;
6270 }
6271
6272 /**
6273 * Retrieve data this intent is operating on. This URI specifies the name
6274 * of the data; often it uses the content: scheme, specifying data in a
6275 * content provider. Other schemes may be handled by specific activities,
6276 * such as http: by the web browser.
6277 *
6278 * @return The URI of the data this intent is targeting or null.
6279 *
6280 * @see #getScheme
6281 * @see #setData
6282 */
6283 public Uri getData() {
6284 return mData;
6285 }
6286
6287 /**
6288 * The same as {@link #getData()}, but returns the URI as an encoded
6289 * String.
6290 */
6291 public String getDataString() {
6292 return mData != null ? mData.toString() : null;
6293 }
6294
6295 /**
6296 * Return the scheme portion of the intent's data. If the data is null or
6297 * does not include a scheme, null is returned. Otherwise, the scheme
6298 * prefix without the final ':' is returned, i.e. "http".
6299 *
6300 * <p>This is the same as calling getData().getScheme() (and checking for
6301 * null data).
6302 *
6303 * @return The scheme of this intent.
6304 *
6305 * @see #getData
6306 */
6307 public String getScheme() {
6308 return mData != null ? mData.getScheme() : null;
6309 }
6310
6311 /**
6312 * Retrieve any explicit MIME type included in the intent. This is usually
6313 * null, as the type is determined by the intent data.
6314 *
6315 * @return If a type was manually set, it is returned; else null is
6316 * returned.
6317 *
6318 * @see #resolveType(ContentResolver)
6319 * @see #setType
6320 */
6321 public String getType() {
6322 return mType;
6323 }
6324
6325 /**
6326 * Return the MIME data type of this intent. If the type field is
6327 * explicitly set, that is simply returned. Otherwise, if the data is set,
6328 * the type of that data is returned. If neither fields are set, a null is
6329 * returned.
6330 *
6331 * @return The MIME type of this intent.
6332 *
6333 * @see #getType
6334 * @see #resolveType(ContentResolver)
6335 */
6336 public String resolveType(Context context) {
6337 return resolveType(context.getContentResolver());
6338 }
6339
6340 /**
6341 * Return the MIME data type of this intent. If the type field is
6342 * explicitly set, that is simply returned. Otherwise, if the data is set,
6343 * the type of that data is returned. If neither fields are set, a null is
6344 * returned.
6345 *
6346 * @param resolver A ContentResolver that can be used to determine the MIME
6347 * type of the intent's data.
6348 *
6349 * @return The MIME type of this intent.
6350 *
6351 * @see #getType
6352 * @see #resolveType(Context)
6353 */
6354 public String resolveType(ContentResolver resolver) {
6355 if (mType != null) {
6356 return mType;
6357 }
6358 if (mData != null) {
6359 if ("content".equals(mData.getScheme())) {
6360 return resolver.getType(mData);
6361 }
6362 }
6363 return null;
6364 }
6365
6366 /**
6367 * Return the MIME data type of this intent, only if it will be needed for
6368 * intent resolution. This is not generally useful for application code;
6369 * it is used by the frameworks for communicating with back-end system
6370 * services.
6371 *
6372 * @param resolver A ContentResolver that can be used to determine the MIME
6373 * type of the intent's data.
6374 *
6375 * @return The MIME type of this intent, or null if it is unknown or not
6376 * needed.
6377 */
6378 public String resolveTypeIfNeeded(ContentResolver resolver) {
6379 if (mComponent != null) {
6380 return mType;
6381 }
6382 return resolveType(resolver);
6383 }
6384
6385 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006386 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006387 *
6388 * @param category The category to check.
6389 *
6390 * @return boolean True if the intent contains the category, else false.
6391 *
6392 * @see #getCategories
6393 * @see #addCategory
6394 */
6395 public boolean hasCategory(String category) {
6396 return mCategories != null && mCategories.contains(category);
6397 }
6398
6399 /**
6400 * Return the set of all categories in the intent. If there are no categories,
6401 * returns NULL.
6402 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006403 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006404 *
6405 * @see #hasCategory
6406 * @see #addCategory
6407 */
6408 public Set<String> getCategories() {
6409 return mCategories;
6410 }
6411
6412 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006413 * Return the specific selector associated with this Intent. If there is
6414 * none, returns null. See {@link #setSelector} for more information.
6415 *
6416 * @see #setSelector
6417 */
6418 public Intent getSelector() {
6419 return mSelector;
6420 }
6421
6422 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006423 * Return the {@link ClipData} associated with this Intent. If there is
6424 * none, returns null. See {@link #setClipData} for more information.
6425 *
John Spurlock125d1332013-11-25 11:58:37 -05006426 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006427 */
6428 public ClipData getClipData() {
6429 return mClipData;
6430 }
6431
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006432 /** @hide */
6433 public int getContentUserHint() {
6434 return mContentUserHint;
6435 }
6436
Todd Kennedyb3b431302017-03-20 16:05:48 -07006437 /** @hide */
6438 public String getLaunchToken() {
6439 return mLaunchToken;
6440 }
6441
6442 /** @hide */
6443 public void setLaunchToken(String launchToken) {
6444 mLaunchToken = launchToken;
6445 }
6446
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006447 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006448 * Sets the ClassLoader that will be used when unmarshalling
6449 * any Parcelable values from the extras of this Intent.
6450 *
6451 * @param loader a ClassLoader, or null to use the default loader
6452 * at the time of unmarshalling.
6453 */
6454 public void setExtrasClassLoader(ClassLoader loader) {
6455 if (mExtras != null) {
6456 mExtras.setClassLoader(loader);
6457 }
6458 }
6459
6460 /**
6461 * Returns true if an extra value is associated with the given name.
6462 * @param name the extra's name
6463 * @return true if the given extra is present.
6464 */
6465 public boolean hasExtra(String name) {
6466 return mExtras != null && mExtras.containsKey(name);
6467 }
6468
6469 /**
6470 * Returns true if the Intent's extras contain a parcelled file descriptor.
6471 * @return true if the Intent contains a parcelled file descriptor.
6472 */
6473 public boolean hasFileDescriptors() {
6474 return mExtras != null && mExtras.hasFileDescriptors();
6475 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006476
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006477 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006478 public void setAllowFds(boolean allowFds) {
6479 if (mExtras != null) {
6480 mExtras.setAllowFds(allowFds);
6481 }
6482 }
6483
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006484 /** {@hide} */
6485 public void setDefusable(boolean defusable) {
6486 if (mExtras != null) {
6487 mExtras.setDefusable(defusable);
6488 }
6489 }
6490
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006491 /**
6492 * Retrieve extended data from the intent.
6493 *
6494 * @param name The name of the desired item.
6495 *
6496 * @return the value of an item that previously added with putExtra()
6497 * or null if none was found.
6498 *
6499 * @deprecated
6500 * @hide
6501 */
6502 @Deprecated
6503 public Object getExtra(String name) {
6504 return getExtra(name, null);
6505 }
6506
6507 /**
6508 * Retrieve extended data from the intent.
6509 *
6510 * @param name The name of the desired item.
6511 * @param defaultValue the value to be returned if no value of the desired
6512 * type is stored with the given name.
6513 *
6514 * @return the value of an item that previously added with putExtra()
6515 * or the default value if none was found.
6516 *
6517 * @see #putExtra(String, boolean)
6518 */
6519 public boolean getBooleanExtra(String name, boolean defaultValue) {
6520 return mExtras == null ? defaultValue :
6521 mExtras.getBoolean(name, defaultValue);
6522 }
6523
6524 /**
6525 * Retrieve extended data from the intent.
6526 *
6527 * @param name The name of the desired item.
6528 * @param defaultValue the value to be returned if no value of the desired
6529 * type is stored with the given name.
6530 *
6531 * @return the value of an item that previously added with putExtra()
6532 * or the default value if none was found.
6533 *
6534 * @see #putExtra(String, byte)
6535 */
6536 public byte getByteExtra(String name, byte defaultValue) {
6537 return mExtras == null ? defaultValue :
6538 mExtras.getByte(name, defaultValue);
6539 }
6540
6541 /**
6542 * Retrieve extended data from the intent.
6543 *
6544 * @param name The name of the desired item.
6545 * @param defaultValue the value to be returned if no value of the desired
6546 * type is stored with the given name.
6547 *
6548 * @return the value of an item that previously added with putExtra()
6549 * or the default value if none was found.
6550 *
6551 * @see #putExtra(String, short)
6552 */
6553 public short getShortExtra(String name, short defaultValue) {
6554 return mExtras == null ? defaultValue :
6555 mExtras.getShort(name, defaultValue);
6556 }
6557
6558 /**
6559 * Retrieve extended data from the intent.
6560 *
6561 * @param name The name of the desired item.
6562 * @param defaultValue the value to be returned if no value of the desired
6563 * type is stored with the given name.
6564 *
6565 * @return the value of an item that previously added with putExtra()
6566 * or the default value if none was found.
6567 *
6568 * @see #putExtra(String, char)
6569 */
6570 public char getCharExtra(String name, char defaultValue) {
6571 return mExtras == null ? defaultValue :
6572 mExtras.getChar(name, defaultValue);
6573 }
6574
6575 /**
6576 * Retrieve extended data from the intent.
6577 *
6578 * @param name The name of the desired item.
6579 * @param defaultValue the value to be returned if no value of the desired
6580 * type is stored with the given name.
6581 *
6582 * @return the value of an item that previously added with putExtra()
6583 * or the default value if none was found.
6584 *
6585 * @see #putExtra(String, int)
6586 */
6587 public int getIntExtra(String name, int defaultValue) {
6588 return mExtras == null ? defaultValue :
6589 mExtras.getInt(name, defaultValue);
6590 }
6591
6592 /**
6593 * Retrieve extended data from the intent.
6594 *
6595 * @param name The name of the desired item.
6596 * @param defaultValue the value to be returned if no value of the desired
6597 * type is stored with the given name.
6598 *
6599 * @return the value of an item that previously added with putExtra()
6600 * or the default value if none was found.
6601 *
6602 * @see #putExtra(String, long)
6603 */
6604 public long getLongExtra(String name, long defaultValue) {
6605 return mExtras == null ? defaultValue :
6606 mExtras.getLong(name, defaultValue);
6607 }
6608
6609 /**
6610 * Retrieve extended data from the intent.
6611 *
6612 * @param name The name of the desired item.
6613 * @param defaultValue the value to be returned if no value of the desired
6614 * type is stored with the given name.
6615 *
6616 * @return the value of an item that previously added with putExtra(),
6617 * or the default value if no such item is present
6618 *
6619 * @see #putExtra(String, float)
6620 */
6621 public float getFloatExtra(String name, float defaultValue) {
6622 return mExtras == null ? defaultValue :
6623 mExtras.getFloat(name, defaultValue);
6624 }
6625
6626 /**
6627 * Retrieve extended data from the intent.
6628 *
6629 * @param name The name of the desired item.
6630 * @param defaultValue the value to be returned if no value of the desired
6631 * type is stored with the given name.
6632 *
6633 * @return the value of an item that previously added with putExtra()
6634 * or the default value if none was found.
6635 *
6636 * @see #putExtra(String, double)
6637 */
6638 public double getDoubleExtra(String name, double defaultValue) {
6639 return mExtras == null ? defaultValue :
6640 mExtras.getDouble(name, defaultValue);
6641 }
6642
6643 /**
6644 * Retrieve extended data from the intent.
6645 *
6646 * @param name The name of the desired item.
6647 *
6648 * @return the value of an item that previously added with putExtra()
6649 * or null if no String value was found.
6650 *
6651 * @see #putExtra(String, String)
6652 */
6653 public String getStringExtra(String name) {
6654 return mExtras == null ? null : mExtras.getString(name);
6655 }
6656
6657 /**
6658 * Retrieve extended data from the intent.
6659 *
6660 * @param name The name of the desired item.
6661 *
6662 * @return the value of an item that previously added with putExtra()
6663 * or null if no CharSequence value was found.
6664 *
6665 * @see #putExtra(String, CharSequence)
6666 */
6667 public CharSequence getCharSequenceExtra(String name) {
6668 return mExtras == null ? null : mExtras.getCharSequence(name);
6669 }
6670
6671 /**
6672 * Retrieve extended data from the intent.
6673 *
6674 * @param name The name of the desired item.
6675 *
6676 * @return the value of an item that previously added with putExtra()
6677 * or null if no Parcelable value was found.
6678 *
6679 * @see #putExtra(String, Parcelable)
6680 */
6681 public <T extends Parcelable> T getParcelableExtra(String name) {
6682 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6683 }
6684
6685 /**
6686 * Retrieve extended data from the intent.
6687 *
6688 * @param name The name of the desired item.
6689 *
6690 * @return the value of an item that previously added with putExtra()
6691 * or null if no Parcelable[] value was found.
6692 *
6693 * @see #putExtra(String, Parcelable[])
6694 */
6695 public Parcelable[] getParcelableArrayExtra(String name) {
6696 return mExtras == null ? null : mExtras.getParcelableArray(name);
6697 }
6698
6699 /**
6700 * Retrieve extended data from the intent.
6701 *
6702 * @param name The name of the desired item.
6703 *
6704 * @return the value of an item that previously added with putExtra()
6705 * or null if no ArrayList<Parcelable> value was found.
6706 *
6707 * @see #putParcelableArrayListExtra(String, ArrayList)
6708 */
6709 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6710 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6711 }
6712
6713 /**
6714 * Retrieve extended data from the intent.
6715 *
6716 * @param name The name of the desired item.
6717 *
6718 * @return the value of an item that previously added with putExtra()
6719 * or null if no Serializable value was found.
6720 *
6721 * @see #putExtra(String, Serializable)
6722 */
6723 public Serializable getSerializableExtra(String name) {
6724 return mExtras == null ? null : mExtras.getSerializable(name);
6725 }
6726
6727 /**
6728 * Retrieve extended data from the intent.
6729 *
6730 * @param name The name of the desired item.
6731 *
6732 * @return the value of an item that previously added with putExtra()
6733 * or null if no ArrayList<Integer> value was found.
6734 *
6735 * @see #putIntegerArrayListExtra(String, ArrayList)
6736 */
6737 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6738 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6739 }
6740
6741 /**
6742 * Retrieve extended data from the intent.
6743 *
6744 * @param name The name of the desired item.
6745 *
6746 * @return the value of an item that previously added with putExtra()
6747 * or null if no ArrayList<String> value was found.
6748 *
6749 * @see #putStringArrayListExtra(String, ArrayList)
6750 */
6751 public ArrayList<String> getStringArrayListExtra(String name) {
6752 return mExtras == null ? null : mExtras.getStringArrayList(name);
6753 }
6754
6755 /**
6756 * Retrieve extended data from the intent.
6757 *
6758 * @param name The name of the desired item.
6759 *
6760 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006761 * or null if no ArrayList<CharSequence> value was found.
6762 *
6763 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6764 */
6765 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6766 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6767 }
6768
6769 /**
6770 * Retrieve extended data from the intent.
6771 *
6772 * @param name The name of the desired item.
6773 *
6774 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006775 * or null if no boolean array value was found.
6776 *
6777 * @see #putExtra(String, boolean[])
6778 */
6779 public boolean[] getBooleanArrayExtra(String name) {
6780 return mExtras == null ? null : mExtras.getBooleanArray(name);
6781 }
6782
6783 /**
6784 * Retrieve extended data from the intent.
6785 *
6786 * @param name The name of the desired item.
6787 *
6788 * @return the value of an item that previously added with putExtra()
6789 * or null if no byte array value was found.
6790 *
6791 * @see #putExtra(String, byte[])
6792 */
6793 public byte[] getByteArrayExtra(String name) {
6794 return mExtras == null ? null : mExtras.getByteArray(name);
6795 }
6796
6797 /**
6798 * Retrieve extended data from the intent.
6799 *
6800 * @param name The name of the desired item.
6801 *
6802 * @return the value of an item that previously added with putExtra()
6803 * or null if no short array value was found.
6804 *
6805 * @see #putExtra(String, short[])
6806 */
6807 public short[] getShortArrayExtra(String name) {
6808 return mExtras == null ? null : mExtras.getShortArray(name);
6809 }
6810
6811 /**
6812 * Retrieve extended data from the intent.
6813 *
6814 * @param name The name of the desired item.
6815 *
6816 * @return the value of an item that previously added with putExtra()
6817 * or null if no char array value was found.
6818 *
6819 * @see #putExtra(String, char[])
6820 */
6821 public char[] getCharArrayExtra(String name) {
6822 return mExtras == null ? null : mExtras.getCharArray(name);
6823 }
6824
6825 /**
6826 * Retrieve extended data from the intent.
6827 *
6828 * @param name The name of the desired item.
6829 *
6830 * @return the value of an item that previously added with putExtra()
6831 * or null if no int array value was found.
6832 *
6833 * @see #putExtra(String, int[])
6834 */
6835 public int[] getIntArrayExtra(String name) {
6836 return mExtras == null ? null : mExtras.getIntArray(name);
6837 }
6838
6839 /**
6840 * Retrieve extended data from the intent.
6841 *
6842 * @param name The name of the desired item.
6843 *
6844 * @return the value of an item that previously added with putExtra()
6845 * or null if no long array value was found.
6846 *
6847 * @see #putExtra(String, long[])
6848 */
6849 public long[] getLongArrayExtra(String name) {
6850 return mExtras == null ? null : mExtras.getLongArray(name);
6851 }
6852
6853 /**
6854 * Retrieve extended data from the intent.
6855 *
6856 * @param name The name of the desired item.
6857 *
6858 * @return the value of an item that previously added with putExtra()
6859 * or null if no float array value was found.
6860 *
6861 * @see #putExtra(String, float[])
6862 */
6863 public float[] getFloatArrayExtra(String name) {
6864 return mExtras == null ? null : mExtras.getFloatArray(name);
6865 }
6866
6867 /**
6868 * Retrieve extended data from the intent.
6869 *
6870 * @param name The name of the desired item.
6871 *
6872 * @return the value of an item that previously added with putExtra()
6873 * or null if no double array value was found.
6874 *
6875 * @see #putExtra(String, double[])
6876 */
6877 public double[] getDoubleArrayExtra(String name) {
6878 return mExtras == null ? null : mExtras.getDoubleArray(name);
6879 }
6880
6881 /**
6882 * Retrieve extended data from the intent.
6883 *
6884 * @param name The name of the desired item.
6885 *
6886 * @return the value of an item that previously added with putExtra()
6887 * or null if no String array value was found.
6888 *
6889 * @see #putExtra(String, String[])
6890 */
6891 public String[] getStringArrayExtra(String name) {
6892 return mExtras == null ? null : mExtras.getStringArray(name);
6893 }
6894
6895 /**
6896 * Retrieve extended data from the intent.
6897 *
6898 * @param name The name of the desired item.
6899 *
6900 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006901 * or null if no CharSequence array value was found.
6902 *
6903 * @see #putExtra(String, CharSequence[])
6904 */
6905 public CharSequence[] getCharSequenceArrayExtra(String name) {
6906 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6907 }
6908
6909 /**
6910 * Retrieve extended data from the intent.
6911 *
6912 * @param name The name of the desired item.
6913 *
6914 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006915 * or null if no Bundle value was found.
6916 *
6917 * @see #putExtra(String, Bundle)
6918 */
6919 public Bundle getBundleExtra(String name) {
6920 return mExtras == null ? null : mExtras.getBundle(name);
6921 }
6922
6923 /**
6924 * Retrieve extended data from the intent.
6925 *
6926 * @param name The name of the desired item.
6927 *
6928 * @return the value of an item that previously added with putExtra()
6929 * or null if no IBinder value was found.
6930 *
6931 * @see #putExtra(String, IBinder)
6932 *
6933 * @deprecated
6934 * @hide
6935 */
6936 @Deprecated
6937 public IBinder getIBinderExtra(String name) {
6938 return mExtras == null ? null : mExtras.getIBinder(name);
6939 }
6940
6941 /**
6942 * Retrieve extended data from the intent.
6943 *
6944 * @param name The name of the desired item.
6945 * @param defaultValue The default value to return in case no item is
6946 * associated with the key 'name'
6947 *
6948 * @return the value of an item that previously added with putExtra()
6949 * or defaultValue if none was found.
6950 *
6951 * @see #putExtra
6952 *
6953 * @deprecated
6954 * @hide
6955 */
6956 @Deprecated
6957 public Object getExtra(String name, Object defaultValue) {
6958 Object result = defaultValue;
6959 if (mExtras != null) {
6960 Object result2 = mExtras.get(name);
6961 if (result2 != null) {
6962 result = result2;
6963 }
6964 }
6965
6966 return result;
6967 }
6968
6969 /**
6970 * Retrieves a map of extended data from the intent.
6971 *
6972 * @return the map of all extras previously added with putExtra(),
6973 * or null if none have been added.
6974 */
6975 public Bundle getExtras() {
6976 return (mExtras != null)
6977 ? new Bundle(mExtras)
6978 : null;
6979 }
6980
6981 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006982 * Filter extras to only basic types.
6983 * @hide
6984 */
6985 public void removeUnsafeExtras() {
6986 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006987 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006988 }
6989 }
6990
6991 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006992 * Retrieve any special flags associated with this intent. You will
6993 * normally just set them with {@link #setFlags} and let the system
6994 * take the appropriate action with them.
6995 *
6996 * @return int The currently set flags.
6997 *
6998 * @see #setFlags
6999 */
7000 public int getFlags() {
7001 return mFlags;
7002 }
7003
Dianne Hackborne7f97212011-02-24 14:40:20 -08007004 /** @hide */
7005 public boolean isExcludingStopped() {
7006 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7007 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7008 }
7009
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007010 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007011 * Retrieve the application package name this Intent is limited to. When
7012 * resolving an Intent, if non-null this limits the resolution to only
7013 * components in the given application package.
7014 *
7015 * @return The name of the application package for the Intent.
7016 *
7017 * @see #resolveActivity
7018 * @see #setPackage
7019 */
7020 public String getPackage() {
7021 return mPackage;
7022 }
7023
7024 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007025 * Retrieve the concrete component associated with the intent. When receiving
7026 * an intent, this is the component that was found to best handle it (that is,
7027 * yourself) and will always be non-null; in all other cases it will be
7028 * null unless explicitly set.
7029 *
7030 * @return The name of the application component to handle the intent.
7031 *
7032 * @see #resolveActivity
7033 * @see #setComponent
7034 */
7035 public ComponentName getComponent() {
7036 return mComponent;
7037 }
7038
7039 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007040 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7041 * used as a hint to the receiver for animations and the like. Null means that there
7042 * is no source bounds.
7043 */
7044 public Rect getSourceBounds() {
7045 return mSourceBounds;
7046 }
7047
7048 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007049 * Return the Activity component that should be used to handle this intent.
7050 * The appropriate component is determined based on the information in the
7051 * intent, evaluated as follows:
7052 *
7053 * <p>If {@link #getComponent} returns an explicit class, that is returned
7054 * without any further consideration.
7055 *
7056 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7057 * category to be considered.
7058 *
7059 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7060 * action.
7061 *
7062 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7063 * this type.
7064 *
7065 * <p>If {@link #addCategory} has added any categories, the activity must
7066 * handle ALL of the categories specified.
7067 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007068 * <p>If {@link #getPackage} is non-NULL, only activity components in
7069 * that application package will be considered.
7070 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007071 * <p>If there are no activities that satisfy all of these conditions, a
7072 * null string is returned.
7073 *
7074 * <p>If multiple activities are found to satisfy the intent, the one with
7075 * the highest priority will be used. If there are multiple activities
7076 * with the same priority, the system will either pick the best activity
7077 * based on user preference, or resolve to a system class that will allow
7078 * the user to pick an activity and forward from there.
7079 *
7080 * <p>This method is implemented simply by calling
7081 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7082 * true.</p>
7083 * <p> This API is called for you as part of starting an activity from an
7084 * intent. You do not normally need to call it yourself.</p>
7085 *
7086 * @param pm The package manager with which to resolve the Intent.
7087 *
7088 * @return Name of the component implementing an activity that can
7089 * display the intent.
7090 *
7091 * @see #setComponent
7092 * @see #getComponent
7093 * @see #resolveActivityInfo
7094 */
7095 public ComponentName resolveActivity(PackageManager pm) {
7096 if (mComponent != null) {
7097 return mComponent;
7098 }
7099
7100 ResolveInfo info = pm.resolveActivity(
7101 this, PackageManager.MATCH_DEFAULT_ONLY);
7102 if (info != null) {
7103 return new ComponentName(
7104 info.activityInfo.applicationInfo.packageName,
7105 info.activityInfo.name);
7106 }
7107
7108 return null;
7109 }
7110
7111 /**
7112 * Resolve the Intent into an {@link ActivityInfo}
7113 * describing the activity that should execute the intent. Resolution
7114 * follows the same rules as described for {@link #resolveActivity}, but
7115 * you get back the completely information about the resolved activity
7116 * instead of just its class name.
7117 *
7118 * @param pm The package manager with which to resolve the Intent.
7119 * @param flags Addition information to retrieve as per
7120 * {@link PackageManager#getActivityInfo(ComponentName, int)
7121 * PackageManager.getActivityInfo()}.
7122 *
7123 * @return PackageManager.ActivityInfo
7124 *
7125 * @see #resolveActivity
7126 */
7127 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7128 ActivityInfo ai = null;
7129 if (mComponent != null) {
7130 try {
7131 ai = pm.getActivityInfo(mComponent, flags);
7132 } catch (PackageManager.NameNotFoundException e) {
7133 // ignore
7134 }
7135 } else {
7136 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007137 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007138 if (info != null) {
7139 ai = info.activityInfo;
7140 }
7141 }
7142
7143 return ai;
7144 }
7145
7146 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007147 * Special function for use by the system to resolve service
7148 * intents to system apps. Throws an exception if there are
7149 * multiple potential matches to the Intent. Returns null if
7150 * there are no matches.
7151 * @hide
7152 */
7153 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7154 if (mComponent != null) {
7155 return mComponent;
7156 }
7157
7158 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7159 if (results == null) {
7160 return null;
7161 }
7162 ComponentName comp = null;
7163 for (int i=0; i<results.size(); i++) {
7164 ResolveInfo ri = results.get(i);
7165 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7166 continue;
7167 }
7168 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7169 ri.serviceInfo.name);
7170 if (comp != null) {
7171 throw new IllegalStateException("Multiple system services handle " + this
7172 + ": " + comp + ", " + foundComp);
7173 }
7174 comp = foundComp;
7175 }
7176 return comp;
7177 }
7178
7179 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007180 * Set the general action to be performed.
7181 *
7182 * @param action An action name, such as ACTION_VIEW. Application-specific
7183 * actions should be prefixed with the vendor's package name.
7184 *
7185 * @return Returns the same Intent object, for chaining multiple calls
7186 * into a single statement.
7187 *
7188 * @see #getAction
7189 */
7190 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007191 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007192 return this;
7193 }
7194
7195 /**
7196 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007197 * clears any type that was previously set by {@link #setType} or
7198 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007199 *
Nick Pellyccae4122012-01-09 14:12:58 -08007200 * <p><em>Note: scheme matching in the Android framework is
7201 * case-sensitive, unlike the formal RFC. As a result,
7202 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007203 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007204 * {@link #setDataAndNormalize}
7205 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007206 *
Nick Pellyccae4122012-01-09 14:12:58 -08007207 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007208 *
7209 * @return Returns the same Intent object, for chaining multiple calls
7210 * into a single statement.
7211 *
7212 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007213 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007214 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007215 */
7216 public Intent setData(Uri data) {
7217 mData = data;
7218 mType = null;
7219 return this;
7220 }
7221
7222 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007223 * Normalize and set the data this intent is operating on.
7224 *
7225 * <p>This method automatically clears any type that was
7226 * previously set (for example, by {@link #setType}).
7227 *
7228 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007229 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007230 * so really this is just a convenience method for
7231 * <pre>
7232 * setData(data.normalize())
7233 * </pre>
7234 *
7235 * @param data The Uri of the data this intent is now targeting.
7236 *
7237 * @return Returns the same Intent object, for chaining multiple calls
7238 * into a single statement.
7239 *
7240 * @see #getData
7241 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007242 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007243 */
7244 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007245 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007246 }
7247
7248 /**
7249 * Set an explicit MIME data type.
7250 *
7251 * <p>This is used to create intents that only specify a type and not data,
7252 * for example to indicate the type of data to return.
7253 *
7254 * <p>This method automatically clears any data that was
7255 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007256 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007257 * <p><em>Note: MIME type matching in the Android framework is
7258 * case-sensitive, unlike formal RFC MIME types. As a result,
7259 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007260 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7261 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007262 *
7263 * @param type The MIME type of the data being handled by this intent.
7264 *
7265 * @return Returns the same Intent object, for chaining multiple calls
7266 * into a single statement.
7267 *
7268 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007269 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007270 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007271 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007272 */
7273 public Intent setType(String type) {
7274 mData = null;
7275 mType = type;
7276 return this;
7277 }
7278
7279 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007280 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007281 *
Nick Pellyccae4122012-01-09 14:12:58 -08007282 * <p>This is used to create intents that only specify a type and not data,
7283 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007284 *
Nick Pellyccae4122012-01-09 14:12:58 -08007285 * <p>This method automatically clears any data that was
7286 * previously set (for example by {@link #setData}).
7287 *
7288 * <p>The MIME type is normalized using
7289 * {@link #normalizeMimeType} before it is set,
7290 * so really this is just a convenience method for
7291 * <pre>
7292 * setType(Intent.normalizeMimeType(type))
7293 * </pre>
7294 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007295 * @param type The MIME type of the data being handled by this intent.
7296 *
7297 * @return Returns the same Intent object, for chaining multiple calls
7298 * into a single statement.
7299 *
Nick Pellyccae4122012-01-09 14:12:58 -08007300 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007301 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007302 * @see #normalizeMimeType
7303 */
7304 public Intent setTypeAndNormalize(String type) {
7305 return setType(normalizeMimeType(type));
7306 }
7307
7308 /**
7309 * (Usually optional) Set the data for the intent along with an explicit
7310 * MIME data type. This method should very rarely be used -- it allows you
7311 * to override the MIME type that would ordinarily be inferred from the
7312 * data with your own type given here.
7313 *
7314 * <p><em>Note: MIME type and Uri scheme matching in the
7315 * Android framework is case-sensitive, unlike the formal RFC definitions.
7316 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007317 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007318 * {@link #setDataAndTypeAndNormalize}
7319 * to ensure that they are converted to lower case.</em>
7320 *
7321 * @param data The Uri of the data this intent is now targeting.
7322 * @param type The MIME type of the data being handled by this intent.
7323 *
7324 * @return Returns the same Intent object, for chaining multiple calls
7325 * into a single statement.
7326 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007327 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007328 * @see #setData
7329 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007330 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007331 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007332 */
7333 public Intent setDataAndType(Uri data, String type) {
7334 mData = data;
7335 mType = type;
7336 return this;
7337 }
7338
7339 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007340 * (Usually optional) Normalize and set both the data Uri and an explicit
7341 * MIME data type. This method should very rarely be used -- it allows you
7342 * to override the MIME type that would ordinarily be inferred from the
7343 * data with your own type given here.
7344 *
7345 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007346 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007347 * before they are set, so really this is just a convenience method for
7348 * <pre>
7349 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7350 * </pre>
7351 *
7352 * @param data The Uri of the data this intent is now targeting.
7353 * @param type The MIME type of the data being handled by this intent.
7354 *
7355 * @return Returns the same Intent object, for chaining multiple calls
7356 * into a single statement.
7357 *
7358 * @see #setType
7359 * @see #setData
7360 * @see #setDataAndType
7361 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007362 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007363 */
7364 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007365 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007366 }
7367
7368 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007369 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007370 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007371 * activities that provide <em>all</em> of the requested categories will be
7372 * used.
7373 *
7374 * @param category The desired category. This can be either one of the
7375 * predefined Intent categories, or a custom category in your own
7376 * namespace.
7377 *
7378 * @return Returns the same Intent object, for chaining multiple calls
7379 * into a single statement.
7380 *
7381 * @see #hasCategory
7382 * @see #removeCategory
7383 */
7384 public Intent addCategory(String category) {
7385 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007386 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007387 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007388 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007389 return this;
7390 }
7391
7392 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007393 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007394 *
7395 * @param category The category to remove.
7396 *
7397 * @see #addCategory
7398 */
7399 public void removeCategory(String category) {
7400 if (mCategories != null) {
7401 mCategories.remove(category);
7402 if (mCategories.size() == 0) {
7403 mCategories = null;
7404 }
7405 }
7406 }
7407
7408 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007409 * Set a selector for this Intent. This is a modification to the kinds of
7410 * things the Intent will match. If the selector is set, it will be used
7411 * when trying to find entities that can handle the Intent, instead of the
7412 * main contents of the Intent. This allows you build an Intent containing
7413 * a generic protocol while targeting it more specifically.
7414 *
7415 * <p>An example of where this may be used is with things like
7416 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7417 * Intent that will launch the Browser application. However, the correct
7418 * main entry point of an application is actually {@link #ACTION_MAIN}
7419 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7420 * used to specify the actual Activity to launch. If you launch the browser
7421 * with something different, undesired behavior may happen if the user has
7422 * previously or later launches it the normal way, since they do not match.
7423 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7424 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7425 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7426 *
7427 * <p>Setting a selector does not impact the behavior of
7428 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7429 * desired behavior of a selector -- it does not impact the base meaning
7430 * of the Intent, just what kinds of things will be matched against it
7431 * when determining who can handle it.</p>
7432 *
7433 * <p>You can not use both a selector and {@link #setPackage(String)} on
7434 * the same base Intent.</p>
7435 *
7436 * @param selector The desired selector Intent; set to null to not use
7437 * a special selector.
7438 */
7439 public void setSelector(Intent selector) {
7440 if (selector == this) {
7441 throw new IllegalArgumentException(
7442 "Intent being set as a selector of itself");
7443 }
7444 if (selector != null && mPackage != null) {
7445 throw new IllegalArgumentException(
7446 "Can't set selector when package name is already set");
7447 }
7448 mSelector = selector;
7449 }
7450
7451 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007452 * Set a {@link ClipData} associated with this Intent. This replaces any
7453 * previously set ClipData.
7454 *
7455 * <p>The ClipData in an intent is not used for Intent matching or other
7456 * such operations. Semantically it is like extras, used to transmit
7457 * additional data with the Intent. The main feature of using this over
7458 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7459 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7460 * items included in the clip data. This is useful, in particular, if
7461 * you want to transmit an Intent containing multiple <code>content:</code>
7462 * URIs for which the recipient may not have global permission to access the
7463 * content provider.
7464 *
7465 * <p>If the ClipData contains items that are themselves Intents, any
7466 * grant flags in those Intents will be ignored. Only the top-level flags
7467 * of the main Intent are respected, and will be applied to all Uri or
7468 * Intent items in the clip (or sub-items of the clip).
7469 *
7470 * <p>The MIME type, label, and icon in the ClipData object are not
7471 * directly used by Intent. Applications should generally rely on the
7472 * MIME type of the Intent itself, not what it may find in the ClipData.
7473 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007474 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007475 *
7476 * @param clip The new clip to set. May be null to clear the current clip.
7477 */
7478 public void setClipData(ClipData clip) {
7479 mClipData = clip;
7480 }
7481
7482 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007483 * This is NOT a secure mechanism to identify the user who sent the intent.
7484 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7485 * who sent the intent.
7486 * @hide
7487 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007488 public void prepareToLeaveUser(int userId) {
7489 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7490 // We want mContentUserHint to refer to the original user, so don't do anything.
7491 if (mContentUserHint == UserHandle.USER_CURRENT) {
7492 mContentUserHint = userId;
7493 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007494 }
7495
7496 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007497 * Add extended data to the intent. The name must include a package
7498 * prefix, for example the app com.android.contacts would use names
7499 * like "com.android.contacts.ShowAll".
7500 *
7501 * @param name The name of the extra data, with package prefix.
7502 * @param value The boolean data value.
7503 *
7504 * @return Returns the same Intent object, for chaining multiple calls
7505 * into a single statement.
7506 *
7507 * @see #putExtras
7508 * @see #removeExtra
7509 * @see #getBooleanExtra(String, boolean)
7510 */
7511 public Intent putExtra(String name, boolean value) {
7512 if (mExtras == null) {
7513 mExtras = new Bundle();
7514 }
7515 mExtras.putBoolean(name, value);
7516 return this;
7517 }
7518
7519 /**
7520 * Add extended data to the intent. The name must include a package
7521 * prefix, for example the app com.android.contacts would use names
7522 * like "com.android.contacts.ShowAll".
7523 *
7524 * @param name The name of the extra data, with package prefix.
7525 * @param value The byte data value.
7526 *
7527 * @return Returns the same Intent object, for chaining multiple calls
7528 * into a single statement.
7529 *
7530 * @see #putExtras
7531 * @see #removeExtra
7532 * @see #getByteExtra(String, byte)
7533 */
7534 public Intent putExtra(String name, byte value) {
7535 if (mExtras == null) {
7536 mExtras = new Bundle();
7537 }
7538 mExtras.putByte(name, value);
7539 return this;
7540 }
7541
7542 /**
7543 * Add extended data to the intent. The name must include a package
7544 * prefix, for example the app com.android.contacts would use names
7545 * like "com.android.contacts.ShowAll".
7546 *
7547 * @param name The name of the extra data, with package prefix.
7548 * @param value The char data value.
7549 *
7550 * @return Returns the same Intent object, for chaining multiple calls
7551 * into a single statement.
7552 *
7553 * @see #putExtras
7554 * @see #removeExtra
7555 * @see #getCharExtra(String, char)
7556 */
7557 public Intent putExtra(String name, char value) {
7558 if (mExtras == null) {
7559 mExtras = new Bundle();
7560 }
7561 mExtras.putChar(name, value);
7562 return this;
7563 }
7564
7565 /**
7566 * Add extended data to the intent. The name must include a package
7567 * prefix, for example the app com.android.contacts would use names
7568 * like "com.android.contacts.ShowAll".
7569 *
7570 * @param name The name of the extra data, with package prefix.
7571 * @param value The short data value.
7572 *
7573 * @return Returns the same Intent object, for chaining multiple calls
7574 * into a single statement.
7575 *
7576 * @see #putExtras
7577 * @see #removeExtra
7578 * @see #getShortExtra(String, short)
7579 */
7580 public Intent putExtra(String name, short value) {
7581 if (mExtras == null) {
7582 mExtras = new Bundle();
7583 }
7584 mExtras.putShort(name, value);
7585 return this;
7586 }
7587
7588 /**
7589 * Add extended data to the intent. The name must include a package
7590 * prefix, for example the app com.android.contacts would use names
7591 * like "com.android.contacts.ShowAll".
7592 *
7593 * @param name The name of the extra data, with package prefix.
7594 * @param value The integer data value.
7595 *
7596 * @return Returns the same Intent object, for chaining multiple calls
7597 * into a single statement.
7598 *
7599 * @see #putExtras
7600 * @see #removeExtra
7601 * @see #getIntExtra(String, int)
7602 */
7603 public Intent putExtra(String name, int value) {
7604 if (mExtras == null) {
7605 mExtras = new Bundle();
7606 }
7607 mExtras.putInt(name, value);
7608 return this;
7609 }
7610
7611 /**
7612 * Add extended data to the intent. The name must include a package
7613 * prefix, for example the app com.android.contacts would use names
7614 * like "com.android.contacts.ShowAll".
7615 *
7616 * @param name The name of the extra data, with package prefix.
7617 * @param value The long data value.
7618 *
7619 * @return Returns the same Intent object, for chaining multiple calls
7620 * into a single statement.
7621 *
7622 * @see #putExtras
7623 * @see #removeExtra
7624 * @see #getLongExtra(String, long)
7625 */
7626 public Intent putExtra(String name, long value) {
7627 if (mExtras == null) {
7628 mExtras = new Bundle();
7629 }
7630 mExtras.putLong(name, value);
7631 return this;
7632 }
7633
7634 /**
7635 * Add extended data to the intent. The name must include a package
7636 * prefix, for example the app com.android.contacts would use names
7637 * like "com.android.contacts.ShowAll".
7638 *
7639 * @param name The name of the extra data, with package prefix.
7640 * @param value The float data value.
7641 *
7642 * @return Returns the same Intent object, for chaining multiple calls
7643 * into a single statement.
7644 *
7645 * @see #putExtras
7646 * @see #removeExtra
7647 * @see #getFloatExtra(String, float)
7648 */
7649 public Intent putExtra(String name, float value) {
7650 if (mExtras == null) {
7651 mExtras = new Bundle();
7652 }
7653 mExtras.putFloat(name, value);
7654 return this;
7655 }
7656
7657 /**
7658 * Add extended data to the intent. The name must include a package
7659 * prefix, for example the app com.android.contacts would use names
7660 * like "com.android.contacts.ShowAll".
7661 *
7662 * @param name The name of the extra data, with package prefix.
7663 * @param value The double data value.
7664 *
7665 * @return Returns the same Intent object, for chaining multiple calls
7666 * into a single statement.
7667 *
7668 * @see #putExtras
7669 * @see #removeExtra
7670 * @see #getDoubleExtra(String, double)
7671 */
7672 public Intent putExtra(String name, double value) {
7673 if (mExtras == null) {
7674 mExtras = new Bundle();
7675 }
7676 mExtras.putDouble(name, value);
7677 return this;
7678 }
7679
7680 /**
7681 * Add extended data to the intent. The name must include a package
7682 * prefix, for example the app com.android.contacts would use names
7683 * like "com.android.contacts.ShowAll".
7684 *
7685 * @param name The name of the extra data, with package prefix.
7686 * @param value The String data value.
7687 *
7688 * @return Returns the same Intent object, for chaining multiple calls
7689 * into a single statement.
7690 *
7691 * @see #putExtras
7692 * @see #removeExtra
7693 * @see #getStringExtra(String)
7694 */
7695 public Intent putExtra(String name, String value) {
7696 if (mExtras == null) {
7697 mExtras = new Bundle();
7698 }
7699 mExtras.putString(name, value);
7700 return this;
7701 }
7702
7703 /**
7704 * Add extended data to the intent. The name must include a package
7705 * prefix, for example the app com.android.contacts would use names
7706 * like "com.android.contacts.ShowAll".
7707 *
7708 * @param name The name of the extra data, with package prefix.
7709 * @param value The CharSequence data value.
7710 *
7711 * @return Returns the same Intent object, for chaining multiple calls
7712 * into a single statement.
7713 *
7714 * @see #putExtras
7715 * @see #removeExtra
7716 * @see #getCharSequenceExtra(String)
7717 */
7718 public Intent putExtra(String name, CharSequence value) {
7719 if (mExtras == null) {
7720 mExtras = new Bundle();
7721 }
7722 mExtras.putCharSequence(name, value);
7723 return this;
7724 }
7725
7726 /**
7727 * Add extended data to the intent. The name must include a package
7728 * prefix, for example the app com.android.contacts would use names
7729 * like "com.android.contacts.ShowAll".
7730 *
7731 * @param name The name of the extra data, with package prefix.
7732 * @param value The Parcelable data value.
7733 *
7734 * @return Returns the same Intent object, for chaining multiple calls
7735 * into a single statement.
7736 *
7737 * @see #putExtras
7738 * @see #removeExtra
7739 * @see #getParcelableExtra(String)
7740 */
7741 public Intent putExtra(String name, Parcelable value) {
7742 if (mExtras == null) {
7743 mExtras = new Bundle();
7744 }
7745 mExtras.putParcelable(name, value);
7746 return this;
7747 }
7748
7749 /**
7750 * Add extended data to the intent. The name must include a package
7751 * prefix, for example the app com.android.contacts would use names
7752 * like "com.android.contacts.ShowAll".
7753 *
7754 * @param name The name of the extra data, with package prefix.
7755 * @param value The Parcelable[] data value.
7756 *
7757 * @return Returns the same Intent object, for chaining multiple calls
7758 * into a single statement.
7759 *
7760 * @see #putExtras
7761 * @see #removeExtra
7762 * @see #getParcelableArrayExtra(String)
7763 */
7764 public Intent putExtra(String name, Parcelable[] value) {
7765 if (mExtras == null) {
7766 mExtras = new Bundle();
7767 }
7768 mExtras.putParcelableArray(name, value);
7769 return this;
7770 }
7771
7772 /**
7773 * Add extended data to the intent. The name must include a package
7774 * prefix, for example the app com.android.contacts would use names
7775 * like "com.android.contacts.ShowAll".
7776 *
7777 * @param name The name of the extra data, with package prefix.
7778 * @param value The ArrayList<Parcelable> data value.
7779 *
7780 * @return Returns the same Intent object, for chaining multiple calls
7781 * into a single statement.
7782 *
7783 * @see #putExtras
7784 * @see #removeExtra
7785 * @see #getParcelableArrayListExtra(String)
7786 */
7787 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7788 if (mExtras == null) {
7789 mExtras = new Bundle();
7790 }
7791 mExtras.putParcelableArrayList(name, value);
7792 return this;
7793 }
7794
7795 /**
7796 * Add extended data to the intent. The name must include a package
7797 * prefix, for example the app com.android.contacts would use names
7798 * like "com.android.contacts.ShowAll".
7799 *
7800 * @param name The name of the extra data, with package prefix.
7801 * @param value The ArrayList<Integer> data value.
7802 *
7803 * @return Returns the same Intent object, for chaining multiple calls
7804 * into a single statement.
7805 *
7806 * @see #putExtras
7807 * @see #removeExtra
7808 * @see #getIntegerArrayListExtra(String)
7809 */
7810 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7811 if (mExtras == null) {
7812 mExtras = new Bundle();
7813 }
7814 mExtras.putIntegerArrayList(name, value);
7815 return this;
7816 }
7817
7818 /**
7819 * Add extended data to the intent. The name must include a package
7820 * prefix, for example the app com.android.contacts would use names
7821 * like "com.android.contacts.ShowAll".
7822 *
7823 * @param name The name of the extra data, with package prefix.
7824 * @param value The ArrayList<String> data value.
7825 *
7826 * @return Returns the same Intent object, for chaining multiple calls
7827 * into a single statement.
7828 *
7829 * @see #putExtras
7830 * @see #removeExtra
7831 * @see #getStringArrayListExtra(String)
7832 */
7833 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7834 if (mExtras == null) {
7835 mExtras = new Bundle();
7836 }
7837 mExtras.putStringArrayList(name, value);
7838 return this;
7839 }
7840
7841 /**
7842 * Add extended data to the intent. The name must include a package
7843 * prefix, for example the app com.android.contacts would use names
7844 * like "com.android.contacts.ShowAll".
7845 *
7846 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007847 * @param value The ArrayList<CharSequence> data value.
7848 *
7849 * @return Returns the same Intent object, for chaining multiple calls
7850 * into a single statement.
7851 *
7852 * @see #putExtras
7853 * @see #removeExtra
7854 * @see #getCharSequenceArrayListExtra(String)
7855 */
7856 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7857 if (mExtras == null) {
7858 mExtras = new Bundle();
7859 }
7860 mExtras.putCharSequenceArrayList(name, value);
7861 return this;
7862 }
7863
7864 /**
7865 * Add extended data to the intent. The name must include a package
7866 * prefix, for example the app com.android.contacts would use names
7867 * like "com.android.contacts.ShowAll".
7868 *
7869 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007870 * @param value The Serializable data value.
7871 *
7872 * @return Returns the same Intent object, for chaining multiple calls
7873 * into a single statement.
7874 *
7875 * @see #putExtras
7876 * @see #removeExtra
7877 * @see #getSerializableExtra(String)
7878 */
7879 public Intent putExtra(String name, Serializable value) {
7880 if (mExtras == null) {
7881 mExtras = new Bundle();
7882 }
7883 mExtras.putSerializable(name, value);
7884 return this;
7885 }
7886
7887 /**
7888 * Add extended data to the intent. The name must include a package
7889 * prefix, for example the app com.android.contacts would use names
7890 * like "com.android.contacts.ShowAll".
7891 *
7892 * @param name The name of the extra data, with package prefix.
7893 * @param value The boolean array data value.
7894 *
7895 * @return Returns the same Intent object, for chaining multiple calls
7896 * into a single statement.
7897 *
7898 * @see #putExtras
7899 * @see #removeExtra
7900 * @see #getBooleanArrayExtra(String)
7901 */
7902 public Intent putExtra(String name, boolean[] value) {
7903 if (mExtras == null) {
7904 mExtras = new Bundle();
7905 }
7906 mExtras.putBooleanArray(name, value);
7907 return this;
7908 }
7909
7910 /**
7911 * Add extended data to the intent. The name must include a package
7912 * prefix, for example the app com.android.contacts would use names
7913 * like "com.android.contacts.ShowAll".
7914 *
7915 * @param name The name of the extra data, with package prefix.
7916 * @param value The byte array data value.
7917 *
7918 * @return Returns the same Intent object, for chaining multiple calls
7919 * into a single statement.
7920 *
7921 * @see #putExtras
7922 * @see #removeExtra
7923 * @see #getByteArrayExtra(String)
7924 */
7925 public Intent putExtra(String name, byte[] value) {
7926 if (mExtras == null) {
7927 mExtras = new Bundle();
7928 }
7929 mExtras.putByteArray(name, value);
7930 return this;
7931 }
7932
7933 /**
7934 * Add extended data to the intent. The name must include a package
7935 * prefix, for example the app com.android.contacts would use names
7936 * like "com.android.contacts.ShowAll".
7937 *
7938 * @param name The name of the extra data, with package prefix.
7939 * @param value The short array data value.
7940 *
7941 * @return Returns the same Intent object, for chaining multiple calls
7942 * into a single statement.
7943 *
7944 * @see #putExtras
7945 * @see #removeExtra
7946 * @see #getShortArrayExtra(String)
7947 */
7948 public Intent putExtra(String name, short[] value) {
7949 if (mExtras == null) {
7950 mExtras = new Bundle();
7951 }
7952 mExtras.putShortArray(name, value);
7953 return this;
7954 }
7955
7956 /**
7957 * Add extended data to the intent. The name must include a package
7958 * prefix, for example the app com.android.contacts would use names
7959 * like "com.android.contacts.ShowAll".
7960 *
7961 * @param name The name of the extra data, with package prefix.
7962 * @param value The char array data value.
7963 *
7964 * @return Returns the same Intent object, for chaining multiple calls
7965 * into a single statement.
7966 *
7967 * @see #putExtras
7968 * @see #removeExtra
7969 * @see #getCharArrayExtra(String)
7970 */
7971 public Intent putExtra(String name, char[] value) {
7972 if (mExtras == null) {
7973 mExtras = new Bundle();
7974 }
7975 mExtras.putCharArray(name, value);
7976 return this;
7977 }
7978
7979 /**
7980 * Add extended data to the intent. The name must include a package
7981 * prefix, for example the app com.android.contacts would use names
7982 * like "com.android.contacts.ShowAll".
7983 *
7984 * @param name The name of the extra data, with package prefix.
7985 * @param value The int array data value.
7986 *
7987 * @return Returns the same Intent object, for chaining multiple calls
7988 * into a single statement.
7989 *
7990 * @see #putExtras
7991 * @see #removeExtra
7992 * @see #getIntArrayExtra(String)
7993 */
7994 public Intent putExtra(String name, int[] value) {
7995 if (mExtras == null) {
7996 mExtras = new Bundle();
7997 }
7998 mExtras.putIntArray(name, value);
7999 return this;
8000 }
8001
8002 /**
8003 * Add extended data to the intent. The name must include a package
8004 * prefix, for example the app com.android.contacts would use names
8005 * like "com.android.contacts.ShowAll".
8006 *
8007 * @param name The name of the extra data, with package prefix.
8008 * @param value The byte array data value.
8009 *
8010 * @return Returns the same Intent object, for chaining multiple calls
8011 * into a single statement.
8012 *
8013 * @see #putExtras
8014 * @see #removeExtra
8015 * @see #getLongArrayExtra(String)
8016 */
8017 public Intent putExtra(String name, long[] value) {
8018 if (mExtras == null) {
8019 mExtras = new Bundle();
8020 }
8021 mExtras.putLongArray(name, value);
8022 return this;
8023 }
8024
8025 /**
8026 * Add extended data to the intent. The name must include a package
8027 * prefix, for example the app com.android.contacts would use names
8028 * like "com.android.contacts.ShowAll".
8029 *
8030 * @param name The name of the extra data, with package prefix.
8031 * @param value The float array data value.
8032 *
8033 * @return Returns the same Intent object, for chaining multiple calls
8034 * into a single statement.
8035 *
8036 * @see #putExtras
8037 * @see #removeExtra
8038 * @see #getFloatArrayExtra(String)
8039 */
8040 public Intent putExtra(String name, float[] value) {
8041 if (mExtras == null) {
8042 mExtras = new Bundle();
8043 }
8044 mExtras.putFloatArray(name, value);
8045 return this;
8046 }
8047
8048 /**
8049 * Add extended data to the intent. The name must include a package
8050 * prefix, for example the app com.android.contacts would use names
8051 * like "com.android.contacts.ShowAll".
8052 *
8053 * @param name The name of the extra data, with package prefix.
8054 * @param value The double array data value.
8055 *
8056 * @return Returns the same Intent object, for chaining multiple calls
8057 * into a single statement.
8058 *
8059 * @see #putExtras
8060 * @see #removeExtra
8061 * @see #getDoubleArrayExtra(String)
8062 */
8063 public Intent putExtra(String name, double[] value) {
8064 if (mExtras == null) {
8065 mExtras = new Bundle();
8066 }
8067 mExtras.putDoubleArray(name, value);
8068 return this;
8069 }
8070
8071 /**
8072 * Add extended data to the intent. The name must include a package
8073 * prefix, for example the app com.android.contacts would use names
8074 * like "com.android.contacts.ShowAll".
8075 *
8076 * @param name The name of the extra data, with package prefix.
8077 * @param value The String array data value.
8078 *
8079 * @return Returns the same Intent object, for chaining multiple calls
8080 * into a single statement.
8081 *
8082 * @see #putExtras
8083 * @see #removeExtra
8084 * @see #getStringArrayExtra(String)
8085 */
8086 public Intent putExtra(String name, String[] value) {
8087 if (mExtras == null) {
8088 mExtras = new Bundle();
8089 }
8090 mExtras.putStringArray(name, value);
8091 return this;
8092 }
8093
8094 /**
8095 * Add extended data to the intent. The name must include a package
8096 * prefix, for example the app com.android.contacts would use names
8097 * like "com.android.contacts.ShowAll".
8098 *
8099 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008100 * @param value The CharSequence array data value.
8101 *
8102 * @return Returns the same Intent object, for chaining multiple calls
8103 * into a single statement.
8104 *
8105 * @see #putExtras
8106 * @see #removeExtra
8107 * @see #getCharSequenceArrayExtra(String)
8108 */
8109 public Intent putExtra(String name, CharSequence[] value) {
8110 if (mExtras == null) {
8111 mExtras = new Bundle();
8112 }
8113 mExtras.putCharSequenceArray(name, value);
8114 return this;
8115 }
8116
8117 /**
8118 * Add extended data to the intent. The name must include a package
8119 * prefix, for example the app com.android.contacts would use names
8120 * like "com.android.contacts.ShowAll".
8121 *
8122 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008123 * @param value The Bundle data value.
8124 *
8125 * @return Returns the same Intent object, for chaining multiple calls
8126 * into a single statement.
8127 *
8128 * @see #putExtras
8129 * @see #removeExtra
8130 * @see #getBundleExtra(String)
8131 */
8132 public Intent putExtra(String name, Bundle value) {
8133 if (mExtras == null) {
8134 mExtras = new Bundle();
8135 }
8136 mExtras.putBundle(name, value);
8137 return this;
8138 }
8139
8140 /**
8141 * Add extended data to the intent. The name must include a package
8142 * prefix, for example the app com.android.contacts would use names
8143 * like "com.android.contacts.ShowAll".
8144 *
8145 * @param name The name of the extra data, with package prefix.
8146 * @param value The IBinder data value.
8147 *
8148 * @return Returns the same Intent object, for chaining multiple calls
8149 * into a single statement.
8150 *
8151 * @see #putExtras
8152 * @see #removeExtra
8153 * @see #getIBinderExtra(String)
8154 *
8155 * @deprecated
8156 * @hide
8157 */
8158 @Deprecated
8159 public Intent putExtra(String name, IBinder value) {
8160 if (mExtras == null) {
8161 mExtras = new Bundle();
8162 }
8163 mExtras.putIBinder(name, value);
8164 return this;
8165 }
8166
8167 /**
8168 * Copy all extras in 'src' in to this intent.
8169 *
8170 * @param src Contains the extras to copy.
8171 *
8172 * @see #putExtra
8173 */
8174 public Intent putExtras(Intent src) {
8175 if (src.mExtras != null) {
8176 if (mExtras == null) {
8177 mExtras = new Bundle(src.mExtras);
8178 } else {
8179 mExtras.putAll(src.mExtras);
8180 }
8181 }
8182 return this;
8183 }
8184
8185 /**
8186 * Add a set of extended data to the intent. The keys must include a package
8187 * prefix, for example the app com.android.contacts would use names
8188 * like "com.android.contacts.ShowAll".
8189 *
8190 * @param extras The Bundle of extras to add to this intent.
8191 *
8192 * @see #putExtra
8193 * @see #removeExtra
8194 */
8195 public Intent putExtras(Bundle extras) {
8196 if (mExtras == null) {
8197 mExtras = new Bundle();
8198 }
8199 mExtras.putAll(extras);
8200 return this;
8201 }
8202
8203 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008204 * Completely replace the extras in the Intent with the extras in the
8205 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008206 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008207 * @param src The exact extras contained in this Intent are copied
8208 * into the target intent, replacing any that were previously there.
8209 */
8210 public Intent replaceExtras(Intent src) {
8211 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8212 return this;
8213 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008214
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008215 /**
8216 * Completely replace the extras in the Intent with the given Bundle of
8217 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008218 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008219 * @param extras The new set of extras in the Intent, or null to erase
8220 * all extras.
8221 */
8222 public Intent replaceExtras(Bundle extras) {
8223 mExtras = extras != null ? new Bundle(extras) : null;
8224 return this;
8225 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008226
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008227 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008228 * Remove extended data from the intent.
8229 *
8230 * @see #putExtra
8231 */
8232 public void removeExtra(String name) {
8233 if (mExtras != null) {
8234 mExtras.remove(name);
8235 if (mExtras.size() == 0) {
8236 mExtras = null;
8237 }
8238 }
8239 }
8240
8241 /**
8242 * Set special flags controlling how this intent is handled. Most values
8243 * here depend on the type of component being executed by the Intent,
8244 * specifically the FLAG_ACTIVITY_* flags are all for use with
8245 * {@link Context#startActivity Context.startActivity()} and the
8246 * FLAG_RECEIVER_* flags are all for use with
8247 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8248 *
Scott Main7aee61f2011-02-08 11:25:01 -08008249 * <p>See the
8250 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8251 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008252 * the behavior of your application.
8253 *
8254 * @param flags The desired flags.
8255 *
8256 * @return Returns the same Intent object, for chaining multiple calls
8257 * into a single statement.
8258 *
8259 * @see #getFlags
8260 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008261 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008262 *
8263 * @see #FLAG_GRANT_READ_URI_PERMISSION
8264 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008265 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8266 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008267 * @see #FLAG_DEBUG_LOG_RESOLUTION
8268 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008269 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008270 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008271 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008272 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008273 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8274 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008275 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008276 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008277 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008278 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008279 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008280 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008281 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008282 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8283 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008284 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008285 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008286 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008287 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8288 */
8289 public Intent setFlags(int flags) {
8290 mFlags = flags;
8291 return this;
8292 }
8293
8294 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008295 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008296 *
8297 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008298 * @return Returns the same Intent object, for chaining multiple calls into
8299 * a single statement.
8300 * @see #setFlags(int)
8301 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008302 */
8303 public Intent addFlags(int flags) {
8304 mFlags |= flags;
8305 return this;
8306 }
8307
8308 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008309 * Remove these flags from the intent.
8310 *
8311 * @param flags The flags to remove.
8312 * @see #setFlags(int)
8313 * @see #addFlags(int)
8314 */
8315 public void removeFlags(int flags) {
8316 mFlags &= ~flags;
8317 }
8318
8319 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008320 * (Usually optional) Set an explicit application package name that limits
8321 * the components this Intent will resolve to. If left to the default
8322 * value of null, all components in all applications will considered.
8323 * If non-null, the Intent can only match the components in the given
8324 * application package.
8325 *
8326 * @param packageName The name of the application package to handle the
8327 * intent, or null to allow any application package.
8328 *
8329 * @return Returns the same Intent object, for chaining multiple calls
8330 * into a single statement.
8331 *
8332 * @see #getPackage
8333 * @see #resolveActivity
8334 */
8335 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008336 if (packageName != null && mSelector != null) {
8337 throw new IllegalArgumentException(
8338 "Can't set package name when selector is already set");
8339 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008340 mPackage = packageName;
8341 return this;
8342 }
8343
8344 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008345 * (Usually optional) Explicitly set the component to handle the intent.
8346 * If left with the default value of null, the system will determine the
8347 * appropriate class to use based on the other fields (action, data,
8348 * type, categories) in the Intent. If this class is defined, the
8349 * specified class will always be used regardless of the other fields. You
8350 * should only set this value when you know you absolutely want a specific
8351 * class to be used; otherwise it is better to let the system find the
8352 * appropriate class so that you will respect the installed applications
8353 * and user preferences.
8354 *
8355 * @param component The name of the application component to handle the
8356 * intent, or null to let the system find one for you.
8357 *
8358 * @return Returns the same Intent object, for chaining multiple calls
8359 * into a single statement.
8360 *
8361 * @see #setClass
8362 * @see #setClassName(Context, String)
8363 * @see #setClassName(String, String)
8364 * @see #getComponent
8365 * @see #resolveActivity
8366 */
8367 public Intent setComponent(ComponentName component) {
8368 mComponent = component;
8369 return this;
8370 }
8371
8372 /**
8373 * Convenience for calling {@link #setComponent} with an
8374 * explicit class name.
8375 *
8376 * @param packageContext A Context of the application package implementing
8377 * this class.
8378 * @param className The name of a class inside of the application package
8379 * that will be used as the component for this Intent.
8380 *
8381 * @return Returns the same Intent object, for chaining multiple calls
8382 * into a single statement.
8383 *
8384 * @see #setComponent
8385 * @see #setClass
8386 */
8387 public Intent setClassName(Context packageContext, String className) {
8388 mComponent = new ComponentName(packageContext, className);
8389 return this;
8390 }
8391
8392 /**
8393 * Convenience for calling {@link #setComponent} with an
8394 * explicit application package name and class name.
8395 *
8396 * @param packageName The name of the package implementing the desired
8397 * component.
8398 * @param className The name of a class inside of the application package
8399 * that will be used as the component for this Intent.
8400 *
8401 * @return Returns the same Intent object, for chaining multiple calls
8402 * into a single statement.
8403 *
8404 * @see #setComponent
8405 * @see #setClass
8406 */
8407 public Intent setClassName(String packageName, String className) {
8408 mComponent = new ComponentName(packageName, className);
8409 return this;
8410 }
8411
8412 /**
8413 * Convenience for calling {@link #setComponent(ComponentName)} with the
8414 * name returned by a {@link Class} object.
8415 *
8416 * @param packageContext A Context of the application package implementing
8417 * this class.
8418 * @param cls The class name to set, equivalent to
8419 * <code>setClassName(context, cls.getName())</code>.
8420 *
8421 * @return Returns the same Intent object, for chaining multiple calls
8422 * into a single statement.
8423 *
8424 * @see #setComponent
8425 */
8426 public Intent setClass(Context packageContext, Class<?> cls) {
8427 mComponent = new ComponentName(packageContext, cls);
8428 return this;
8429 }
8430
8431 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008432 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8433 * used as a hint to the receiver for animations and the like. Null means that there
8434 * is no source bounds.
8435 */
8436 public void setSourceBounds(Rect r) {
8437 if (r != null) {
8438 mSourceBounds = new Rect(r);
8439 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008440 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008441 }
8442 }
8443
Tor Norbyed9273d62013-05-30 15:59:53 -07008444 /** @hide */
8445 @IntDef(flag = true,
8446 value = {
8447 FILL_IN_ACTION,
8448 FILL_IN_DATA,
8449 FILL_IN_CATEGORIES,
8450 FILL_IN_COMPONENT,
8451 FILL_IN_PACKAGE,
8452 FILL_IN_SOURCE_BOUNDS,
8453 FILL_IN_SELECTOR,
8454 FILL_IN_CLIP_DATA
8455 })
8456 @Retention(RetentionPolicy.SOURCE)
8457 public @interface FillInFlags {}
8458
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008459 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008460 * Use with {@link #fillIn} to allow the current action value to be
8461 * overwritten, even if it is already set.
8462 */
8463 public static final int FILL_IN_ACTION = 1<<0;
8464
8465 /**
8466 * Use with {@link #fillIn} to allow the current data or type value
8467 * overwritten, even if it is already set.
8468 */
8469 public static final int FILL_IN_DATA = 1<<1;
8470
8471 /**
8472 * Use with {@link #fillIn} to allow the current categories to be
8473 * overwritten, even if they are already set.
8474 */
8475 public static final int FILL_IN_CATEGORIES = 1<<2;
8476
8477 /**
8478 * Use with {@link #fillIn} to allow the current component value to be
8479 * overwritten, even if it is already set.
8480 */
8481 public static final int FILL_IN_COMPONENT = 1<<3;
8482
8483 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008484 * Use with {@link #fillIn} to allow the current package value to be
8485 * overwritten, even if it is already set.
8486 */
8487 public static final int FILL_IN_PACKAGE = 1<<4;
8488
8489 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008490 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008491 * overwritten, even if it is already set.
8492 */
8493 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8494
8495 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008496 * Use with {@link #fillIn} to allow the current selector to be
8497 * overwritten, even if it is already set.
8498 */
8499 public static final int FILL_IN_SELECTOR = 1<<6;
8500
8501 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008502 * Use with {@link #fillIn} to allow the current ClipData to be
8503 * overwritten, even if it is already set.
8504 */
8505 public static final int FILL_IN_CLIP_DATA = 1<<7;
8506
8507 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008508 * Copy the contents of <var>other</var> in to this object, but only
8509 * where fields are not defined by this object. For purposes of a field
8510 * being defined, the following pieces of data in the Intent are
8511 * considered to be separate fields:
8512 *
8513 * <ul>
8514 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008515 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008516 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8517 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008518 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008519 * <li> component, as set by {@link #setComponent(ComponentName)} or
8520 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008521 * <li> source bounds, as set by {@link #setSourceBounds}.
8522 * <li> selector, as set by {@link #setSelector(Intent)}.
8523 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008524 * <li> each top-level name in the associated extras.
8525 * </ul>
8526 *
8527 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008528 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008529 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8530 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8531 * the restriction where the corresponding field will not be replaced if
8532 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008533 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008534 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8535 * is explicitly specified. The selector will only be copied if
8536 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008537 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008538 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8539 * and Intent B with {action="gotit", data-type="some/thing",
8540 * categories="one","two"}.
8541 *
8542 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8543 * containing: {action="gotit", data-type="some/thing",
8544 * categories="bar"}.
8545 *
8546 * @param other Another Intent whose values are to be used to fill in
8547 * the current one.
8548 * @param flags Options to control which fields can be filled in.
8549 *
8550 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008551 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008552 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008553 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008554 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008556 @FillInFlags
8557 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008558 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008559 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008560 if (other.mAction != null
8561 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008562 mAction = other.mAction;
8563 changes |= FILL_IN_ACTION;
8564 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008565 if ((other.mData != null || other.mType != null)
8566 && ((mData == null && mType == null)
8567 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008568 mData = other.mData;
8569 mType = other.mType;
8570 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008571 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008572 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008573 if (other.mCategories != null
8574 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008576 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008577 }
8578 changes |= FILL_IN_CATEGORIES;
8579 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008580 if (other.mPackage != null
8581 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008582 // Only do this if mSelector is not set.
8583 if (mSelector == null) {
8584 mPackage = other.mPackage;
8585 changes |= FILL_IN_PACKAGE;
8586 }
8587 }
8588 // Selector is special: it can only be set if explicitly allowed,
8589 // for the same reason as the component name.
8590 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8591 if (mPackage == null) {
8592 mSelector = new Intent(other.mSelector);
8593 mPackage = null;
8594 changes |= FILL_IN_SELECTOR;
8595 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008596 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008597 if (other.mClipData != null
8598 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8599 mClipData = other.mClipData;
8600 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008601 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008602 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008603 // Component is special: it can -only- be set if explicitly allowed,
8604 // since otherwise the sender could force the intent somewhere the
8605 // originator didn't intend.
8606 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008607 mComponent = other.mComponent;
8608 changes |= FILL_IN_COMPONENT;
8609 }
8610 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008611 if (other.mSourceBounds != null
8612 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8613 mSourceBounds = new Rect(other.mSourceBounds);
8614 changes |= FILL_IN_SOURCE_BOUNDS;
8615 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008616 if (mExtras == null) {
8617 if (other.mExtras != null) {
8618 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008619 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008620 }
8621 } else if (other.mExtras != null) {
8622 try {
8623 Bundle newb = new Bundle(other.mExtras);
8624 newb.putAll(mExtras);
8625 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008626 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008627 } catch (RuntimeException e) {
8628 // Modifying the extras can cause us to unparcel the contents
8629 // of the bundle, and if we do this in the system process that
8630 // may fail. We really should handle this (i.e., the Bundle
8631 // impl shouldn't be on top of a plain map), but for now just
8632 // ignore it and keep the original contents. :(
8633 Log.w("Intent", "Failure filling in extras", e);
8634 }
8635 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008636 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8637 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8638 mContentUserHint = other.mContentUserHint;
8639 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008640 return changes;
8641 }
8642
8643 /**
8644 * Wrapper class holding an Intent and implementing comparisons on it for
8645 * the purpose of filtering. The class implements its
8646 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8647 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8648 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8649 * on the wrapped Intent.
8650 */
8651 public static final class FilterComparison {
8652 private final Intent mIntent;
8653 private final int mHashCode;
8654
8655 public FilterComparison(Intent intent) {
8656 mIntent = intent;
8657 mHashCode = intent.filterHashCode();
8658 }
8659
8660 /**
8661 * Return the Intent that this FilterComparison represents.
8662 * @return Returns the Intent held by the FilterComparison. Do
8663 * not modify!
8664 */
8665 public Intent getIntent() {
8666 return mIntent;
8667 }
8668
8669 @Override
8670 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008671 if (obj instanceof FilterComparison) {
8672 Intent other = ((FilterComparison)obj).mIntent;
8673 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008674 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008675 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008676 }
8677
8678 @Override
8679 public int hashCode() {
8680 return mHashCode;
8681 }
8682 }
8683
8684 /**
8685 * Determine if two intents are the same for the purposes of intent
8686 * resolution (filtering). That is, if their action, data, type,
8687 * class, and categories are the same. This does <em>not</em> compare
8688 * any extra data included in the intents.
8689 *
8690 * @param other The other Intent to compare against.
8691 *
8692 * @return Returns true if action, data, type, class, and categories
8693 * are the same.
8694 */
8695 public boolean filterEquals(Intent other) {
8696 if (other == null) {
8697 return false;
8698 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008699 if (!Objects.equals(this.mAction, other.mAction)) return false;
8700 if (!Objects.equals(this.mData, other.mData)) return false;
8701 if (!Objects.equals(this.mType, other.mType)) return false;
8702 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8703 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8704 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008705
8706 return true;
8707 }
8708
8709 /**
8710 * Generate hash code that matches semantics of filterEquals().
8711 *
8712 * @return Returns the hash value of the action, data, type, class, and
8713 * categories.
8714 *
8715 * @see #filterEquals
8716 */
8717 public int filterHashCode() {
8718 int code = 0;
8719 if (mAction != null) {
8720 code += mAction.hashCode();
8721 }
8722 if (mData != null) {
8723 code += mData.hashCode();
8724 }
8725 if (mType != null) {
8726 code += mType.hashCode();
8727 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008728 if (mPackage != null) {
8729 code += mPackage.hashCode();
8730 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008731 if (mComponent != null) {
8732 code += mComponent.hashCode();
8733 }
8734 if (mCategories != null) {
8735 code += mCategories.hashCode();
8736 }
8737 return code;
8738 }
8739
8740 @Override
8741 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008742 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008743
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008744 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008745 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008746 b.append(" }");
8747
8748 return b.toString();
8749 }
8750
8751 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008752 public String toInsecureString() {
8753 StringBuilder b = new StringBuilder(128);
8754
8755 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008756 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008757 b.append(" }");
8758
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008759 return b.toString();
8760 }
Romain Guy4969af72009-06-17 10:53:19 -07008761
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008762 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008763 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008764 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008765
8766 b.append("Intent { ");
8767 toShortString(b, false, true, true, true);
8768 b.append(" }");
8769
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008770 return b.toString();
8771 }
8772
8773 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008774 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8775 StringBuilder b = new StringBuilder(128);
8776 toShortString(b, secure, comp, extras, clip);
8777 return b.toString();
8778 }
8779
8780 /** @hide */
8781 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8782 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008783 boolean first = true;
8784 if (mAction != null) {
8785 b.append("act=").append(mAction);
8786 first = false;
8787 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008788 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008789 if (!first) {
8790 b.append(' ');
8791 }
8792 first = false;
8793 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008794 for (int i=0; i<mCategories.size(); i++) {
8795 if (i > 0) b.append(',');
8796 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008797 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008798 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008799 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008800 if (mData != null) {
8801 if (!first) {
8802 b.append(' ');
8803 }
8804 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008805 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008806 if (secure) {
8807 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008808 } else {
8809 b.append(mData);
8810 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008811 }
8812 if (mType != null) {
8813 if (!first) {
8814 b.append(' ');
8815 }
8816 first = false;
8817 b.append("typ=").append(mType);
8818 }
8819 if (mFlags != 0) {
8820 if (!first) {
8821 b.append(' ');
8822 }
8823 first = false;
8824 b.append("flg=0x").append(Integer.toHexString(mFlags));
8825 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008826 if (mPackage != null) {
8827 if (!first) {
8828 b.append(' ');
8829 }
8830 first = false;
8831 b.append("pkg=").append(mPackage);
8832 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008833 if (comp && mComponent != null) {
8834 if (!first) {
8835 b.append(' ');
8836 }
8837 first = false;
8838 b.append("cmp=").append(mComponent.flattenToShortString());
8839 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008840 if (mSourceBounds != null) {
8841 if (!first) {
8842 b.append(' ');
8843 }
8844 first = false;
8845 b.append("bnds=").append(mSourceBounds.toShortString());
8846 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008847 if (mClipData != null) {
8848 if (!first) {
8849 b.append(' ');
8850 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008851 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008852 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008853 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008854 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008855 if (mClipData.getDescription() != null) {
8856 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8857 } else {
8858 first = true;
8859 }
8860 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008861 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008862 first = false;
8863 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008864 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008865 if (extras && mExtras != null) {
8866 if (!first) {
8867 b.append(' ');
8868 }
8869 first = false;
8870 b.append("(has extras)");
8871 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008872 if (mContentUserHint != UserHandle.USER_CURRENT) {
8873 if (!first) {
8874 b.append(' ');
8875 }
8876 first = false;
8877 b.append("u=").append(mContentUserHint);
8878 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008879 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008880 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008881 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008882 b.append("}");
8883 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008884 }
8885
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008886 /**
8887 * Call {@link #toUri} with 0 flags.
8888 * @deprecated Use {@link #toUri} instead.
8889 */
8890 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008891 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008892 return toUri(0);
8893 }
8894
8895 /**
8896 * Convert this Intent into a String holding a URI representation of it.
8897 * The returned URI string has been properly URI encoded, so it can be
8898 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8899 * Intent's data as the base URI, with an additional fragment describing
8900 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008901 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008902 * <p>You can convert the returned string back to an Intent with
8903 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008904 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008905 * @param flags Additional operating flags. Either 0,
8906 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008907 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008908 * @return Returns a URI encoding URI string describing the entire contents
8909 * of the Intent.
8910 */
8911 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008912 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008913 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8914 if (mPackage == null) {
8915 throw new IllegalArgumentException(
8916 "Intent must include an explicit package name to build an android-app: "
8917 + this);
8918 }
8919 uri.append("android-app://");
8920 uri.append(mPackage);
8921 String scheme = null;
8922 if (mData != null) {
8923 scheme = mData.getScheme();
8924 if (scheme != null) {
8925 uri.append('/');
8926 uri.append(scheme);
8927 String authority = mData.getEncodedAuthority();
8928 if (authority != null) {
8929 uri.append('/');
8930 uri.append(authority);
8931 String path = mData.getEncodedPath();
8932 if (path != null) {
8933 uri.append(path);
8934 }
8935 String queryParams = mData.getEncodedQuery();
8936 if (queryParams != null) {
8937 uri.append('?');
8938 uri.append(queryParams);
8939 }
8940 String fragment = mData.getEncodedFragment();
8941 if (fragment != null) {
8942 uri.append('#');
8943 uri.append(fragment);
8944 }
8945 }
8946 }
8947 }
8948 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8949 mPackage, flags);
8950 return uri.toString();
8951 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008952 String scheme = null;
8953 if (mData != null) {
8954 String data = mData.toString();
8955 if ((flags&URI_INTENT_SCHEME) != 0) {
8956 final int N = data.length();
8957 for (int i=0; i<N; i++) {
8958 char c = data.charAt(i);
8959 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8960 || c == '.' || c == '-') {
8961 continue;
8962 }
8963 if (c == ':' && i > 0) {
8964 // Valid scheme.
8965 scheme = data.substring(0, i);
8966 uri.append("intent:");
8967 data = data.substring(i+1);
8968 break;
8969 }
Tom Taylord4a47292009-12-21 13:59:18 -08008970
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008971 // No scheme.
8972 break;
8973 }
8974 }
8975 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008976
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008977 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8978 uri.append("intent:");
8979 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008980
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008981 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008982
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008983 return uri.toString();
8984 }
8985
8986 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8987 String defPackage, int flags) {
8988 StringBuilder frag = new StringBuilder(128);
8989
8990 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008991 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008992 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008993 // Note that for now we are not going to try to handle the
8994 // data part; not clear how to represent this as a URI, and
8995 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008996 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8997 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008998 }
8999
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009000 if (frag.length() > 0) {
9001 uri.append("#Intent;");
9002 uri.append(frag);
9003 uri.append("end");
9004 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009005 }
9006
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009007 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9008 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009009 if (scheme != null) {
9010 uri.append("scheme=").append(scheme).append(';');
9011 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009012 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009013 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009014 }
9015 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009016 for (int i=0; i<mCategories.size(); i++) {
9017 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009018 }
9019 }
9020 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009021 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009022 }
9023 if (mFlags != 0) {
9024 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9025 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009026 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009027 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9028 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009029 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009030 uri.append("component=").append(Uri.encode(
9031 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009032 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009033 if (mSourceBounds != null) {
9034 uri.append("sourceBounds=")
9035 .append(Uri.encode(mSourceBounds.flattenToString()))
9036 .append(';');
9037 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009038 if (mExtras != null) {
9039 for (String key : mExtras.keySet()) {
9040 final Object value = mExtras.get(key);
9041 char entryType =
9042 value instanceof String ? 'S' :
9043 value instanceof Boolean ? 'B' :
9044 value instanceof Byte ? 'b' :
9045 value instanceof Character ? 'c' :
9046 value instanceof Double ? 'd' :
9047 value instanceof Float ? 'f' :
9048 value instanceof Integer ? 'i' :
9049 value instanceof Long ? 'l' :
9050 value instanceof Short ? 's' :
9051 '\0';
9052
9053 if (entryType != '\0') {
9054 uri.append(entryType);
9055 uri.append('.');
9056 uri.append(Uri.encode(key));
9057 uri.append('=');
9058 uri.append(Uri.encode(value.toString()));
9059 uri.append(';');
9060 }
9061 }
9062 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009063 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009064
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009065 public int describeContents() {
9066 return (mExtras != null) ? mExtras.describeContents() : 0;
9067 }
9068
9069 public void writeToParcel(Parcel out, int flags) {
9070 out.writeString(mAction);
9071 Uri.writeToParcel(out, mData);
9072 out.writeString(mType);
9073 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009074 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009075 ComponentName.writeToParcel(mComponent, out);
9076
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009077 if (mSourceBounds != null) {
9078 out.writeInt(1);
9079 mSourceBounds.writeToParcel(out, flags);
9080 } else {
9081 out.writeInt(0);
9082 }
9083
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009084 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009085 final int N = mCategories.size();
9086 out.writeInt(N);
9087 for (int i=0; i<N; i++) {
9088 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009089 }
9090 } else {
9091 out.writeInt(0);
9092 }
9093
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009094 if (mSelector != null) {
9095 out.writeInt(1);
9096 mSelector.writeToParcel(out, flags);
9097 } else {
9098 out.writeInt(0);
9099 }
9100
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009101 if (mClipData != null) {
9102 out.writeInt(1);
9103 mClipData.writeToParcel(out, flags);
9104 } else {
9105 out.writeInt(0);
9106 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009107 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009108 out.writeBundle(mExtras);
9109 }
9110
9111 public static final Parcelable.Creator<Intent> CREATOR
9112 = new Parcelable.Creator<Intent>() {
9113 public Intent createFromParcel(Parcel in) {
9114 return new Intent(in);
9115 }
9116 public Intent[] newArray(int size) {
9117 return new Intent[size];
9118 }
9119 };
9120
Dianne Hackborneb034652009-09-07 00:49:58 -07009121 /** @hide */
9122 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009123 readFromParcel(in);
9124 }
9125
9126 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009127 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009128 mData = Uri.CREATOR.createFromParcel(in);
9129 mType = in.readString();
9130 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009131 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009132 mComponent = ComponentName.readFromParcel(in);
9133
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009134 if (in.readInt() != 0) {
9135 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9136 }
9137
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009138 int N = in.readInt();
9139 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009140 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009141 int i;
9142 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009143 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009144 }
9145 } else {
9146 mCategories = null;
9147 }
9148
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009149 if (in.readInt() != 0) {
9150 mSelector = new Intent(in);
9151 }
9152
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009153 if (in.readInt() != 0) {
9154 mClipData = new ClipData(in);
9155 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009156 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009157 mExtras = in.readBundle();
9158 }
9159
9160 /**
9161 * Parses the "intent" element (and its children) from XML and instantiates
9162 * an Intent object. The given XML parser should be located at the tag
9163 * where parsing should start (often named "intent"), from which the
9164 * basic action, data, type, and package and class name will be
9165 * retrieved. The function will then parse in to any child elements,
9166 * looking for <category android:name="xxx"> tags to add categories and
9167 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9168 * to the intent.
9169 *
9170 * @param resources The Resources to use when inflating resources.
9171 * @param parser The XML parser pointing at an "intent" tag.
9172 * @param attrs The AttributeSet interface for retrieving extended
9173 * attribute data at the current <var>parser</var> location.
9174 * @return An Intent object matching the XML data.
9175 * @throws XmlPullParserException If there was an XML parsing error.
9176 * @throws IOException If there was an I/O error.
9177 */
9178 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9179 throws XmlPullParserException, IOException {
9180 Intent intent = new Intent();
9181
9182 TypedArray sa = resources.obtainAttributes(attrs,
9183 com.android.internal.R.styleable.Intent);
9184
9185 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9186
9187 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9188 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9189 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9190
9191 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9192 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9193 if (packageName != null && className != null) {
9194 intent.setComponent(new ComponentName(packageName, className));
9195 }
9196
9197 sa.recycle();
9198
9199 int outerDepth = parser.getDepth();
9200 int type;
9201 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9202 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9203 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9204 continue;
9205 }
9206
9207 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009208 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009209 sa = resources.obtainAttributes(attrs,
9210 com.android.internal.R.styleable.IntentCategory);
9211 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9212 sa.recycle();
9213
9214 if (cat != null) {
9215 intent.addCategory(cat);
9216 }
9217 XmlUtils.skipCurrentTag(parser);
9218
Craig Mautner21d24a22014-04-23 11:45:37 -07009219 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009220 if (intent.mExtras == null) {
9221 intent.mExtras = new Bundle();
9222 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009223 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009224 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009225
9226 } else {
9227 XmlUtils.skipCurrentTag(parser);
9228 }
9229 }
9230
9231 return intent;
9232 }
Nick Pellyccae4122012-01-09 14:12:58 -08009233
Craig Mautner21d24a22014-04-23 11:45:37 -07009234 /** @hide */
9235 public void saveToXml(XmlSerializer out) throws IOException {
9236 if (mAction != null) {
9237 out.attribute(null, ATTR_ACTION, mAction);
9238 }
9239 if (mData != null) {
9240 out.attribute(null, ATTR_DATA, mData.toString());
9241 }
9242 if (mType != null) {
9243 out.attribute(null, ATTR_TYPE, mType);
9244 }
9245 if (mComponent != null) {
9246 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9247 }
9248 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9249
9250 if (mCategories != null) {
9251 out.startTag(null, TAG_CATEGORIES);
9252 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9253 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9254 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009255 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009256 }
9257 }
9258
9259 /** @hide */
9260 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9261 XmlPullParserException {
9262 Intent intent = new Intent();
9263 final int outerDepth = in.getDepth();
9264
9265 int attrCount = in.getAttributeCount();
9266 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9267 final String attrName = in.getAttributeName(attrNdx);
9268 final String attrValue = in.getAttributeValue(attrNdx);
9269 if (ATTR_ACTION.equals(attrName)) {
9270 intent.setAction(attrValue);
9271 } else if (ATTR_DATA.equals(attrName)) {
9272 intent.setData(Uri.parse(attrValue));
9273 } else if (ATTR_TYPE.equals(attrName)) {
9274 intent.setType(attrValue);
9275 } else if (ATTR_COMPONENT.equals(attrName)) {
9276 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9277 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009278 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009279 } else {
9280 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9281 }
9282 }
9283
9284 int event;
9285 String name;
9286 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9287 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9288 if (event == XmlPullParser.START_TAG) {
9289 name = in.getName();
9290 if (TAG_CATEGORIES.equals(name)) {
9291 attrCount = in.getAttributeCount();
9292 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9293 intent.addCategory(in.getAttributeValue(attrNdx));
9294 }
9295 } else {
9296 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9297 XmlUtils.skipCurrentTag(in);
9298 }
9299 }
9300 }
9301
9302 return intent;
9303 }
9304
Nick Pellyccae4122012-01-09 14:12:58 -08009305 /**
9306 * Normalize a MIME data type.
9307 *
9308 * <p>A normalized MIME type has white-space trimmed,
9309 * content-type parameters removed, and is lower-case.
9310 * This aligns the type with Android best practices for
9311 * intent filtering.
9312 *
9313 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9314 * "text/x-vCard" becomes "text/x-vcard".
9315 *
9316 * <p>All MIME types received from outside Android (such as user input,
9317 * or external sources like Bluetooth, NFC, or the Internet) should
9318 * be normalized before they are used to create an Intent.
9319 *
9320 * @param type MIME data type to normalize
9321 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009322 * @see #setType
9323 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009324 */
9325 public static String normalizeMimeType(String type) {
9326 if (type == null) {
9327 return null;
9328 }
9329
Elliott Hughescb64d432013-08-02 10:00:44 -07009330 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009331
9332 final int semicolonIndex = type.indexOf(';');
9333 if (semicolonIndex != -1) {
9334 type = type.substring(0, semicolonIndex);
9335 }
9336 return type;
9337 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009338
9339 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009340 * Prepare this {@link Intent} to leave an app process.
9341 *
9342 * @hide
9343 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009344 public void prepareToLeaveProcess(Context context) {
9345 final boolean leavingPackage = (mComponent == null)
9346 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9347 prepareToLeaveProcess(leavingPackage);
9348 }
9349
9350 /**
9351 * Prepare this {@link Intent} to leave an app process.
9352 *
9353 * @hide
9354 */
9355 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009356 setAllowFds(false);
9357
9358 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009359 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009360 }
9361 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009362 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009363 }
9364
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009365 if (mExtras != null && !mExtras.isParcelled()) {
9366 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9367 if (intent instanceof Intent) {
9368 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9369 }
9370 }
9371
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009372 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9373 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009374 switch (mAction) {
9375 case ACTION_MEDIA_REMOVED:
9376 case ACTION_MEDIA_UNMOUNTED:
9377 case ACTION_MEDIA_CHECKING:
9378 case ACTION_MEDIA_NOFS:
9379 case ACTION_MEDIA_MOUNTED:
9380 case ACTION_MEDIA_SHARED:
9381 case ACTION_MEDIA_UNSHARED:
9382 case ACTION_MEDIA_BAD_REMOVAL:
9383 case ACTION_MEDIA_UNMOUNTABLE:
9384 case ACTION_MEDIA_EJECT:
9385 case ACTION_MEDIA_SCANNER_STARTED:
9386 case ACTION_MEDIA_SCANNER_FINISHED:
9387 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009388 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9389 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009390 // Ignore legacy actions
9391 break;
9392 default:
9393 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009394 }
9395 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009396
9397 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9398 && leavingPackage) {
9399 switch (mAction) {
9400 case ACTION_PROVIDER_CHANGED:
9401 // Ignore actions that don't need to grant
9402 break;
9403 default:
9404 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9405 }
9406 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009407 }
9408
9409 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009410 * @hide
9411 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009412 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009413 // We just entered destination process, so we should be able to read all
9414 // parcelables inside.
9415 setDefusable(true);
9416
9417 if (mSelector != null) {
9418 mSelector.prepareToEnterProcess();
9419 }
9420 if (mClipData != null) {
9421 mClipData.prepareToEnterProcess();
9422 }
9423
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009424 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009425 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9426 fixUris(mContentUserHint);
9427 mContentUserHint = UserHandle.USER_CURRENT;
9428 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009429 }
Jeff Sharkeya0ba51c2017-03-21 20:23:36 -06009430
9431 // If someone is sending us ClipData, but not EXTRA_STREAM, offer to
9432 // downgrade that content for older apps to find
9433 if (mClipData != null && mClipData.getItemCount() > 0 && !hasExtra(EXTRA_STREAM)) {
9434 final String action = getAction();
9435 if (ACTION_SEND.equals(action)) {
9436 putExtra(EXTRA_STREAM, mClipData.getItemAt(0).getUri());
9437 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
9438 final ArrayList<Uri> list = new ArrayList<>();
9439 for (int i = 0; i < mClipData.getItemCount(); i++) {
9440 list.add(mClipData.getItemAt(i).getUri());
9441 }
9442 putExtra(EXTRA_STREAM, list);
9443 }
9444 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009445 }
9446
9447 /**
9448 * @hide
9449 */
9450 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009451 Uri data = getData();
9452 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009453 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009454 }
9455 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009456 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009457 }
9458 String action = getAction();
9459 if (ACTION_SEND.equals(action)) {
9460 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9461 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009462 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009463 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009464 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009465 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9466 if (streams != null) {
9467 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9468 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009469 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009470 }
9471 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9472 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009473 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9474 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9475 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9476 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9477 if (output != null) {
9478 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9479 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009480 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009481 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009482
9483 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009484 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009485 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9486 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009487 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009488 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009489 * @hide
9490 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009491 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009492 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009493 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009494
9495 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009496 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009497
9498 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009499 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009500 // Inspect contained intents to see if we need to migrate extras. We
9501 // don't promote ClipData to the parent, since ChooserActivity will
9502 // already start the picked item as the caller, and we can't combine
9503 // the flags in a safe way.
9504
9505 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009506 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009507 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9508 if (intent != null) {
9509 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009510 }
9511 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009512 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009513 try {
9514 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9515 if (intents != null) {
9516 for (int i = 0; i < intents.length; i++) {
9517 final Intent intent = (Intent) intents[i];
9518 if (intent != null) {
9519 migrated |= intent.migrateExtraStreamToClipData();
9520 }
9521 }
9522 }
9523 } catch (ClassCastException e) {
9524 }
9525 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009526
9527 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009528 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009529 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9530 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9531 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9532 if (stream != null || text != null || htmlText != null) {
9533 final ClipData clipData = new ClipData(
9534 null, new String[] { getType() },
9535 new ClipData.Item(text, htmlText, null, stream));
9536 setClipData(clipData);
9537 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009538 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009539 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009540 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009541 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009542
9543 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009544 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009545 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9546 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9547 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9548 int num = -1;
9549 if (streams != null) {
9550 num = streams.size();
9551 }
9552 if (texts != null) {
9553 if (num >= 0 && num != texts.size()) {
9554 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009555 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009556 }
9557 num = texts.size();
9558 }
9559 if (htmlTexts != null) {
9560 if (num >= 0 && num != htmlTexts.size()) {
9561 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009562 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009563 }
9564 num = htmlTexts.size();
9565 }
9566 if (num > 0) {
9567 final ClipData clipData = new ClipData(
9568 null, new String[] { getType() },
9569 makeClipItem(streams, texts, htmlTexts, 0));
9570
9571 for (int i = 1; i < num; i++) {
9572 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9573 }
9574
9575 setClipData(clipData);
9576 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009577 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009578 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009579 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009580 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009581 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9582 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9583 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9584 final Uri output;
9585 try {
9586 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9587 } catch (ClassCastException e) {
9588 return false;
9589 }
9590 if (output != null) {
9591 setClipData(ClipData.newRawUri("", output));
9592 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9593 return true;
9594 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009595 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009596
9597 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009598 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009599
9600 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9601 ArrayList<String> htmlTexts, int which) {
9602 Uri uri = streams != null ? streams.get(which) : null;
9603 CharSequence text = texts != null ? texts.get(which) : null;
9604 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9605 return new ClipData.Item(text, htmlText, null, uri);
9606 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009607
9608 /** @hide */
9609 public boolean isDocument() {
9610 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9611 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009612}