blob: e013662616ed23988fbd488ba40f71a78f9c9d03 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070020import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070021import android.annotation.IntDef;
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060022import android.annotation.NonNull;
23import android.annotation.Nullable;
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 Sharkey81aebe72017-04-03 20:14:10 +000046import android.os.storage.StorageManager;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070047import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070048import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050049import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070050import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050051import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070052import android.util.AttributeSet;
53import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080054import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050055import org.xmlpull.v1.XmlPullParser;
56import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070057import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058
59import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080060import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070061import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070062import java.lang.annotation.Retention;
63import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070064import java.net.URISyntaxException;
65import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080066import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070067import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080068import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070069import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070070import java.util.Set;
71
Jeff Sharkey81aebe72017-04-03 20:14:10 +000072import static android.content.ContentProvider.maybeAddUserId;
73
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070074/**
75 * An intent is an abstract description of an operation to be performed. It
76 * can be used with {@link Context#startActivity(Intent) startActivity} to
77 * launch an {@link android.app.Activity},
78 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
79 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
80 * and {@link android.content.Context#startService} or
81 * {@link android.content.Context#bindService} to communicate with a
82 * background {@link android.app.Service}.
83 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070084 * <p>An Intent provides a facility for performing late runtime binding between the code in
85 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070086 * can be thought of as the glue between activities. It is basically a passive data structure
87 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070088 *
89 * <div class="special reference">
90 * <h3>Developer Guides</h3>
91 * <p>For information about how to create and resolve intents, read the
92 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
93 * developer guide.</p>
94 * </div>
95 *
96 * <a name="IntentStructure"></a>
97 * <h3>Intent Structure</h3>
98 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070099 *
100 * <ul>
101 * <li> <p><b>action</b> -- The general action to be performed, such as
102 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
103 * etc.</p>
104 * </li>
105 * <li> <p><b>data</b> -- The data to operate on, such as a person record
106 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
107 * </li>
108 * </ul>
109 *
110 *
111 * <p>Some examples of action/data pairs are:</p>
112 *
113 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700114 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700115 * information about the person whose identifier is "1".</p>
116 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700117 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700118 * the phone dialer with the person filled in.</p>
119 * </li>
120 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
121 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700122 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700123 * a particular URI.</p>
124 * </li>
125 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
126 * the phone dialer with the given number filled in.</p>
127 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700128 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700129 * information about the person whose identifier is "1".</p>
130 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700131 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700132 * a list of people, which the user can browse through. This example is a
133 * typical top-level entry into the Contacts application, showing you the
134 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700135 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700136 * being used to start an activity to display that person.</p>
137 * </li>
138 * </ul>
139 *
140 * <p>In addition to these primary attributes, there are a number of secondary
141 * attributes that you can also include with an intent:</p>
142 *
143 * <ul>
144 * <li> <p><b>category</b> -- Gives additional information about the action
145 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
146 * appear in the Launcher as a top-level application, while
147 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
148 * of alternative actions the user can perform on a piece of data.</p>
149 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
150 * intent data. Normally the type is inferred from the data itself.
151 * By setting this attribute, you disable that evaluation and force
152 * an explicit type.</p>
153 * <li> <p><b>component</b> -- Specifies an explicit name of a component
154 * class to use for the intent. Normally this is determined by looking
155 * at the other information in the intent (the action, data/type, and
156 * categories) and matching that with a component that can handle it.
157 * If this attribute is set then none of the evaluation is performed,
158 * and this component is used exactly as is. By specifying this attribute,
159 * all of the other Intent attributes become optional.</p>
160 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
161 * This can be used to provide extended information to the component.
162 * For example, if we have a action to send an e-mail message, we could
163 * also include extra pieces of data here to supply a subject, body,
164 * etc.</p>
165 * </ul>
166 *
167 * <p>Here are some examples of other operations you can specify as intents
168 * using these additional parameters:</p>
169 *
170 * <ul>
171 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
172 * Launch the home screen.</p>
173 * </li>
174 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
175 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
176 * vnd.android.cursor.item/phone}</i></b>
177 * -- Display the list of people's phone numbers, allowing the user to
178 * browse through them and pick one and return it to the parent activity.</p>
179 * </li>
180 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
181 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
182 * -- Display all pickers for data that can be opened with
183 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
184 * allowing the user to pick one of them and then some data inside of it
185 * and returning the resulting URI to the caller. This can be used,
186 * for example, in an e-mail application to allow the user to pick some
187 * data to include as an attachment.</p>
188 * </li>
189 * </ul>
190 *
191 * <p>There are a variety of standard Intent action and category constants
192 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700193 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700194 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700195 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700196 *
197 * <p>Put together, the set of actions, data types, categories, and extra data
198 * defines a language for the system allowing for the expression of phrases
199 * such as "call john smith's cell". As applications are added to the system,
200 * they can extend this language by adding new actions, types, and categories, or
201 * they can modify the behavior of existing phrases by supplying their own
202 * activities that handle them.</p>
203 *
204 * <a name="IntentResolution"></a>
205 * <h3>Intent Resolution</h3>
206 *
207 * <p>There are two primary forms of intents you will use.
208 *
209 * <ul>
210 * <li> <p><b>Explicit Intents</b> have specified a component (via
211 * {@link #setComponent} or {@link #setClass}), which provides the exact
212 * class to be run. Often these will not include any other information,
213 * simply being a way for an application to launch various internal
214 * activities it has as the user interacts with the application.
215 *
216 * <li> <p><b>Implicit Intents</b> have not specified a component;
217 * instead, they must include enough information for the system to
218 * determine which of the available components is best to run for that
219 * intent.
220 * </ul>
221 *
222 * <p>When using implicit intents, given such an arbitrary intent we need to
223 * know what to do with it. This is handled by the process of <em>Intent
224 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
225 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
226 * more activities/receivers) that can handle it.</p>
227 *
228 * <p>The intent resolution mechanism basically revolves around matching an
229 * Intent against all of the &lt;intent-filter&gt; descriptions in the
230 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
231 * objects explicitly registered with {@link Context#registerReceiver}.) More
232 * details on this can be found in the documentation on the {@link
233 * IntentFilter} class.</p>
234 *
235 * <p>There are three pieces of information in the Intent that are used for
236 * resolution: the action, type, and category. Using this information, a query
237 * is done on the {@link PackageManager} for a component that can handle the
238 * intent. The appropriate component is determined based on the intent
239 * information supplied in the <code>AndroidManifest.xml</code> file as
240 * follows:</p>
241 *
242 * <ul>
243 * <li> <p>The <b>action</b>, if given, must be listed by the component as
244 * one it handles.</p>
245 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
246 * already supplied in the Intent. Like the action, if a type is
247 * included in the intent (either explicitly or implicitly in its
248 * data), then this must be listed by the component as one it handles.</p>
249 * <li> For data that is not a <code>content:</code> URI and where no explicit
250 * type is included in the Intent, instead the <b>scheme</b> of the
251 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
252 * considered. Again like the action, if we are matching a scheme it
253 * must be listed by the component as one it can handle.
254 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
255 * by the activity as categories it handles. That is, if you include
256 * the categories {@link #CATEGORY_LAUNCHER} and
257 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
258 * with an intent that lists <em>both</em> of those categories.
259 * Activities will very often need to support the
260 * {@link #CATEGORY_DEFAULT} so that they can be found by
261 * {@link Context#startActivity Context.startActivity()}.</p>
262 * </ul>
263 *
264 * <p>For example, consider the Note Pad sample application that
265 * allows user to browse through a list of notes data and view details about
266 * individual items. Text in italics indicate places were you would replace a
267 * name with one specific to your own package.</p>
268 *
269 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
270 * package="<i>com.android.notepad</i>"&gt;
271 * &lt;application android:icon="@drawable/app_notes"
272 * android:label="@string/app_name"&gt;
273 *
274 * &lt;provider class=".NotePadProvider"
275 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
276 *
277 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.MAIN" /&gt;
280 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700281 * &lt;/intent-filter&gt;
282 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700283 * &lt;action android:name="android.intent.action.VIEW" /&gt;
284 * &lt;action android:name="android.intent.action.EDIT" /&gt;
285 * &lt;action android:name="android.intent.action.PICK" /&gt;
286 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
287 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700288 * &lt;/intent-filter&gt;
289 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700290 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
291 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
292 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700293 * &lt;/intent-filter&gt;
294 * &lt;/activity&gt;
295 *
296 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
297 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700298 * &lt;action android:name="android.intent.action.VIEW" /&gt;
299 * &lt;action android:name="android.intent.action.EDIT" /&gt;
300 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
301 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700302 * &lt;/intent-filter&gt;
303 *
304 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700305 * &lt;action android:name="android.intent.action.INSERT" /&gt;
306 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
307 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700308 * &lt;/intent-filter&gt;
309 *
310 * &lt;/activity&gt;
311 *
312 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
313 * android:theme="@android:style/Theme.Dialog"&gt;
314 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700315 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
316 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
317 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
318 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
319 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700320 * &lt;/intent-filter&gt;
321 * &lt;/activity&gt;
322 *
323 * &lt;/application&gt;
324 * &lt;/manifest&gt;</pre>
325 *
326 * <p>The first activity,
327 * <code>com.android.notepad.NotesList</code>, serves as our main
328 * entry into the app. It can do three things as described by its three intent
329 * templates:
330 * <ol>
331 * <li><pre>
332 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700333 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
334 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700335 * &lt;/intent-filter&gt;</pre>
336 * <p>This provides a top-level entry into the NotePad application: the standard
337 * MAIN action is a main entry point (not requiring any other information in
338 * the Intent), and the LAUNCHER category says that this entry point should be
339 * listed in the application launcher.</p>
340 * <li><pre>
341 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700342 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
343 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
344 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
345 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700346 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700347 * &lt;/intent-filter&gt;</pre>
348 * <p>This declares the things that the activity can do on a directory of
349 * notes. The type being supported is given with the &lt;type&gt; tag, where
350 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
351 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
352 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
353 * The activity allows the user to view or edit the directory of data (via
354 * the VIEW and EDIT actions), or to pick a particular note and return it
355 * to the caller (via the PICK action). Note also the DEFAULT category
356 * supplied here: this is <em>required</em> for the
357 * {@link Context#startActivity Context.startActivity} method to resolve your
358 * activity when its component name is not explicitly specified.</p>
359 * <li><pre>
360 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700361 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
362 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
363 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700364 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700365 * <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 -0700366 * the user without needing to know where it came from. The data type
367 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
368 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
369 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
370 * The GET_CONTENT action is similar to the PICK action, where the activity
371 * will return to its caller a piece of data selected by the user. Here,
372 * however, the caller specifies the type of data they desire instead of
373 * the type of data the user will be picking from.</p>
374 * </ol>
375 *
376 * <p>Given these capabilities, the following intents will resolve to the
377 * NotesList activity:</p>
378 *
379 * <ul>
380 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
381 * activities that can be used as top-level entry points into an
382 * application.</p>
383 * <li> <p><b>{ action=android.app.action.MAIN,
384 * category=android.app.category.LAUNCHER }</b> is the actual intent
385 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700386 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700387 * data=content://com.google.provider.NotePad/notes }</b>
388 * displays a list of all the notes under
389 * "content://com.google.provider.NotePad/notes", which
390 * the user can browse through and see the details on.</p>
391 * <li> <p><b>{ action=android.app.action.PICK
392 * data=content://com.google.provider.NotePad/notes }</b>
393 * provides a list of the notes under
394 * "content://com.google.provider.NotePad/notes", from which
395 * the user can pick a note whose data URL is returned back to the caller.</p>
396 * <li> <p><b>{ action=android.app.action.GET_CONTENT
397 * type=vnd.android.cursor.item/vnd.google.note }</b>
398 * is similar to the pick action, but allows the caller to specify the
399 * kind of data they want back so that the system can find the appropriate
400 * activity to pick something of that data type.</p>
401 * </ul>
402 *
403 * <p>The second activity,
404 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
405 * note entry and allows them to edit it. It can do two things as described
406 * by its two intent templates:
407 * <ol>
408 * <li><pre>
409 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700410 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
411 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
412 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
413 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700414 * &lt;/intent-filter&gt;</pre>
415 * <p>The first, primary, purpose of this activity is to let the user interact
416 * with a single note, as decribed by the MIME type
417 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
418 * either VIEW a note or allow the user to EDIT it. Again we support the
419 * DEFAULT category to allow the activity to be launched without explicitly
420 * specifying its component.</p>
421 * <li><pre>
422 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700423 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
424 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
425 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700426 * &lt;/intent-filter&gt;</pre>
427 * <p>The secondary use of this activity is to insert a new note entry into
428 * an existing directory of notes. This is used when the user creates a new
429 * note: the INSERT action is executed on the directory of notes, causing
430 * this activity to run and have the user create the new note data which
431 * it then adds to the content provider.</p>
432 * </ol>
433 *
434 * <p>Given these capabilities, the following intents will resolve to the
435 * NoteEditor activity:</p>
436 *
437 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700438 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700439 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
440 * shows the user the content of note <var>{ID}</var>.</p>
441 * <li> <p><b>{ action=android.app.action.EDIT
442 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
443 * allows the user to edit the content of note <var>{ID}</var>.</p>
444 * <li> <p><b>{ action=android.app.action.INSERT
445 * data=content://com.google.provider.NotePad/notes }</b>
446 * creates a new, empty note in the notes list at
447 * "content://com.google.provider.NotePad/notes"
448 * and allows the user to edit it. If they keep their changes, the URI
449 * of the newly created note is returned to the caller.</p>
450 * </ul>
451 *
452 * <p>The last activity,
453 * <code>com.android.notepad.TitleEditor</code>, allows the user to
454 * edit the title of a note. This could be implemented as a class that the
455 * application directly invokes (by explicitly setting its component in
456 * the Intent), but here we show a way you can publish alternative
457 * operations on existing data:</p>
458 *
459 * <pre>
460 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700461 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
463 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
464 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
465 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700466 * &lt;/intent-filter&gt;</pre>
467 *
468 * <p>In the single intent template here, we
469 * have created our own private action called
470 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
471 * edit the title of a note. It must be invoked on a specific note
472 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
473 * view and edit actions, but here displays and edits the title contained
474 * in the note data.
475 *
476 * <p>In addition to supporting the default category as usual, our title editor
477 * also supports two other standard categories: ALTERNATIVE and
478 * SELECTED_ALTERNATIVE. Implementing
479 * these categories allows others to find the special action it provides
480 * without directly knowing about it, through the
481 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
482 * more often to build dynamic menu items with
483 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
484 * template here was also supply an explicit name for the template
485 * (via <code>android:label="@string/resolve_title"</code>) to better control
486 * what the user sees when presented with this activity as an alternative
487 * action to the data they are viewing.
488 *
489 * <p>Given these capabilities, the following intent will resolve to the
490 * TitleEditor activity:</p>
491 *
492 * <ul>
493 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
494 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
495 * displays and allows the user to edit the title associated
496 * with note <var>{ID}</var>.</p>
497 * </ul>
498 *
499 * <h3>Standard Activity Actions</h3>
500 *
501 * <p>These are the current standard actions that Intent defines for launching
502 * activities (usually through {@link Context#startActivity}. The most
503 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
504 * {@link #ACTION_EDIT}.
505 *
506 * <ul>
507 * <li> {@link #ACTION_MAIN}
508 * <li> {@link #ACTION_VIEW}
509 * <li> {@link #ACTION_ATTACH_DATA}
510 * <li> {@link #ACTION_EDIT}
511 * <li> {@link #ACTION_PICK}
512 * <li> {@link #ACTION_CHOOSER}
513 * <li> {@link #ACTION_GET_CONTENT}
514 * <li> {@link #ACTION_DIAL}
515 * <li> {@link #ACTION_CALL}
516 * <li> {@link #ACTION_SEND}
517 * <li> {@link #ACTION_SENDTO}
518 * <li> {@link #ACTION_ANSWER}
519 * <li> {@link #ACTION_INSERT}
520 * <li> {@link #ACTION_DELETE}
521 * <li> {@link #ACTION_RUN}
522 * <li> {@link #ACTION_SYNC}
523 * <li> {@link #ACTION_PICK_ACTIVITY}
524 * <li> {@link #ACTION_SEARCH}
525 * <li> {@link #ACTION_WEB_SEARCH}
526 * <li> {@link #ACTION_FACTORY_TEST}
527 * </ul>
528 *
529 * <h3>Standard Broadcast Actions</h3>
530 *
531 * <p>These are the current standard actions that Intent defines for receiving
532 * broadcasts (usually through {@link Context#registerReceiver} or a
533 * &lt;receiver&gt; tag in a manifest).
534 *
535 * <ul>
536 * <li> {@link #ACTION_TIME_TICK}
537 * <li> {@link #ACTION_TIME_CHANGED}
538 * <li> {@link #ACTION_TIMEZONE_CHANGED}
539 * <li> {@link #ACTION_BOOT_COMPLETED}
540 * <li> {@link #ACTION_PACKAGE_ADDED}
541 * <li> {@link #ACTION_PACKAGE_CHANGED}
542 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 * <li> {@link #ACTION_PACKAGE_RESTARTED}
544 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000545 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
546 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700547 * <li> {@link #ACTION_UID_REMOVED}
548 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700549 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700550 * <li> {@link #ACTION_POWER_DISCONNECTED}
551 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700552 * </ul>
553 *
554 * <h3>Standard Categories</h3>
555 *
556 * <p>These are the current standard categories that can be used to further
557 * clarify an Intent via {@link #addCategory}.
558 *
559 * <ul>
560 * <li> {@link #CATEGORY_DEFAULT}
561 * <li> {@link #CATEGORY_BROWSABLE}
562 * <li> {@link #CATEGORY_TAB}
563 * <li> {@link #CATEGORY_ALTERNATIVE}
564 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
565 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800566 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * <li> {@link #CATEGORY_HOME}
568 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700569 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400570 * <li> {@link #CATEGORY_CAR_DOCK}
571 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500572 * <li> {@link #CATEGORY_LE_DESK_DOCK}
573 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200574 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700575 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800576 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700577 * </ul>
578 *
579 * <h3>Standard Extra Data</h3>
580 *
581 * <p>These are the current standard fields that can be used as extra data via
582 * {@link #putExtra}.
583 *
584 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800585 * <li> {@link #EXTRA_ALARM_COUNT}
586 * <li> {@link #EXTRA_BCC}
587 * <li> {@link #EXTRA_CC}
588 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
589 * <li> {@link #EXTRA_DATA_REMOVED}
590 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500591 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
592 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800593 * <li> {@link #EXTRA_DOCK_STATE_CAR}
594 * <li> {@link #EXTRA_DOCK_STATE_DESK}
595 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
596 * <li> {@link #EXTRA_DONT_KILL_APP}
597 * <li> {@link #EXTRA_EMAIL}
598 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700599 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700601 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700603 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800604 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
605 * <li> {@link #EXTRA_REPLACING}
606 * <li> {@link #EXTRA_SHORTCUT_ICON}
607 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
608 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800610 * <li> {@link #EXTRA_SHORTCUT_NAME}
611 * <li> {@link #EXTRA_SUBJECT}
612 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700613 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800614 * <li> {@link #EXTRA_TITLE}
615 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 * </ul>
617 *
618 * <h3>Flags</h3>
619 *
620 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800621 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
622 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700623 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800624public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700625 private static final String ATTR_ACTION = "action";
626 private static final String TAG_CATEGORIES = "categories";
627 private static final String ATTR_CATEGORY = "category";
628 private static final String TAG_EXTRA = "extra";
629 private static final String ATTR_TYPE = "type";
630 private static final String ATTR_COMPONENT = "component";
631 private static final String ATTR_DATA = "data";
632 private static final String ATTR_FLAGS = "flags";
633
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700634 // ---------------------------------------------------------------------
635 // ---------------------------------------------------------------------
636 // Standard intent activity actions (see action variable).
637
638 /**
639 * Activity Action: Start as a main entry point, does not expect to
640 * receive data.
641 * <p>Input: nothing
642 * <p>Output: nothing
643 */
644 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
645 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800646
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700647 /**
648 * Activity Action: Display the data to the user. This is the most common
649 * action performed on data -- it is the generic action you can use on
650 * a piece of data to get the most reasonable thing to occur. For example,
651 * when used on a contacts entry it will view the entry; when used on a
652 * mailto: URI it will bring up a compose window filled with the information
653 * supplied by the URI; when used with a tel: URI it will invoke the
654 * dialer.
655 * <p>Input: {@link #getData} is URI from which to retrieve data.
656 * <p>Output: nothing.
657 */
658 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
659 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800660
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700661 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700662 * Extra that can be included on activity intents coming from the storage UI
663 * when it launches sub-activities to manage various types of storage. For example,
664 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
665 * the images on the device, and in that case also include this extra to tell the
666 * app it is coming from the storage UI so should help the user manage storage of
667 * this type.
668 */
669 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
670
671 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700672 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
673 * performed on a piece of data.
674 */
675 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800676
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700677 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900678 * Activity Action: Quick view the data. Launches a quick viewer for
679 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900680 * <p>Activities handling this intent action should handle the vast majority of
681 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700682 * <p>Quick viewers must render the quick view image locally, and must not send
683 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900684 * <p>Input: {@link #getData} is a mandatory content URI of the item to
685 * preview. {@link #getClipData} contains an optional list of content URIs
686 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
687 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700688 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
689 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700690 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900691 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700692 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700693 */
694 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
695 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
696
697 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700698 * Used to indicate that some piece of data should be attached to some other
699 * place. For example, image data could be attached to a contact. It is up
700 * to the recipient to decide where the data should be attached; the intent
701 * does not specify the ultimate destination.
702 * <p>Input: {@link #getData} is URI of data to be attached.
703 * <p>Output: nothing.
704 */
705 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
706 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800707
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700708 /**
709 * Activity Action: Provide explicit editable access to the given data.
710 * <p>Input: {@link #getData} is URI of data to be edited.
711 * <p>Output: nothing.
712 */
713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714 public static final String ACTION_EDIT = "android.intent.action.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 existing item, or insert a new item, and then edit it.
718 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
719 * The extras can contain type specific data to pass through to the editing/creating
720 * activity.
721 * <p>Output: The URI of the item that was picked. This must be a content:
722 * URI so that any receiver can access it.
723 */
724 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
725 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800726
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700727 /**
728 * Activity Action: Pick an item from the data, returning what was selected.
729 * <p>Input: {@link #getData} is URI containing a directory of data
730 * (vnd.android.cursor.dir/*) from which to pick an item.
731 * <p>Output: The URI of the item that was picked.
732 */
733 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
734 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800735
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700736 /**
737 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800738 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800739 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
740 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700741 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
742 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800743 * (value: ShortcutIconResource).</p>
744 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800745 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700746 * @see #EXTRA_SHORTCUT_INTENT
747 * @see #EXTRA_SHORTCUT_NAME
748 * @see #EXTRA_SHORTCUT_ICON
749 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
750 * @see android.content.Intent.ShortcutIconResource
751 */
752 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
753 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
754
755 /**
756 * The name of the extra used to define the Intent of a shortcut.
757 *
758 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800759 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700760 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800761 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700762 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
763 /**
764 * The name of the extra used to define the name of a shortcut.
765 *
766 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800767 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800769 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700770 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
771 /**
772 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
773 *
774 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800777 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700778 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
779 /**
780 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
781 *
782 * @see #ACTION_CREATE_SHORTCUT
783 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800784 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700785 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800786 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700787 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
788 "android.intent.extra.shortcut.ICON_RESOURCE";
789
790 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500791 * An activity that provides a user interface for adjusting application preferences.
792 * Optional but recommended settings for all applications which have settings.
793 */
794 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
795 public static final String ACTION_APPLICATION_PREFERENCES
796 = "android.intent.action.APPLICATION_PREFERENCES";
797
798 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700799 * Activity Action: Launch an activity showing the app information.
800 * For applications which install other applications (such as app stores), it is recommended
801 * to handle this action for providing the app information to the user.
802 *
803 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
804 * to be displayed.
805 * <p>Output: Nothing.
806 */
807 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
808 public static final String ACTION_SHOW_APP_INFO
809 = "android.intent.action.SHOW_APP_INFO";
810
811 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800812 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700813 *
814 * @see Intent#ACTION_CREATE_SHORTCUT
815 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800816 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
817 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700818 */
819 public static class ShortcutIconResource implements Parcelable {
820 /**
821 * The package name of the application containing the icon.
822 */
823 public String packageName;
824
825 /**
826 * The resource name of the icon, including package, name and type.
827 */
828 public String resourceName;
829
830 /**
831 * Creates a new ShortcutIconResource for the specified context and resource
832 * identifier.
833 *
834 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700835 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700836 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700837 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700838 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700839 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700840 ShortcutIconResource icon = new ShortcutIconResource();
841 icon.packageName = context.getPackageName();
842 icon.resourceName = context.getResources().getResourceName(resourceId);
843 return icon;
844 }
845
846 /**
847 * Used to read a ShortcutIconResource from a Parcel.
848 */
849 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
850 new Parcelable.Creator<ShortcutIconResource>() {
851
852 public ShortcutIconResource createFromParcel(Parcel source) {
853 ShortcutIconResource icon = new ShortcutIconResource();
854 icon.packageName = source.readString();
855 icon.resourceName = source.readString();
856 return icon;
857 }
858
859 public ShortcutIconResource[] newArray(int size) {
860 return new ShortcutIconResource[size];
861 }
862 };
863
864 /**
865 * No special parcel contents.
866 */
867 public int describeContents() {
868 return 0;
869 }
870
871 public void writeToParcel(Parcel dest, int flags) {
872 dest.writeString(packageName);
873 dest.writeString(resourceName);
874 }
875
876 @Override
877 public String toString() {
878 return resourceName;
879 }
880 }
881
882 /**
883 * Activity Action: Display an activity chooser, allowing the user to pick
884 * what they want to before proceeding. This can be used as an alternative
885 * to the standard activity picker that is displayed by the system when
886 * you try to start an activity with multiple possible matches, with these
887 * differences in behavior:
888 * <ul>
889 * <li>You can specify the title that will appear in the activity chooser.
890 * <li>The user does not have the option to make one of the matching
891 * activities a preferred activity, and all possible activities will
892 * always be shown even if one of them is currently marked as the
893 * preferred activity.
894 * </ul>
895 * <p>
896 * This action should be used when the user will naturally expect to
897 * select an activity in order to proceed. An example if when not to use
898 * it is when the user clicks on a "mailto:" link. They would naturally
899 * expect to go directly to their mail app, so startActivity() should be
900 * called directly: it will
901 * either launch the current preferred app, or put up a dialog allowing the
902 * user to pick an app to use and optionally marking that as preferred.
903 * <p>
904 * In contrast, if the user is selecting a menu item to send a picture
905 * they are viewing to someone else, there are many different things they
906 * may want to do at this point: send it through e-mail, upload it to a
907 * web service, etc. In this case the CHOOSER action should be used, to
908 * always present to the user a list of the things they can do, with a
909 * nice title given by the caller such as "Send this photo with:".
910 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700911 * If you need to grant URI permissions through a chooser, you must specify
912 * the permissions to be granted on the ACTION_CHOOSER Intent
913 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
914 * {@link #setClipData} to specify the URIs to be granted as well as
915 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
916 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
917 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700918 * As a convenience, an Intent of this form can be created with the
919 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700920 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700921 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700922 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
923 * and can optionally have a {@link #EXTRA_TITLE} field containing the
924 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700925 * <p>
926 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700927 */
928 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
929 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
930
931 /**
932 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
933 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700934 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
935 * target intent, also optionally supplying a title. If the target
936 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
937 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
938 * set in the returned chooser intent, with its ClipData set appropriately:
939 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500940 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700941 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700942 * @param target The Intent that the user will be selecting an activity
943 * to perform.
944 * @param title Optional title that will be displayed in the chooser.
945 * @return Return a new Intent object that you can hand to
946 * {@link Context#startActivity(Intent) Context.startActivity()} and
947 * related methods.
948 */
949 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700950 return createChooser(target, title, null);
951 }
952
953 /**
954 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
955 *
956 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
957 * target intent, also optionally supplying a title. If the target
958 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
959 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
960 * set in the returned chooser intent, with its ClipData set appropriately:
961 * either a direct reflection of {@link #getClipData()} if that is non-null,
962 * or a new ClipData built from {@link #getData()}.</p>
963 *
964 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
965 * when the user makes a choice. This can be useful if the calling application wants
966 * to remember the last chosen target and surface it as a more prominent or one-touch
967 * affordance elsewhere in the UI for next time.</p>
968 *
969 * @param target The Intent that the user will be selecting an activity
970 * to perform.
971 * @param title Optional title that will be displayed in the chooser.
972 * @param sender Optional IntentSender to be called when a choice is made.
973 * @return Return a new Intent object that you can hand to
974 * {@link Context#startActivity(Intent) Context.startActivity()} and
975 * related methods.
976 */
977 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700978 Intent intent = new Intent(ACTION_CHOOSER);
979 intent.putExtra(EXTRA_INTENT, target);
980 if (title != null) {
981 intent.putExtra(EXTRA_TITLE, title);
982 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700983
Adam Powell0b3c1122014-10-09 12:50:14 -0700984 if (sender != null) {
985 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
986 }
987
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700988 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700989 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
990 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
991 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700992 if (permFlags != 0) {
993 ClipData targetClipData = target.getClipData();
994 if (targetClipData == null && target.getData() != null) {
995 ClipData.Item item = new ClipData.Item(target.getData());
996 String[] mimeTypes;
997 if (target.getType() != null) {
998 mimeTypes = new String[] { target.getType() };
999 } else {
1000 mimeTypes = new String[] { };
1001 }
1002 targetClipData = new ClipData(null, mimeTypes, item);
1003 }
1004 if (targetClipData != null) {
1005 intent.setClipData(targetClipData);
1006 intent.addFlags(permFlags);
1007 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001008 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001009
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001010 return intent;
1011 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001013 /**
1014 * Activity Action: Allow the user to select a particular kind of data and
1015 * return it. This is different than {@link #ACTION_PICK} in that here we
1016 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001017 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001018 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001019 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001020 * etc.
1021 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001022 * 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 -07001023 * of data, such as a person contact, you set the MIME type to the kind of
1024 * data you want and launch it with {@link Context#startActivity(Intent)}.
1025 * The system will then launch the best application to select that kind
1026 * of data for you.
1027 * <p>
1028 * You may also be interested in any of a set of types of content the user
1029 * can pick. For example, an e-mail application that wants to allow the
1030 * user to add an attachment to an e-mail message can use this action to
1031 * bring up a list of all of the types of content the user can attach.
1032 * <p>
1033 * In this case, you should wrap the GET_CONTENT intent with a chooser
1034 * (through {@link #createChooser}), which will give the proper interface
1035 * for the user to pick how to send your data and allow you to specify
1036 * a prompt indicating what they are doing. You will usually specify a
1037 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1038 * broad range of content types the user can select from.
1039 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001040 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001041 * only pick from data that can be represented as a stream. This is
1042 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1043 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001044 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001045 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001046 * is locally available on the device. For example, if this extra is set
1047 * to true then an image picker should not show any pictures that are available
1048 * from a remote server but not already on the local device (thus requiring
1049 * they be downloaded when opened).
1050 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001051 * If the caller can handle multiple returned items (the user performing
1052 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1053 * to indicate this.
1054 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001055 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1056 * that no URI is supplied in the intent, as there are no constraints on
1057 * where the returned data originally comes from. You may also include the
1058 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001059 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001060 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1061 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001062 * <p>
1063 * Output: The URI of the item that was picked. This must be a content:
1064 * URI so that any receiver can access it.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1068 /**
1069 * Activity Action: Dial a number as specified by the data. This shows a
1070 * UI with the number being dialed, allowing the user to explicitly
1071 * initiate the call.
1072 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1073 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1074 * number.
1075 * <p>Output: nothing.
1076 */
1077 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1078 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1079 /**
1080 * Activity Action: Perform a call to someone specified by the data.
1081 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1082 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1083 * number.
1084 * <p>Output: nothing.
1085 *
1086 * <p>Note: there will be restrictions on which applications can initiate a
1087 * call; most applications should use the {@link #ACTION_DIAL}.
1088 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1089 * numbers. Applications can <strong>dial</strong> emergency numbers using
1090 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001091 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001092 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001093 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001094 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001095 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001096 */
1097 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1098 public static final String ACTION_CALL = "android.intent.action.CALL";
1099 /**
1100 * Activity Action: Perform a call to an emergency number specified by the
1101 * data.
1102 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1103 * tel: URI of an explicit phone number.
1104 * <p>Output: nothing.
1105 * @hide
1106 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001107 @SystemApi
1108 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001109 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1110 /**
1111 * Activity action: Perform a call to any number (emergency or not)
1112 * specified by the data.
1113 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1114 * tel: URI of an explicit phone number.
1115 * <p>Output: nothing.
1116 * @hide
1117 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001118 @SystemApi
1119 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001120 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001121
Santos Cordon15a13782015-03-31 18:32:31 -07001122 /**
fionaxuadfe7002017-02-17 17:20:46 -08001123 * Activity Action: Main entry point for carrier setup apps.
1124 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1125 * carrier service and typically require
1126 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1127 * fulfill their duties.
1128 */
1129 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1130 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1131 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001132 * Activity Action: Send a message to someone specified by the data.
1133 * <p>Input: {@link #getData} is URI describing the target.
1134 * <p>Output: nothing.
1135 */
1136 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1137 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1138 /**
1139 * Activity Action: Deliver some data to someone else. Who the data is
1140 * being delivered to is not specified; it is up to the receiver of this
1141 * action to ask the user where the data should be sent.
1142 * <p>
1143 * When launching a SEND intent, you should usually wrap it in a chooser
1144 * (through {@link #createChooser}), which will give the proper interface
1145 * for the user to pick how to send your data and allow you to specify
1146 * a prompt indicating what they are doing.
1147 * <p>
1148 * Input: {@link #getType} is the MIME type of the data being sent.
1149 * get*Extra can have either a {@link #EXTRA_TEXT}
1150 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1151 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1152 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1153 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001154 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1155 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1156 * your text with HTML formatting.
1157 * <p>
1158 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1159 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1160 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1161 * content: URIs and other advanced features of {@link ClipData}. If
1162 * using this approach, you still must supply the same data through the
1163 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1164 * for compatibility with old applications. If you don't set a ClipData,
1165 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001166 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001167 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1168 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1169 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1170 * be openable only as asset typed files using
1171 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1172 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001173 * Optional standard extras, which may be interpreted by some recipients as
1174 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1175 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1176 * <p>
1177 * Output: nothing.
1178 */
1179 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1180 public static final String ACTION_SEND = "android.intent.action.SEND";
1181 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001182 * Activity Action: Deliver multiple data to someone else.
1183 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001184 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001185 * <p>
1186 * Input: {@link #getType} is the MIME type of the data being sent.
1187 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001188 * #EXTRA_STREAM} field, containing the data to be sent. If using
1189 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1190 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001191 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001192 * Multiple types are supported, and receivers should handle mixed types
1193 * whenever possible. The right way for the receiver to check them is to
1194 * use the content resolver on each URI. The intent sender should try to
1195 * put the most concrete mime type in the intent type, but it can fall
1196 * back to {@literal <type>/*} or {@literal *}/* as needed.
1197 * <p>
1198 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1199 * be image/jpg, but if you are sending image/jpg and image/png, then the
1200 * intent's type should be image/*.
1201 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001202 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1203 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1204 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1205 * content: URIs and other advanced features of {@link ClipData}. If
1206 * using this approach, you still must supply the same data through the
1207 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1208 * for compatibility with old applications. If you don't set a ClipData,
1209 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1210 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001211 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1212 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1213 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1214 * be openable only as asset typed files using
1215 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1216 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001217 * Optional standard extras, which may be interpreted by some recipients as
1218 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1219 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1220 * <p>
1221 * Output: nothing.
1222 */
1223 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1224 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1225 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001226 * Activity Action: Handle an incoming phone call.
1227 * <p>Input: nothing.
1228 * <p>Output: nothing.
1229 */
1230 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1231 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1232 /**
1233 * Activity Action: Insert an empty item into the given container.
1234 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1235 * in which to place the data.
1236 * <p>Output: URI of the new data that was created.
1237 */
1238 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1239 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1240 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001241 * Activity Action: Create a new item in the given container, initializing it
1242 * from the current contents of the clipboard.
1243 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1244 * in which to place the data.
1245 * <p>Output: URI of the new data that was created.
1246 */
1247 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1248 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1249 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001250 * Activity Action: Delete the given data from its container.
1251 * <p>Input: {@link #getData} is URI of data to be deleted.
1252 * <p>Output: nothing.
1253 */
1254 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1255 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1256 /**
1257 * Activity Action: Run the data, whatever that means.
1258 * <p>Input: ? (Note: this is currently specific to the test harness.)
1259 * <p>Output: nothing.
1260 */
1261 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1262 public static final String ACTION_RUN = "android.intent.action.RUN";
1263 /**
1264 * Activity Action: Perform a data synchronization.
1265 * <p>Input: ?
1266 * <p>Output: ?
1267 */
1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1269 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1270 /**
1271 * Activity Action: Pick an activity given an intent, returning the class
1272 * selected.
1273 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1274 * used with {@link PackageManager#queryIntentActivities} to determine the
1275 * set of activities from which to pick.
1276 * <p>Output: Class name of the activity that was selected.
1277 */
1278 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1279 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1280 /**
1281 * Activity Action: Perform a search.
1282 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1283 * is the text to search for. If empty, simply
1284 * enter your search results Activity with the search UI activated.
1285 * <p>Output: nothing.
1286 */
1287 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1289 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001290 * Activity Action: Start the platform-defined tutorial
1291 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1292 * is the text to search for. If empty, simply
1293 * enter your search results Activity with the search UI activated.
1294 * <p>Output: nothing.
1295 */
1296 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1297 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1298 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001299 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001300 * <p>
1301 * Input: {@link android.app.SearchManager#QUERY
1302 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1303 * a url starts with http or https, the site will be opened. If it is plain
1304 * text, Google search will be applied.
1305 * <p>
1306 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001307 */
1308 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1309 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001310
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001311 /**
Jim Miller07994402012-05-02 14:22:27 -07001312 * Activity Action: Perform assist action.
1313 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001314 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1315 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001316 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1317 * information.
Jim Miller07994402012-05-02 14:22:27 -07001318 * Output: nothing.
1319 */
1320 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1321 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001322
1323 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001324 * Activity Action: Perform voice assist action.
1325 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001326 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1327 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001328 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001329 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001330 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001331 */
Amith Yamasani16452032017-03-03 10:15:57 -08001332 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001333 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1334 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1335
1336 /**
Adam Skory7140a252013-09-11 12:04:58 +01001337 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1338 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001339 */
1340 public static final String EXTRA_ASSIST_PACKAGE
1341 = "android.intent.extra.ASSIST_PACKAGE";
1342
1343 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001344 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1345 * application package at the time the assist was invoked.
1346 */
1347 public static final String EXTRA_ASSIST_UID
1348 = "android.intent.extra.ASSIST_UID";
1349
1350 /**
Adam Skory7140a252013-09-11 12:04:58 +01001351 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1352 * information supplied by the current foreground app at the time of the assist request.
1353 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001354 */
1355 public static final String EXTRA_ASSIST_CONTEXT
1356 = "android.intent.extra.ASSIST_CONTEXT";
1357
Jim Miller07994402012-05-02 14:22:27 -07001358 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001359 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1360 * keyboard as the primary input device for assistance.
1361 */
1362 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1363 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1364
1365 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001366 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1367 * that was used to invoke the assist.
1368 */
1369 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1370 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1371
1372 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001373 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001374 * <p>Input: Nothing.
1375 * <p>Output: nothing.
1376 */
1377 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1378 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1379 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001380 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001381 * <p>Input: Nothing.
1382 * <p>Output: Nothing.
1383 */
1384 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1385 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1386
1387 /**
1388 * Activity Action: Show activity for reporting a bug.
1389 * <p>Input: Nothing.
1390 * <p>Output: Nothing.
1391 */
1392 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1393 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1394
1395 /**
1396 * Activity Action: Main entry point for factory tests. Only used when
1397 * the device is booting in factory test node. The implementing package
1398 * must be installed in the system image.
1399 * <p>Input: nothing
1400 * <p>Output: nothing
1401 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001402 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001403 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1404
1405 /**
1406 * Activity Action: The user pressed the "call" button to go to the dialer
1407 * or other appropriate UI for placing a call.
1408 * <p>Input: Nothing.
1409 * <p>Output: Nothing.
1410 */
1411 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1412 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1413
1414 /**
1415 * Activity Action: Start Voice Command.
1416 * <p>Input: Nothing.
1417 * <p>Output: Nothing.
1418 */
1419 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1420 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001421
1422 /**
1423 * Activity Action: Start action associated with long pressing on the
1424 * search key.
1425 * <p>Input: Nothing.
1426 * <p>Output: Nothing.
1427 */
1428 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001430
Jacek Surazski86b6c532009-05-13 14:38:28 +02001431 /**
1432 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1433 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001434 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001435 * <p>Input: No data is specified. The bug report is passed in using
1436 * an {@link #EXTRA_BUG_REPORT} field.
1437 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001438 *
1439 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001440 */
1441 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1442 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001443
1444 /**
1445 * Activity Action: Show power usage information to the user.
1446 * <p>Input: Nothing.
1447 * <p>Output: Nothing.
1448 */
1449 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1450 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001451
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001452 /**
Russell Brenner880994d2017-02-24 11:11:47 -08001453 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1454 * to run.
1455 * <p>Input: Nothing.
1456 * <p>Output: Nothing.
1457 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1458 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1459 * @hide
1460 */
1461 @Deprecated
1462 @SystemApi
1463 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1464 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1465
1466 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001467 * Activity Action: Setup wizard to launch after a platform update. This
1468 * activity should have a string meta-data field associated with it,
1469 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1470 * the platform for setup. The activity will be launched only if
1471 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1472 * same value.
1473 * <p>Input: Nothing.
1474 * <p>Output: Nothing.
1475 * @hide
1476 */
Russell Brenner880994d2017-02-24 11:11:47 -08001477 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001478 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1479 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001480
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001481 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001482 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1483 * <p>Input: Nothing.
1484 * <p>Output: Nothing.
1485 * @hide
1486 */
1487 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1488 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001489 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001490
1491 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001492 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1493 * <p>Input: Nothing.
1494 * <p>Output: Nothing.
1495 * @hide
1496 */
1497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1498 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001499 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001500
1501 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001502 * Activity Action: Show settings for managing network data usage of a
1503 * specific application. Applications should define an activity that offers
1504 * options to control data usage.
1505 */
1506 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1507 public static final String ACTION_MANAGE_NETWORK_USAGE =
1508 "android.intent.action.MANAGE_NETWORK_USAGE";
1509
1510 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001511 * Activity Action: Launch application installer.
1512 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001513 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001514 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1515 * you can also use "package:<package-name>" to install an application for the
1516 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001517 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1518 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1519 * <p>
1520 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1521 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001522 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001523 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001524 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1525 * in order to launch the application installer.
1526 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001527 *
1528 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1529 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1530 * @see #EXTRA_RETURN_RESULT
1531 */
1532 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1533 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1534
1535 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001536 * @hide
1537 * @deprecated Do not use. This will go away.
1538 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1539 */
1540 @SystemApi
1541 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1542 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1543 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1544 /**
1545 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001546 * <p class="note">
1547 * This is a protected intent that can only be sent by the system.
1548 * </p>
1549 *
1550 * @hide
1551 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001552 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001553 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001554 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1555 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001556
1557 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001558 * @hide
1559 * @deprecated Do not use. This will go away.
1560 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1561 */
1562 @SystemApi
1563 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1564 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1565 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1566 /**
1567 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001568 * <p>
1569 * The system will have a persistent connection to this service.
1570 * This is a protected intent that can only be sent by the system.
1571 * </p>
1572 *
1573 * @hide
1574 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001575 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001576 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001577 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1578 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001579
1580 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001581 * @hide
1582 * @deprecated Do not use. This will go away.
1583 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1584 */
1585 @SystemApi
1586 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1587 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1588 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1589 /**
1590 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001591 *
1592 * <p class="note">
1593 * This is a protected intent that can only be sent by the system.
1594 * </p>
1595 *
1596 * @hide
1597 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001598 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001599 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001600 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1601 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001602
1603 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001604 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1605 * package. Specifies the installer package name; this package will receive the
1606 * {@link #ACTION_APP_ERROR} intent.
1607 */
1608 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1609 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1610
1611 /**
1612 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1613 * package. Specifies that the application being installed should not be
1614 * treated as coming from an unknown source, but as coming from the app
1615 * invoking the Intent. For this to work you must start the installer with
1616 * startActivityForResult().
1617 */
1618 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1619 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1620
1621 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001622 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1623 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001624 * data field originated from.
1625 */
rich cannings706e8ba2012-08-20 13:20:14 -07001626 public static final String EXTRA_ORIGINATING_URI
1627 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001628
1629 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001630 * This extra can be used with any Intent used to launch an activity, supplying information
1631 * about who is launching that activity. This field contains a {@link android.net.Uri}
1632 * object, typically an http: or https: URI of the web site that the referral came from;
1633 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1634 * a native application that it came from.
1635 *
1636 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1637 * instead of directly retrieving the extra. It is also valid for applications to
1638 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1639 * a string, not a Uri; the field here, if supplied, will always take precedence,
1640 * however.</p>
1641 *
1642 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001643 */
1644 public static final String EXTRA_REFERRER
1645 = "android.intent.extra.REFERRER";
1646
1647 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001648 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1649 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1650 * not be created, in particular when Intent extras are supplied through the
1651 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1652 * schemes.
1653 *
1654 * @see #EXTRA_REFERRER
1655 */
1656 public static final String EXTRA_REFERRER_NAME
1657 = "android.intent.extra.REFERRER_NAME";
1658
1659 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001660 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001661 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001662 * Currently only a system app that hosts the provider authority "downloads" or holds the
1663 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001664 * @hide
1665 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001666 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001667 public static final String EXTRA_ORIGINATING_UID
1668 = "android.intent.extra.ORIGINATING_UID";
1669
1670 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001671 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1672 * package. Tells the installer UI to skip the confirmation with the user
1673 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001674 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1675 * will no longer show an interstitial message about updating existing
1676 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001677 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001678 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001679 public static final String EXTRA_ALLOW_REPLACE
1680 = "android.intent.extra.ALLOW_REPLACE";
1681
1682 /**
1683 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1684 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1685 * return to the application the result code of the install/uninstall. The returned result
1686 * code will be {@link android.app.Activity#RESULT_OK} on success or
1687 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1688 */
1689 public static final String EXTRA_RETURN_RESULT
1690 = "android.intent.extra.RETURN_RESULT";
1691
1692 /**
1693 * Package manager install result code. @hide because result codes are not
1694 * yet ready to be exposed.
1695 */
1696 public static final String EXTRA_INSTALL_RESULT
1697 = "android.intent.extra.INSTALL_RESULT";
1698
1699 /**
1700 * Activity Action: Launch application uninstaller.
1701 * <p>
1702 * Input: The data must be a package: URI whose scheme specific part is
1703 * the package name of the current installed package to be uninstalled.
1704 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1705 * <p>
1706 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1707 * succeeded.
1708 */
1709 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1710 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1711
1712 /**
msnider3c191b82017-01-23 14:23:16 -08001713 * Activity Action: Launch application uninstaller.
1714 * <p>
1715 * Input: The data must be a package: URI whose scheme specific part is
1716 * the package name of the current installed package to be uninstalled.
1717 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1718 * <p>
1719 * Output: Nothing.
1720 * </p>
1721 */
1722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1723 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1724
1725 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001726 * Specify whether the package should be uninstalled for all users.
1727 * @hide because these should not be part of normal application flow.
1728 */
1729 public static final String EXTRA_UNINSTALL_ALL_USERS
1730 = "android.intent.extra.UNINSTALL_ALL_USERS";
1731
1732 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001733 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1734 * describing the last run version of the platform that was setup.
1735 * @hide
1736 */
1737 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1738
Svet Ganov3695b8a2015-03-24 16:30:25 -07001739 /**
1740 * Activity action: Launch UI to manage the permissions of an app.
1741 * <p>
1742 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1743 * will be managed by the launched UI.
1744 * </p>
1745 * <p>
1746 * Output: Nothing.
1747 * </p>
1748 *
1749 * @see #EXTRA_PACKAGE_NAME
1750 *
1751 * @hide
1752 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001753 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001754 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1755 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1756 "android.intent.action.MANAGE_APP_PERMISSIONS";
1757
1758 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001759 * Activity action: Launch UI to manage permissions.
1760 * <p>
1761 * Input: Nothing.
1762 * </p>
1763 * <p>
1764 * Output: Nothing.
1765 * </p>
1766 *
1767 * @hide
1768 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001769 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001770 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1771 public static final String ACTION_MANAGE_PERMISSIONS =
1772 "android.intent.action.MANAGE_PERMISSIONS";
1773
1774 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001775 * Activity action: Launch UI to review permissions for an app.
1776 * The system uses this intent if permission review for apps not
1777 * supporting the new runtime permissions model is enabled. In
1778 * this mode a permission review is required before any of the
1779 * app components can run.
1780 * <p>
1781 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1782 * permissions will be reviewed (mandatory).
1783 * </p>
1784 * <p>
1785 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1786 * be fired after the permission review (optional).
1787 * </p>
1788 * <p>
1789 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1790 * be invoked after the permission review (optional).
1791 * </p>
1792 * <p>
1793 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1794 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1795 * </p>
1796 * <p>
1797 * Output: Nothing.
1798 * </p>
1799 *
1800 * @see #EXTRA_PACKAGE_NAME
1801 * @see #EXTRA_INTENT
1802 * @see #EXTRA_REMOTE_CALLBACK
1803 * @see #EXTRA_RESULT_NEEDED
1804 *
1805 * @hide
1806 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001807 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001808 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1809 public static final String ACTION_REVIEW_PERMISSIONS =
1810 "android.intent.action.REVIEW_PERMISSIONS";
1811
1812 /**
1813 * Intent extra: A callback for reporting remote result as a bundle.
1814 * <p>
1815 * Type: IRemoteCallback
1816 * </p>
1817 *
1818 * @hide
1819 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001820 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001821 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1822
1823 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001824 * Intent extra: An app package name.
1825 * <p>
1826 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001827 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001828 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001829 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001830 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1831
1832 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001833 * Intent extra: An app split name.
1834 * <p>
1835 * Type: String
1836 * </p>
1837 * @hide
1838 */
1839 @SystemApi
1840 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1841
1842 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001843 * Intent extra: A {@link ComponentName} value.
1844 * <p>
1845 * Type: String
1846 * </p>
1847 */
1848 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1849
1850 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001851 * Intent extra: An extra for specifying whether a result is needed.
1852 * <p>
1853 * Type: boolean
1854 * </p>
1855 *
1856 * @hide
1857 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001858 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001859 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1860
1861 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001862 * Activity action: Launch UI to manage which apps have a given permission.
1863 * <p>
1864 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1865 * to which will be managed by the launched UI.
1866 * </p>
1867 * <p>
1868 * Output: Nothing.
1869 * </p>
1870 *
1871 * @see #EXTRA_PERMISSION_NAME
1872 *
1873 * @hide
1874 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001875 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001876 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1877 public static final String ACTION_MANAGE_PERMISSION_APPS =
1878 "android.intent.action.MANAGE_PERMISSION_APPS";
1879
1880 /**
1881 * Intent extra: The name of a permission.
1882 * <p>
1883 * Type: String
1884 * </p>
1885 *
1886 * @hide
1887 */
1888 @SystemApi
1889 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1890
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001891 // ---------------------------------------------------------------------
1892 // ---------------------------------------------------------------------
1893 // Standard intent broadcast actions (see action variable).
1894
1895 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001896 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1897 * <p>
1898 * For historical reasons, the name of this broadcast action refers to the power
1899 * state of the screen but it is actually sent in response to changes in the
1900 * overall interactive state of the device.
1901 * </p><p>
1902 * This broadcast is sent when the device becomes non-interactive which may have
1903 * nothing to do with the screen turning off. To determine the
1904 * actual state of the screen, use {@link android.view.Display#getState}.
1905 * </p><p>
1906 * See {@link android.os.PowerManager#isInteractive} for details.
1907 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001908 * You <em>cannot</em> receive this through components declared in
1909 * manifests, only by explicitly registering for it with
1910 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1911 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001912 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001913 * <p class="note">This is a protected intent that can only be sent
1914 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001915 */
1916 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1917 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001918
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001919 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001920 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1921 * <p>
1922 * For historical reasons, the name of this broadcast action refers to the power
1923 * state of the screen but it is actually sent in response to changes in the
1924 * overall interactive state of the device.
1925 * </p><p>
1926 * This broadcast is sent when the device becomes interactive which may have
1927 * nothing to do with the screen turning on. To determine the
1928 * actual state of the screen, use {@link android.view.Display#getState}.
1929 * </p><p>
1930 * See {@link android.os.PowerManager#isInteractive} for details.
1931 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001932 * You <em>cannot</em> receive this through components declared in
1933 * manifests, only by explicitly registering for it with
1934 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1935 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001936 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001937 * <p class="note">This is a protected intent that can only be sent
1938 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001939 */
1940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1941 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001942
1943 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001944 * Broadcast Action: Sent after the system stops dreaming.
1945 *
1946 * <p class="note">This is a protected intent that can only be sent by the system.
1947 * It is only sent to registered receivers.</p>
1948 */
1949 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1950 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1951
1952 /**
1953 * Broadcast Action: Sent after the system starts dreaming.
1954 *
1955 * <p class="note">This is a protected intent that can only be sent by the system.
1956 * It is only sent to registered receivers.</p>
1957 */
1958 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1959 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1960
1961 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001962 * 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 -07001963 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001964 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001965 * <p class="note">This is a protected intent that can only be sent
1966 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001967 */
1968 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001969 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001970
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001971 /**
1972 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001973 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001974 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001975 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1976 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001977 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001978 * <p class="note">This is a protected intent that can only be sent
1979 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001980 */
1981 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1982 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1983 /**
1984 * Broadcast Action: The time was set.
1985 */
1986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1987 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1988 /**
1989 * Broadcast Action: The date has changed.
1990 */
1991 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1992 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1993 /**
1994 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1995 * <ul>
1996 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1997 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001998 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001999 * <p class="note">This is a protected intent that can only be sent
2000 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002001 */
2002 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2003 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2004 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002005 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2006 * DNS entries should be tossed.
2007 * @hide
2008 */
2009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2010 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2011 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002012 * Alarm Changed Action: This is broadcast when the AlarmClock
2013 * application's alarm is set or unset. It is used by the
2014 * AlarmClock application and the StatusBar service.
2015 * @hide
2016 */
2017 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2018 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002019
2020 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002021 * Broadcast Action: This is broadcast once, after the user has finished
2022 * booting, but while still in the "locked" state. It can be used to perform
2023 * application-specific initialization, such as installing alarms. You must
2024 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2025 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002026 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002027 * This broadcast is sent immediately at boot by all devices (regardless of
2028 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2029 * higher. Upon receipt of this broadcast, the user is still locked and only
2030 * device-protected storage can be accessed safely. If you want to access
2031 * credential-protected storage, you need to wait for the user to be
2032 * unlocked (typically by entering their lock pattern or PIN for the first
2033 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2034 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2035 * <p>
2036 * To receive this broadcast, your receiver component must be marked as
2037 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002038 * <p class="note">
2039 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002040 *
2041 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002042 */
2043 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2044 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2045
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002046 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002047 * Broadcast Action: This is broadcast once, after the user has finished
2048 * booting. It can be used to perform application-specific initialization,
2049 * such as installing alarms. You must hold the
2050 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2051 * order to receive this broadcast.
2052 * <p>
2053 * This broadcast is sent at boot by all devices (both with and without
2054 * direct boot support). Upon receipt of this broadcast, the user is
2055 * unlocked and both device-protected and credential-protected storage can
2056 * accessed safely.
2057 * <p>
2058 * If you need to run while the user is still locked (before they've entered
2059 * their lock pattern or PIN for the first time), you can listen for the
2060 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2061 * <p class="note">
2062 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002063 */
2064 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002065 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002066 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002067
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002068 /**
2069 * Broadcast Action: This is broadcast when a user action should request a
2070 * temporary system dialog to dismiss. Some examples of temporary system
2071 * dialogs are the notification window-shade and the recent tasks dialog.
2072 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002074 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2075 /**
2076 * Broadcast Action: Trigger the download and eventual installation
2077 * of a package.
2078 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002079 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002080 * <p class="note">This is a protected intent that can only be sent
2081 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002082 *
2083 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002084 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002085 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002086 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2087 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2088 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002089 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002090 * device. The data contains the name of the package. Note that the
2091 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002092 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002093 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002094 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2095 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002096 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2097 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002098 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002099 * <p class="note">This is a protected intent that can only be sent
2100 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002101 */
2102 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2103 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2104 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002105 * Broadcast Action: A new version of an application package has been
2106 * installed, replacing an existing version that was previously installed.
2107 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002108 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002109 * <ul>
2110 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2111 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002112 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002113 * <p class="note">This is a protected intent that can only be sent
2114 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002115 */
2116 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2117 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2118 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002119 * Broadcast Action: A new version of your application has been installed
2120 * over an existing one. This is only sent to the application that was
2121 * replaced. It does not contain any additional data; to receive it, just
2122 * use an intent filter for this action.
2123 *
2124 * <p class="note">This is a protected intent that can only be sent
2125 * by the system.
2126 */
2127 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2128 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2129 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002130 * Broadcast Action: An existing application package has been removed from
2131 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002132 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002133 * <ul>
2134 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2135 * to the package.
2136 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2137 * application -- data and code -- is being removed.
2138 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2139 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2140 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002141 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002142 * <p class="note">This is a protected intent that can only be sent
2143 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002144 */
2145 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2146 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2147 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002148 * Broadcast Action: An existing application package has been completely
2149 * removed from the device. The data contains the name of the package.
2150 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2151 * {@link #EXTRA_DATA_REMOVED} is true and
2152 * {@link #EXTRA_REPLACING} is false of that broadcast.
2153 *
2154 * <ul>
2155 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2156 * to the package.
2157 * </ul>
2158 *
2159 * <p class="note">This is a protected intent that can only be sent
2160 * by the system.
2161 */
2162 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2163 public static final String ACTION_PACKAGE_FULLY_REMOVED
2164 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2165 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002166 * Broadcast Action: An existing application package has been changed (for
2167 * example, a component has been enabled or disabled). The data contains
2168 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002169 * <ul>
2170 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002171 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002172 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002173 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2174 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002175 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002176 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002177 * <p class="note">This is a protected intent that can only be sent
2178 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002179 */
2180 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2181 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2182 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002183 * @hide
2184 * Broadcast Action: Ask system services if there is any reason to
2185 * restart the given package. The data contains the name of the
2186 * package.
2187 * <ul>
2188 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2189 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2190 * </ul>
2191 *
2192 * <p class="note">This is a protected intent that can only be sent
2193 * by the system.
2194 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002195 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2197 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2198 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002199 * Broadcast Action: The user has restarted a package, and all of its
2200 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002201 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002202 * be removed. Note that the restarted package does <em>not</em>
2203 * receive this broadcast.
2204 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002205 * <ul>
2206 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2207 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002208 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002209 * <p class="note">This is a protected intent that can only be sent
2210 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002211 */
2212 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2213 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2214 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002215 * Broadcast Action: The user has cleared the data of a package. This should
2216 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002217 * its persistent data is erased and this broadcast sent.
2218 * Note that the cleared package does <em>not</em>
2219 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002220 * <ul>
2221 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2222 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002223 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002224 * <p class="note">This is a protected intent that can only be sent
2225 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002226 */
2227 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2228 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2229 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002230 * Broadcast Action: Packages have been suspended.
2231 * <p>Includes the following extras:
2232 * <ul>
2233 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2234 * </ul>
2235 *
2236 * <p class="note">This is a protected intent that can only be sent
2237 * by the system. It is only sent to registered receivers.
2238 */
2239 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2240 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2241 /**
2242 * Broadcast Action: Packages have been unsuspended.
2243 * <p>Includes the following extras:
2244 * <ul>
2245 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2246 * </ul>
2247 *
2248 * <p class="note">This is a protected intent that can only be sent
2249 * by the system. It is only sent to registered receivers.
2250 */
2251 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2252 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2253 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002254 * Broadcast Action: A user ID has been removed from the system. The user
2255 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002256 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002257 * <p class="note">This is a protected intent that can only be sent
2258 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002259 */
2260 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2261 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002262
2263 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002264 * Broadcast Action: Sent to the installer package of an application when
2265 * that application is first launched (that is the first time it is moved
2266 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002267 *
2268 * <p class="note">This is a protected intent that can only be sent
2269 * by the system.
2270 */
2271 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2272 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2273
2274 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002275 * Broadcast Action: Sent to the system package verifier when a package
2276 * needs to be verified. The data contains the package URI.
2277 * <p class="note">
2278 * This is a protected intent that can only be sent by the system.
2279 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002280 */
2281 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2282 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2283
2284 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002285 * Broadcast Action: Sent to the system package verifier when a package is
2286 * verified. The data contains the package URI.
2287 * <p class="note">
2288 * This is a protected intent that can only be sent by the system.
2289 */
2290 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2291 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2292
2293 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002294 * Broadcast Action: Sent to the system intent filter verifier when an
2295 * intent filter needs to be verified. The data contains the filter data
2296 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002297 * <p class="note">
2298 * This is a protected intent that can only be sent by the system.
2299 * </p>
2300 *
2301 * @hide
2302 */
2303 @SystemApi
2304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2305 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2306
2307 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002308 * Broadcast Action: Resources for a set of packages (which were
2309 * previously unavailable) are currently
2310 * available since the media on which they exist is available.
2311 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2312 * list of packages whose availability changed.
2313 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2314 * list of uids of packages whose availability changed.
2315 * Note that the
2316 * packages in this list do <em>not</em> receive this broadcast.
2317 * The specified set of packages are now available on the system.
2318 * <p>Includes the following extras:
2319 * <ul>
2320 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2321 * whose resources(were previously unavailable) are currently available.
2322 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2323 * packages whose resources(were previously unavailable)
2324 * are currently available.
2325 * </ul>
2326 *
2327 * <p class="note">This is a protected intent that can only be sent
2328 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002329 */
2330 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002331 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2332 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002333
2334 /**
2335 * Broadcast Action: Resources for a set of packages are currently
2336 * unavailable since the media on which they exist is unavailable.
2337 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2338 * list of packages whose availability changed.
2339 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2340 * list of uids of packages whose availability changed.
2341 * The specified set of packages can no longer be
2342 * launched and are practically unavailable on the system.
2343 * <p>Inclues the following extras:
2344 * <ul>
2345 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2346 * whose resources are no longer available.
2347 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2348 * whose resources are no longer available.
2349 * </ul>
2350 *
2351 * <p class="note">This is a protected intent that can only be sent
2352 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002353 */
2354 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002355 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002356 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002357
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002358 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002359 * Broadcast Action: preferred activities have changed *explicitly*.
2360 *
2361 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2362 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2363 * be sent.
2364 *
2365 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2366 *
2367 * @hide
2368 */
2369 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2370 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2371 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2372
2373
2374 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002375 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002376 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002377 * This should <em>only</em> be used to determine when the wallpaper
2378 * has changed to show the new wallpaper to the user. You should certainly
2379 * never, in response to this, change the wallpaper or other attributes of
2380 * it such as the suggested size. That would be crazy, right? You'd cause
2381 * all kinds of loops, especially if other apps are doing similar things,
2382 * right? Of course. So please don't do this.
2383 *
2384 * @deprecated Modern applications should use
2385 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2386 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2387 * shown behind their UI, rather than watching for this broadcast and
2388 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002389 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002390 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002391 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2392 /**
2393 * Broadcast Action: The current device {@link android.content.res.Configuration}
2394 * (orientation, locale, etc) has changed. When such a change happens, the
2395 * UIs (view hierarchy) will need to be rebuilt based on this new
2396 * information; for the most part, applications don't need to worry about
2397 * this, because the system will take care of stopping and restarting the
2398 * application to make sure it sees the new changes. Some system code that
2399 * can not be restarted will need to watch for this action and handle it
2400 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002401 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002402 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002403 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002404 * in manifests, only by explicitly registering for it with
2405 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2406 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002407 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002408 * <p class="note">This is a protected intent that can only be sent
2409 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002410 *
2411 * @see android.content.res.Configuration
2412 */
2413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2414 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2415 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002416 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002417 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002418 * <p class="note">This is a protected intent that can only be sent
2419 * by the system.
2420 */
2421 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2422 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2423 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002424 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2425 * charging state, level, and other information about the battery.
2426 * See {@link android.os.BatteryManager} for documentation on the
2427 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002428 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002429 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002430 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002431 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002432 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002433 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2434 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2435 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2436 * broadcasts that are sent and can be received through manifest
2437 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002438 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002439 * <p class="note">This is a protected intent that can only be sent
2440 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002441 */
2442 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2443 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2444 /**
2445 * Broadcast Action: Indicates low battery condition on the device.
2446 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002447 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002448 * <p class="note">This is a protected intent that can only be sent
2449 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002450 */
2451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2452 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2453 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002454 * Broadcast Action: Indicates the battery is now okay after being low.
2455 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2456 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002457 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002458 * <p class="note">This is a protected intent that can only be sent
2459 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002460 */
2461 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2462 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2463 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002464 * Broadcast Action: External power has been connected to the device.
2465 * This is intended for applications that wish to register specifically to this notification.
2466 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2467 * stay active to receive this notification. This action can be used to implement actions
2468 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002469 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002470 * <p class="note">This is a protected intent that can only be sent
2471 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002472 */
2473 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002474 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002475 /**
2476 * Broadcast Action: External power has been removed from the device.
2477 * This is intended for applications that wish to register specifically to this notification.
2478 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2479 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002480 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002481 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002482 * <p class="note">This is a protected intent that can only be sent
2483 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002484 */
2485 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002486 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002487 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002488 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002489 * Broadcast Action: Device is shutting down.
2490 * This is broadcast when the device is being shut down (completely turned
2491 * off, not sleeping). Once the broadcast is complete, the final shutdown
2492 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002493 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002494 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002495 * <p class="note">This is a protected intent that can only be sent
2496 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002497 * <p>May include the following extras:
2498 * <ul>
2499 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2500 * shutdown is only for userspace processes. If not set, assumed to be false.
2501 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002502 */
2503 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002504 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002505 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002506 * Activity Action: Start this activity to request system shutdown.
2507 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002508 * to request confirmation from the user before shutting down. The optional boolean
2509 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2510 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002511 *
2512 * <p class="note">This is a protected intent that can only be sent
2513 * by the system.
2514 *
2515 * {@hide}
2516 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002517 public static final String ACTION_REQUEST_SHUTDOWN
2518 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002519 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002520 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002521 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002522 * <p class="note">
2523 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002524 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002525 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2526 * or above, this broadcast will no longer be delivered to any
2527 * {@link BroadcastReceiver} defined in your manifest. Instead,
2528 * apps are strongly encouraged to use the improved
2529 * {@link Context#getCacheDir()} behavior so the system can
2530 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002531 */
2532 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002533 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002534 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2535 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002536 * Broadcast Action: Indicates low storage space condition on the device no
2537 * longer exists
2538 * <p class="note">
2539 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002540 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002541 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2542 * or above, this broadcast will no longer be delivered to any
2543 * {@link BroadcastReceiver} defined in your manifest. Instead,
2544 * apps are strongly encouraged to use the improved
2545 * {@link Context#getCacheDir()} behavior so the system can
2546 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002547 */
2548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002549 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002550 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2551 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002552 * Broadcast Action: A sticky broadcast that indicates a storage space full
2553 * condition on the device. This is intended for activities that want to be
2554 * able to fill the data partition completely, leaving only enough free
2555 * space to prevent system-wide SQLite failures.
2556 * <p class="note">
2557 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002558 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002559 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2560 * or above, this broadcast will no longer be delivered to any
2561 * {@link BroadcastReceiver} defined in your manifest. Instead,
2562 * apps are strongly encouraged to use the improved
2563 * {@link Context#getCacheDir()} behavior so the system can
2564 * automatically free up storage when needed.
2565 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002566 */
2567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002568 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002569 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2570 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002571 * Broadcast Action: Indicates storage space full condition on the device no
2572 * longer exists.
2573 * <p class="note">
2574 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002575 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002576 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2577 * or above, this broadcast will no longer be delivered to any
2578 * {@link BroadcastReceiver} defined in your manifest. Instead,
2579 * apps are strongly encouraged to use the improved
2580 * {@link Context#getCacheDir()} behavior so the system can
2581 * automatically free up storage when needed.
2582 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002583 */
2584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002585 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002586 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2587 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002588 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2589 * and package management should be started.
2590 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2591 * notification.
2592 */
2593 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2594 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2595 /**
2596 * Broadcast Action: The device has entered USB Mass Storage mode.
2597 * This is used mainly for the USB Settings panel.
2598 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2599 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002600 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002601 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002602 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002604 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2605
2606 /**
2607 * Broadcast Action: The device has exited USB Mass Storage mode.
2608 * This is used mainly for the USB Settings panel.
2609 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2610 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002611 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002612 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002613 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002614 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002615 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2616
2617 /**
2618 * Broadcast Action: External media has been removed.
2619 * The path to the mount point for the removed media is contained in the Intent.mData field.
2620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2623
2624 /**
2625 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002626 * 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 -07002627 */
2628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2629 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2630
2631 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002632 * Broadcast Action: External media is present, and being disk-checked
2633 * 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 -08002634 */
2635 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2636 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2637
2638 /**
2639 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2640 * 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 -08002641 */
2642 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2643 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2644
2645 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002646 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002647 * 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 -07002648 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2649 * media was mounted read only.
2650 */
2651 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2652 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2653
2654 /**
2655 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002656 * 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 -07002657 */
2658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2659 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2660
2661 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002662 * Broadcast Action: External media is no longer being shared via USB mass storage.
2663 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2664 *
2665 * @hide
2666 */
2667 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2668
2669 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002670 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2671 * The path to the mount point for the removed media is contained in the Intent.mData field.
2672 */
2673 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2674 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2675
2676 /**
2677 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002678 * 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 -07002679 */
2680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2681 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2682
2683 /**
2684 * Broadcast Action: User has expressed the desire to remove the external storage media.
2685 * Applications should close all files they have open within the mount point when they receive this intent.
2686 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2687 */
2688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2689 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2690
2691 /**
2692 * Broadcast Action: The media scanner has started scanning a directory.
2693 * The path to the directory being scanned is contained in the Intent.mData field.
2694 */
2695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2696 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2697
2698 /**
2699 * Broadcast Action: The media scanner has finished scanning a directory.
2700 * The path to the scanned directory is contained in the Intent.mData field.
2701 */
2702 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2703 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2704
2705 /**
2706 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2707 * The path to the file is contained in the Intent.mData field.
2708 */
2709 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2710 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2711
2712 /**
2713 * Broadcast Action: The "Media Button" was pressed. Includes a single
2714 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2715 * caused the broadcast.
2716 */
2717 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2718 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2719
2720 /**
2721 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2722 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2723 * caused the broadcast.
2724 */
2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2726 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2727
2728 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2729 // location; they are not general-purpose actions.
2730
2731 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002732 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002733 */
2734 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2735 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2736 "android.intent.action.GTALK_CONNECTED";
2737
2738 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002739 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002740 */
2741 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2742 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2743 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002744
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002745 /**
2746 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002747 */
2748 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2749 public static final String ACTION_INPUT_METHOD_CHANGED =
2750 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002751
2752 /**
2753 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2754 * more radios have been turned off or on. The intent will have the following extra value:</p>
2755 * <ul>
2756 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2757 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2758 * turned off</li>
2759 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002760 *
Peng Xua35b5532016-01-20 00:05:45 -08002761 * <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 -07002762 */
2763 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2764 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2765
2766 /**
2767 * Broadcast Action: Some content providers have parts of their namespace
2768 * where they publish new events or items that the user may be especially
2769 * interested in. For these things, they may broadcast this action when the
2770 * set of interesting items change.
2771 *
2772 * For example, GmailProvider sends this notification when the set of unread
2773 * mail in the inbox changes.
2774 *
2775 * <p>The data of the intent identifies which part of which provider
2776 * changed. When queried through the content resolver, the data URI will
2777 * return the data set in question.
2778 *
2779 * <p>The intent will have the following extra values:
2780 * <ul>
2781 * <li><em>count</em> - The number of items in the data set. This is the
2782 * same as the number of items in the cursor returned by querying the
2783 * data URI. </li>
2784 * </ul>
2785 *
2786 * This intent will be sent at boot (if the count is non-zero) and when the
2787 * data set changes. It is possible for the data set to change without the
2788 * count changing (for example, if a new unread message arrives in the same
2789 * sync operation in which a message is archived). The phone should still
2790 * ring/vibrate/etc as normal in this case.
2791 */
2792 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2793 public static final String ACTION_PROVIDER_CHANGED =
2794 "android.intent.action.PROVIDER_CHANGED";
2795
2796 /**
2797 * Broadcast Action: Wired Headset plugged in or unplugged.
2798 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002799 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2800 * and documentation.
2801 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002802 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002803 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002804 */
2805 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002806 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002807
2808 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002809 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2810 * <ul>
2811 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2812 * </ul>
2813 *
2814 * <p class="note">This is a protected intent that can only be sent
2815 * by the system.
2816 *
2817 * @hide
2818 */
2819 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2820 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2821 = "android.intent.action.ADVANCED_SETTINGS";
2822
2823 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002824 * Broadcast Action: Sent after application restrictions are changed.
2825 *
2826 * <p class="note">This is a protected intent that can only be sent
2827 * by the system.</p>
2828 */
2829 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2830 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2831 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2832
2833 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002834 * Broadcast Action: An outgoing call is about to be placed.
2835 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002836 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002837 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002838 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002839 * the phone number originally intended to be dialed.</li>
2840 * </ul>
2841 * <p>Once the broadcast is finished, the resultData is used as the actual
2842 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002843 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002844 * outgoing call in turn: for example, a parental control application
2845 * might verify that the user is authorized to place the call at that
2846 * time, then a number-rewriting application might add an area code if
2847 * one was not specified.</p>
2848 * <p>For consistency, any receiver whose purpose is to prohibit phone
2849 * calls should have a priority of 0, to ensure it will see the final
2850 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002851 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002852 * should have a positive priority.
2853 * Negative priorities are reserved for the system for this broadcast;
2854 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002855 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2856 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002857 * <p>Emergency calls cannot be intercepted using this mechanism, and
2858 * other calls cannot be modified to call emergency numbers using this
2859 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002860 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2861 * call to use their own service instead. Those apps should first prevent
2862 * the call from being placed by setting resultData to <code>null</code>
2863 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002864 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002865 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2866 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002867 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002868 * <p class="note">This is a protected intent that can only be sent
2869 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002870 */
2871 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2872 public static final String ACTION_NEW_OUTGOING_CALL =
2873 "android.intent.action.NEW_OUTGOING_CALL";
2874
2875 /**
2876 * Broadcast Action: Have the device reboot. This is only for use by
2877 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002878 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002879 * <p class="note">This is a protected intent that can only be sent
2880 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002881 */
2882 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2883 public static final String ACTION_REBOOT =
2884 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002885
Wei Huang97ecc9c2009-05-11 17:44:20 -07002886 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002887 * Broadcast Action: A sticky broadcast for changes in the physical
2888 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002889 *
2890 * <p>The intent will have the following extra values:
2891 * <ul>
2892 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002893 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002894 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002895 * <p>This is intended for monitoring the current physical dock state.
2896 * See {@link android.app.UiModeManager} for the normal API dealing with
2897 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002898 */
2899 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2900 public static final String ACTION_DOCK_EVENT =
2901 "android.intent.action.DOCK_EVENT";
2902
2903 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002904 * Broadcast Action: A broadcast when idle maintenance can be started.
2905 * This means that the user is not interacting with the device and is
2906 * not expected to do so soon. Typical use of the idle maintenance is
2907 * to perform somehow expensive tasks that can be postponed at a moment
2908 * when they will not degrade user experience.
2909 * <p>
2910 * <p class="note">In order to keep the device responsive in case of an
2911 * unexpected user interaction, implementations of a maintenance task
2912 * should be interruptible. In such a scenario a broadcast with action
2913 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2914 * should not do the maintenance work in
2915 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2916 * maintenance service by {@link Context#startService(Intent)}. Also
2917 * you should hold a wake lock while your maintenance service is running
2918 * to prevent the device going to sleep.
2919 * </p>
2920 * <p>
2921 * <p class="note">This is a protected intent that can only be sent by
2922 * the system.
2923 * </p>
2924 *
2925 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002926 *
2927 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002928 */
2929 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2930 public static final String ACTION_IDLE_MAINTENANCE_START =
2931 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2932
2933 /**
2934 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2935 * This means that the user was not interacting with the device as a result
2936 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2937 * was sent and now the user started interacting with the device. Typical
2938 * use of the idle maintenance is to perform somehow expensive tasks that
2939 * can be postponed at a moment when they will not degrade user experience.
2940 * <p>
2941 * <p class="note">In order to keep the device responsive in case of an
2942 * unexpected user interaction, implementations of a maintenance task
2943 * should be interruptible. Hence, on receiving a broadcast with this
2944 * action, the maintenance task should be interrupted as soon as possible.
2945 * In other words, you should not do the maintenance work in
2946 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2947 * maintenance service that was started on receiving of
2948 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2949 * lock you acquired when your maintenance service started.
2950 * </p>
2951 * <p class="note">This is a protected intent that can only be sent
2952 * by the system.
2953 *
2954 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002955 *
2956 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002957 */
2958 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2959 public static final String ACTION_IDLE_MAINTENANCE_END =
2960 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2961
2962 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002963 * Broadcast Action: a remote intent is to be broadcasted.
2964 *
2965 * A remote intent is used for remote RPC between devices. The remote intent
2966 * is serialized and sent from one device to another device. The receiving
2967 * device parses the remote intent and broadcasts it. Note that anyone can
2968 * broadcast a remote intent. However, if the intent receiver of the remote intent
2969 * does not trust intent broadcasts from arbitrary intent senders, it should require
2970 * the sender to hold certain permissions so only trusted sender's broadcast will be
2971 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002972 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002973 */
2974 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002975 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002976
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002977 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002978 * Broadcast Action: This is broadcast once when the user is booting after a
2979 * system update. It can be used to perform cleanup or upgrades after a
2980 * system update.
2981 * <p>
2982 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2983 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2984 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2985 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002986 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002987 * @hide
2988 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002989 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002990 public static final String ACTION_PRE_BOOT_COMPLETED =
2991 "android.intent.action.PRE_BOOT_COMPLETED";
2992
Amith Yamasani13593602012-03-22 16:16:17 -07002993 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002994 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002995 * on restricted users. The broadcast intent contains an extra
2996 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2997 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2998 * String[] depending on the restriction type.<p/>
2999 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003000 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3001 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3002 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003003 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3004 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003005 * @see RestrictionEntry
3006 */
3007 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3008 "android.intent.action.GET_RESTRICTION_ENTRIES";
3009
3010 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003011 * Sent the first time a user is starting, to allow system apps to
3012 * perform one time initialization. (This will not be seen by third
3013 * party applications because a newly initialized user does not have any
3014 * third party applications installed for it.) This is sent early in
3015 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003016 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3017 * broadcast, since it is part of a visible user interaction; be as quick
3018 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003019 */
3020 public static final String ACTION_USER_INITIALIZE =
3021 "android.intent.action.USER_INITIALIZE";
3022
3023 /**
3024 * Sent when a user switch is happening, causing the process's user to be
3025 * brought to the foreground. This is only sent to receivers registered
3026 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3027 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003028 * foreground. This is sent as a foreground
3029 * broadcast, since it is part of a visible user interaction; be as quick
3030 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003031 */
3032 public static final String ACTION_USER_FOREGROUND =
3033 "android.intent.action.USER_FOREGROUND";
3034
3035 /**
3036 * Sent when a user switch is happening, causing the process's user to be
3037 * sent to the background. This is only sent to receivers registered
3038 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3039 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003040 * background. This is sent as a foreground
3041 * broadcast, since it is part of a visible user interaction; be as quick
3042 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003043 */
3044 public static final String ACTION_USER_BACKGROUND =
3045 "android.intent.action.USER_BACKGROUND";
3046
3047 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003048 * Broadcast sent to the system when a user is added. Carries an extra
3049 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3050 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003051 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003052 * @hide
3053 */
3054 public static final String ACTION_USER_ADDED =
3055 "android.intent.action.USER_ADDED";
3056
3057 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003058 * Broadcast sent by the system when a user is started. Carries an extra
3059 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003060 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003061 * that has been started. This is sent as a foreground
3062 * broadcast, since it is part of a visible user interaction; be as quick
3063 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003064 * @hide
3065 */
3066 public static final String ACTION_USER_STARTED =
3067 "android.intent.action.USER_STARTED";
3068
3069 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003070 * Broadcast sent when a user is in the process of starting. Carries an extra
3071 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3072 * sent to registered receivers, not manifest receivers. It is sent to all
3073 * users (including the one that is being started). You must hold
3074 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3075 * this broadcast. This is sent as a background broadcast, since
3076 * its result is not part of the primary UX flow; to safely keep track of
3077 * started/stopped state of a user you can use this in conjunction with
3078 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3079 * other user state broadcasts since those are foreground broadcasts so can
3080 * execute in a different order.
3081 * @hide
3082 */
3083 public static final String ACTION_USER_STARTING =
3084 "android.intent.action.USER_STARTING";
3085
3086 /**
3087 * Broadcast sent when a user is going to be stopped. Carries an extra
3088 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3089 * sent to registered receivers, not manifest receivers. It is sent to all
3090 * users (including the one that is being stopped). You must hold
3091 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3092 * this broadcast. The user will not stop until all receivers have
3093 * handled the broadcast. This is sent as a background broadcast, since
3094 * its result is not part of the primary UX flow; to safely keep track of
3095 * started/stopped state of a user you can use this in conjunction with
3096 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3097 * other user state broadcasts since those are foreground broadcasts so can
3098 * execute in a different order.
3099 * @hide
3100 */
3101 public static final String ACTION_USER_STOPPING =
3102 "android.intent.action.USER_STOPPING";
3103
3104 /**
3105 * Broadcast sent to the system when a user is stopped. Carries an extra
3106 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3107 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3108 * specific package. This is only sent to registered receivers, not manifest
3109 * receivers. It is sent to all running users <em>except</em> the one that
3110 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003111 * @hide
3112 */
3113 public static final String ACTION_USER_STOPPED =
3114 "android.intent.action.USER_STOPPED";
3115
3116 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003117 * 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 -07003118 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003119 * one that has been removed. The user will not be completely removed until all receivers have
3120 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003121 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003122 * @hide
3123 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003124 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003125 public static final String ACTION_USER_REMOVED =
3126 "android.intent.action.USER_REMOVED";
3127
3128 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003129 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003130 * the userHandle of the user to become the current one. This is only sent to
3131 * registered receivers, not manifest receivers. It is sent to all running users.
3132 * You must hold
3133 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003134 * @hide
3135 */
3136 public static final String ACTION_USER_SWITCHED =
3137 "android.intent.action.USER_SWITCHED";
3138
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003139 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003140 * Broadcast Action: Sent when the credential-encrypted private storage has
3141 * become unlocked for the target user. This is only sent to registered
3142 * receivers, not manifest receivers.
3143 */
3144 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3145 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3146
3147 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003148 * Broadcast sent to the system when a user's information changes. Carries an extra
3149 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003150 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003151 * @hide
3152 */
3153 public static final String ACTION_USER_INFO_CHANGED =
3154 "android.intent.action.USER_INFO_CHANGED";
3155
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003156 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003157 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3158 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003159 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3160 * that need to display merged content across both primary and managed profiles need to
3161 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003162 * not manifest receivers.
3163 */
3164 public static final String ACTION_MANAGED_PROFILE_ADDED =
3165 "android.intent.action.MANAGED_PROFILE_ADDED";
3166
3167 /**
3168 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003169 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3170 * Only applications (for example Launchers) that need to display merged content across both
3171 * primary and managed profiles need to worry about this broadcast. This is only sent to
3172 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003173 */
3174 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3175 "android.intent.action.MANAGED_PROFILE_REMOVED";
3176
3177 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003178 * Broadcast sent to the primary user when the credential-encrypted private storage for
3179 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3180 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3181 * Launchers) that need to display merged content across both primary and managed profiles
3182 * need to worry about this broadcast. This is only sent to registered receivers,
3183 * not manifest receivers.
3184 */
3185 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3186 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3187
3188 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003189 * Broadcast sent to the primary user when an associated managed profile has become available.
3190 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003191 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3192 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3193 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003194 */
Rubin Xue95057a2016-04-01 16:49:25 +01003195 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3196 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3197
3198 /**
3199 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3200 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3201 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3202 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3203 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3204 */
3205 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3206 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003207
3208 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003209 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3210 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3211 * the device was locked or unlocked.
3212 *
3213 * This is only sent to registered receivers.
3214 *
3215 * @hide
3216 */
3217 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3218 "android.intent.action.DEVICE_LOCKED_CHANGED";
3219
3220 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003221 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3222 */
3223 public static final String ACTION_QUICK_CLOCK =
3224 "android.intent.action.QUICK_CLOCK";
3225
Michael Wright0087a142013-02-05 16:29:39 -08003226 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003227 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003228 * @hide
3229 */
3230 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003231 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003232
Justin Kohd378ad72013-04-01 12:18:26 -07003233 /**
3234 * Broadcast Action: A global button was pressed. Includes a single
3235 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3236 * caused the broadcast.
3237 * @hide
3238 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003239 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003240 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3241
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003242 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003243 * Broadcast Action: Sent when media resource is granted.
3244 * <p>
3245 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3246 * granted.
3247 * </p>
3248 * <p class="note">
3249 * This is a protected intent that can only be sent by the system.
3250 * </p>
3251 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003252 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003253 * </p>
3254 *
3255 * @hide
3256 */
3257 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3258 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3259
3260 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003261 * Broadcast Action: An overlay package has changed. The data contains the
3262 * name of the overlay package which has changed. This is broadcast on all
3263 * changes to the OverlayInfo returned by {@link
3264 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3265 * most common change is a state change that will change whether the
3266 * overlay is enabled or not.
3267 * @hide
3268 */
3269 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3270
3271 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003272 * Activity Action: Allow the user to select and return one or more existing
3273 * documents. When invoked, the system will display the various
3274 * {@link DocumentsProvider} instances installed on the device, letting the
3275 * user interactively navigate through them. These documents include local
3276 * media, such as photos and video, and documents provided by installed
3277 * cloud storage providers.
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 * All selected documents are returned to the calling application with
3285 * persistable read and write permission grants. If you want to maintain
3286 * access to the documents across device reboots, you need to explicitly
3287 * take the persistable permissions using
3288 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3289 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003290 * Callers must indicate the acceptable document MIME types through
3291 * {@link #setType(String)}. For example, to select photos, use
3292 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3293 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3294 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003295 * <p>
3296 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003297 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3298 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003299 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003300 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3301 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003302 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003303 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003304 * Callers can set a document URI through
3305 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3306 * location of documents navigator. System will do its best to launch the
3307 * navigator in the specified document if it's a folder, or the folder that
3308 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003309 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003310 * Output: The URI of the item that was picked, returned in
3311 * {@link #getData()}. This must be a {@code content://} URI so that any
3312 * receiver can access it. If multiple documents were selected, they are
3313 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003314 *
3315 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003316 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003317 * @see #ACTION_CREATE_DOCUMENT
3318 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003319 */
3320 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3321 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3322
3323 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003324 * Activity Action: Allow the user to create a new document. When invoked,
3325 * the system will display the various {@link DocumentsProvider} instances
3326 * installed on the device, letting the user navigate through them. The
3327 * returned document may be a newly created document with no content, or it
3328 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003329 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003330 * Each document is represented as a {@code content://} URI backed by a
3331 * {@link DocumentsProvider}, which can be opened as a stream with
3332 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3333 * {@link android.provider.DocumentsContract.Document} metadata.
3334 * <p>
3335 * Callers must indicate the concrete MIME type of the document being
3336 * created by setting {@link #setType(String)}. This MIME type cannot be
3337 * changed after the document is created.
3338 * <p>
3339 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3340 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003341 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003342 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3343 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003344 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003345 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003346 * Callers can set a document URI through
3347 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3348 * location of documents navigator. System will do its best to launch the
3349 * navigator in the specified document if it's a folder, or the folder that
3350 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003351 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003352 * Output: The URI of the item that was created. This must be a
3353 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003354 *
3355 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003356 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003357 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003358 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003359 */
3360 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3361 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3362
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003363 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003364 * Activity Action: Allow the user to pick a directory subtree. When
3365 * invoked, the system will display the various {@link DocumentsProvider}
3366 * instances installed on the device, letting the user navigate through
3367 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003368 * <p>
3369 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003370 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3371 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3372 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003373 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003374 * Callers can set a document URI through
3375 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3376 * location of documents navigator. System will do its best to launch the
3377 * navigator in the specified document if it's a folder, or the folder that
3378 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003379 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003380 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003381 *
3382 * @see DocumentsContract
3383 */
3384 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003385 public static final String
3386 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003387
Felipe Lemec7b1f892016-01-15 15:02:31 -08003388 /**
Peng Xua35b5532016-01-20 00:05:45 -08003389 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3390 * exisiting sensor being disconnected.
3391 *
3392 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3393 *
3394 * {@hide}
3395 */
3396 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3397 public static final String
3398 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3399
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003400 /**
Sanket Padawe2c1a49f2017-03-31 12:39:50 -07003401 * Broadcast Action: The default subscription has changed. This has the following
3402 * extra values:</p>
3403 * The {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default subscription index
3404 */
3405 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3406 public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED
3407 = "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED";
3408
3409 /**
3410 * Broadcast Action: The default sms subscription has changed. This has the following
3411 * extra values:</p>
3412 * {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default sms
3413 * subscription index
3414 */
3415 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3416 public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
3417 = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
3418
3419 /**
3420 * Integer extra used with {@link #ACTION_DEFAULT_SUBSCRIPTION_CHANGED} and
3421 * {@link #ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED} to indicate the subscription
3422 * which has changed.
3423 */
3424 public static final String EXTRA_SUBSCRIPTION_INDEX = "android.intent.extra.SUBSCRIPTION_INDEX";
3425
3426 /**
Sam Line707f832017-04-13 17:00:55 -07003427 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003428 * @hide
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003429 */
3430 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003431 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003432 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3433
Christopher Tate6597e342015-02-17 12:15:25 -08003434 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003435 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3436 * is about to be performed.
3437 * @hide
3438 */
3439 @SystemApi
3440 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3441 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3442 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3443
3444 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003445 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3446 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3447 *
3448 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3449 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003450 * @hide
3451 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003452 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003453 public static final String EXTRA_FORCE_MASTER_CLEAR =
3454 "android.intent.extra.FORCE_MASTER_CLEAR";
3455
3456 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003457 * A broadcast action to trigger a factory reset.
3458 *
3459 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3460 *
3461 * <p>Not for use by third-party applications.
3462 *
3463 * @see #EXTRA_FORCE_MASTER_CLEAR
3464 *
3465 * {@hide}
3466 */
3467 @SystemApi
3468 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3469 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3470
3471 /**
3472 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3473 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3474 *
3475 * <p>Not for use by third-party applications.
3476 *
3477 * @hide
3478 */
3479 @SystemApi
3480 public static final String EXTRA_FORCE_FACTORY_RESET =
3481 "android.intent.extra.FORCE_FACTORY_RESET";
3482
3483 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003484 * Broadcast action: report that a settings element is being restored from backup. The intent
3485 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3486 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3487 * is the value of that settings entry prior to the restore operation. All of these values are
3488 * represented as strings.
3489 *
3490 * <p>This broadcast is sent only for settings provider entries known to require special handling
3491 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3492 * the provider's backup agent implementation.
3493 *
3494 * @see #EXTRA_SETTING_NAME
3495 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3496 * @see #EXTRA_SETTING_NEW_VALUE
3497 * {@hide}
3498 */
3499 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3500
3501 /** {@hide} */
3502 public static final String EXTRA_SETTING_NAME = "setting_name";
3503 /** {@hide} */
3504 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3505 /** {@hide} */
3506 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3507
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003508 /**
3509 * Activity Action: Process a piece of text.
3510 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3511 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3512 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3513 */
3514 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3515 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003516
3517 /**
3518 * Broadcast Action: The sim card state has changed.
3519 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3520 * because TelephonyIntents is an internal class.
3521 * @hide
3522 */
3523 @SystemApi
3524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3525 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3526
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003527 /**
fionaxu90fee272017-03-31 12:45:12 -07003528 * Broadcast Action: indicate that the phone service state has changed.
3529 * The intent will have the following extra values:</p>
3530 * <p>
3531 * @see #EXTRA_VOICE_REG_STATE
3532 * @see #EXTRA_DATA_REG_STATE
3533 * @see #EXTRA_VOICE_ROAMING_TYPE
3534 * @see #EXTRA_DATA_ROAMING_TYPE
3535 * @see #EXTRA_OPERATOR_ALPHA_LONG
3536 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3537 * @see #EXTRA_OPERATOR_NUMERIC
3538 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3539 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3540 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3541 * @see #EXTRA_MANUAL
3542 * @see #EXTRA_VOICE_RADIO_TECH
3543 * @see #EXTRA_DATA_RADIO_TECH
3544 * @see #EXTRA_CSS_INDICATOR
3545 * @see #EXTRA_NETWORK_ID
3546 * @see #EXTRA_SYSTEM_ID
3547 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3548 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3549 * @see #EXTRA_EMERGENCY_ONLY
3550 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3551 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3552 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3553 *
3554 * <p class="note">
3555 * Requires the READ_PHONE_STATE permission.
3556 *
3557 * <p class="note">This is a protected intent that can only be sent by the system.
3558 * @hide
3559 */
3560 @Deprecated
3561 @SystemApi
3562 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3563 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3564
3565 /**
3566 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3567 * state.
3568 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3569 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3570 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3571 * @see android.telephony.ServiceState#STATE_POWER_OFF
3572 * @hide
3573 */
3574 @Deprecated
3575 @SystemApi
3576 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3577
3578 /**
3579 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3580 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3581 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3582 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3583 * @see android.telephony.ServiceState#STATE_POWER_OFF
3584 * @hide
3585 */
3586 @Deprecated
3587 @SystemApi
3588 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3589
3590 /**
3591 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3592 * type.
3593 * @hide
3594 */
3595 @Deprecated
3596 @SystemApi
3597 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3598
3599 /**
3600 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3601 * type.
3602 * @hide
3603 */
3604 @Deprecated
3605 @SystemApi
3606 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3607
3608 /**
3609 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3610 * registered voice operator name in long alphanumeric format.
3611 * {@code null} if the operator name is not known or unregistered.
3612 * @hide
3613 */
3614 @Deprecated
3615 @SystemApi
3616 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3617
3618 /**
3619 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3620 * registered voice operator name in short alphanumeric format.
3621 * {@code null} if the operator name is not known or unregistered.
3622 * @hide
3623 */
3624 @Deprecated
3625 @SystemApi
3626 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3627
3628 /**
3629 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3630 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3631 * network.
3632 * @hide
3633 */
3634 @Deprecated
3635 @SystemApi
3636 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3637
3638 /**
3639 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3640 * registered data operator name in long alphanumeric format.
3641 * {@code null} if the operator name is not known or unregistered.
3642 * @hide
3643 */
3644 @Deprecated
3645 @SystemApi
3646 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3647
3648 /**
3649 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3650 * registered data operator name in short alphanumeric format.
3651 * {@code null} if the operator name is not known or unregistered.
3652 * @hide
3653 */
3654 @Deprecated
3655 @SystemApi
3656 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3657
3658 /**
3659 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3660 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3661 * data operator.
3662 * @hide
3663 */
3664 @Deprecated
3665 @SystemApi
3666 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3667
3668 /**
3669 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3670 * network selection mode is manual.
3671 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3672 * @hide
3673 */
3674 @Deprecated
3675 @SystemApi
3676 public static final String EXTRA_MANUAL = "manual";
3677
3678 /**
3679 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3680 * radio technology.
3681 * @hide
3682 */
3683 @Deprecated
3684 @SystemApi
3685 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3686
3687 /**
3688 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3689 * radio technology.
3690 * @hide
3691 */
3692 @Deprecated
3693 @SystemApi
3694 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3695
3696 /**
3697 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3698 * support on CDMA network.
3699 * Will be {@code true} if support, {@code false} otherwise.
3700 * @hide
3701 */
3702 @Deprecated
3703 @SystemApi
3704 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3705
3706 /**
3707 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3708 * id. {@code Integer.MAX_VALUE} if unknown.
3709 * @hide
3710 */
3711 @Deprecated
3712 @SystemApi
3713 public static final String EXTRA_NETWORK_ID = "networkId";
3714
3715 /**
3716 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3717 * {@code Integer.MAX_VALUE} if unknown.
3718 * @hide
3719 */
3720 @Deprecated
3721 @SystemApi
3722 public static final String EXTRA_SYSTEM_ID = "systemId";
3723
3724 /**
3725 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3726 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3727 * @hide
3728 */
3729 @Deprecated
3730 @SystemApi
3731 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3732
3733 /**
3734 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3735 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3736 * @hide
3737 */
3738 @Deprecated
3739 @SystemApi
3740 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3741
3742 /**
3743 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3744 * only mode.
3745 * {@code true} if in emergency only mode, {@code false} otherwise.
3746 * @hide
3747 */
3748 @Deprecated
3749 @SystemApi
3750 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3751
3752 /**
3753 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3754 * registration state is roaming.
3755 * {@code true} if registration indicates roaming, {@code false} otherwise
3756 * @hide
3757 */
3758 @Deprecated
3759 @SystemApi
3760 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3761 "isDataRoamingFromRegistration";
3762
3763 /**
3764 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3765 * aggregation is in use.
3766 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3767 * @hide
3768 */
3769 @Deprecated
3770 @SystemApi
3771 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3772
3773 /**
3774 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3775 * is reduced from the rsrp threshold while calculating signal strength level.
3776 * @hide
3777 */
3778 @Deprecated
3779 @SystemApi
3780 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3781
3782 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003783 * The name of the extra used to define the text to be processed, as a
3784 * CharSequence. Note that this may be a styled CharSequence, so you must use
3785 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003786 */
3787 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3788 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003789 * 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 +00003790 */
3791 public static final String EXTRA_PROCESS_TEXT_READONLY =
3792 "android.intent.extra.PROCESS_TEXT_READONLY";
3793
Bryce Leebc58f592015-09-25 16:43:01 -07003794 /**
3795 * Broadcast action: reports when a new thermal event has been reached. When the device
3796 * is reaching its maximum temperatue, the thermal level reported
3797 * {@hide}
3798 */
3799 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3800 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3801
3802 /** {@hide} */
3803 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3804
3805 /**
3806 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003807 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003808 * {@hide}
3809 */
3810 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3811
3812 /**
3813 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003814 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003815 * {@hide}
3816 */
3817 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3818
3819 /**
3820 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003821 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003822 * {@hide}
3823 */
3824 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3825
3826
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003827 // ---------------------------------------------------------------------
3828 // ---------------------------------------------------------------------
3829 // Standard intent categories (see addCategory()).
3830
3831 /**
3832 * Set if the activity should be an option for the default action
3833 * (center press) to perform on a piece of data. Setting this will
3834 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003835 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003836 * Intent when initiating an action -- it is for use in intent filters
3837 * specified in packages.
3838 */
3839 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3840 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3841 /**
3842 * Activities that can be safely invoked from a browser must support this
3843 * category. For example, if the user is viewing a web page or an e-mail
3844 * and clicks on a link in the text, the Intent generated execute that
3845 * link will require the BROWSABLE category, so that only activities
3846 * supporting this category will be considered as possible actions. By
3847 * supporting this category, you are promising that there is nothing
3848 * damaging (without user intervention) that can happen by invoking any
3849 * matching Intent.
3850 */
3851 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3852 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3853 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003854 * Categories for activities that can participate in voice interaction.
3855 * An activity that supports this category must be prepared to run with
3856 * no UI shown at all (though in some case it may have a UI shown), and
3857 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3858 */
3859 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3860 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3861 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003862 * Set if the activity should be considered as an alternative action to
3863 * the data the user is currently viewing. See also
3864 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3865 * applies to the selection in a list of items.
3866 *
3867 * <p>Supporting this category means that you would like your activity to be
3868 * displayed in the set of alternative things the user can do, usually as
3869 * part of the current activity's options menu. You will usually want to
3870 * include a specific label in the &lt;intent-filter&gt; of this action
3871 * describing to the user what it does.
3872 *
3873 * <p>The action of IntentFilter with this category is important in that it
3874 * describes the specific action the target will perform. This generally
3875 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3876 * a specific name such as "com.android.camera.action.CROP. Only one
3877 * alternative of any particular action will be shown to the user, so using
3878 * a specific action like this makes sure that your alternative will be
3879 * displayed while also allowing other applications to provide their own
3880 * overrides of that particular action.
3881 */
3882 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3883 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3884 /**
3885 * Set if the activity should be considered as an alternative selection
3886 * action to the data the user has currently selected. This is like
3887 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3888 * of items from which the user can select, giving them alternatives to the
3889 * default action that will be performed on it.
3890 */
3891 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3892 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3893 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003894 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003895 */
3896 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3897 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3898 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003899 * Should be displayed in the top-level launcher.
3900 */
3901 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3902 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3903 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003904 * Indicates an activity optimized for Leanback mode, and that should
3905 * be displayed in the Leanback launcher.
3906 */
3907 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3908 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3909 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003910 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3911 * @hide
3912 */
3913 @SystemApi
3914 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3915 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003916 * Provides information about the package it is in; typically used if
3917 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3918 * a front-door to the user without having to be shown in the all apps list.
3919 */
3920 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3921 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3922 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003923 * This is the home activity, that is the first activity that is displayed
3924 * when the device boots.
3925 */
3926 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3927 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3928 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003929 * This is the home activity that is displayed when the device is finished setting up and ready
3930 * for use.
3931 * @hide
3932 */
3933 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3934 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3935 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003936 * This is the setup wizard activity, that is the first activity that is displayed
3937 * when the user sets up the device for the first time.
3938 * @hide
3939 */
3940 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3941 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3942 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003943 * This activity is a preference panel.
3944 */
3945 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3946 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3947 /**
3948 * This activity is a development preference panel.
3949 */
3950 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3951 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3952 /**
3953 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003954 */
3955 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3956 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3957 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003958 * This activity allows the user to browse and download new applications.
3959 */
3960 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3961 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3962 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003963 * This activity may be exercised by the monkey or other automated test tools.
3964 */
3965 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3966 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3967 /**
3968 * To be used as a test (not part of the normal user experience).
3969 */
3970 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3971 /**
3972 * To be used as a unit test (run through the Test Harness).
3973 */
3974 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3975 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003976 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003977 * experience).
3978 */
3979 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003980
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003981 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003982 * Used to indicate that an intent only wants URIs that can be opened with
3983 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3984 * must support at least the columns defined in {@link OpenableColumns} when
3985 * queried.
3986 *
3987 * @see #ACTION_GET_CONTENT
3988 * @see #ACTION_OPEN_DOCUMENT
3989 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003990 */
3991 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3992 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3993
3994 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003995 * Used to indicate that an intent filter can accept files which are not necessarily
3996 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3997 * at least streamable via
3998 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3999 * using one of the stream types exposed via
4000 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4001 *
4002 * @see #ACTION_SEND
4003 * @see #ACTION_SEND_MULTIPLE
4004 */
4005 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4006 public static final String CATEGORY_TYPED_OPENABLE =
4007 "android.intent.category.TYPED_OPENABLE";
4008
4009 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004010 * To be used as code under test for framework instrumentation tests.
4011 */
4012 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4013 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004014 /**
4015 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004016 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4017 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004018 */
4019 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4020 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4021 /**
4022 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004023 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4024 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004025 */
4026 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4027 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004028 /**
4029 * An activity to run when device is inserted into a analog (low end) dock.
4030 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4031 * information, see {@link android.app.UiModeManager}.
4032 */
4033 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4034 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4035
4036 /**
4037 * An activity to run when device is inserted into a digital (high end) dock.
4038 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4039 * information, see {@link android.app.UiModeManager}.
4040 */
4041 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4042 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004043
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004044 /**
4045 * Used to indicate that the activity can be used in a car environment.
4046 */
4047 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4048 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4049
Zak Cohendb6ca492017-01-26 14:09:00 -08004050 /**
4051 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4052 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4053 * information, see {@link android.app.UiModeManager}.
4054 */
4055 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4056 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004057 // ---------------------------------------------------------------------
4058 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004059 // Application launch intent categories (see addCategory()).
4060
4061 /**
4062 * Used with {@link #ACTION_MAIN} to launch the browser application.
4063 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004064 * <p>NOTE: This should not be used as the primary key of an Intent,
4065 * since it will not result in the app launching with the correct
4066 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004067 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004068 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004069 */
4070 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4071 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4072
4073 /**
4074 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4075 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004076 * <p>NOTE: This should not be used as the primary key of an Intent,
4077 * since it will not result in the app launching with the correct
4078 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004079 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004080 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004081 */
4082 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4083 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4084
4085 /**
4086 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4087 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004088 * <p>NOTE: This should not be used as the primary key of an Intent,
4089 * since it will not result in the app launching with the correct
4090 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004091 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004092 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004093 */
4094 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4095 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4096
4097 /**
4098 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4099 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004100 * <p>NOTE: This should not be used as the primary key of an Intent,
4101 * since it will not result in the app launching with the correct
4102 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004103 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004104 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004105 */
4106 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4107 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4108
4109 /**
4110 * Used with {@link #ACTION_MAIN} to launch the email application.
4111 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004112 * <p>NOTE: This should not be used as the primary key of an Intent,
4113 * since it will not result in the app launching with the correct
4114 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004115 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004116 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004117 */
4118 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4119 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4120
4121 /**
4122 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4123 * The activity should be able to view and manipulate image and video files
4124 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004125 * <p>NOTE: This should not be used as the primary key of an Intent,
4126 * since it will not result in the app launching with the correct
4127 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004128 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004129 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004130 */
4131 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4132 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4133
4134 /**
4135 * Used with {@link #ACTION_MAIN} to launch the maps application.
4136 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004137 * <p>NOTE: This should not be used as the primary key of an Intent,
4138 * since it will not result in the app launching with the correct
4139 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004140 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004141 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004142 */
4143 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4144 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4145
4146 /**
4147 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4148 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004149 * <p>NOTE: This should not be used as the primary key of an Intent,
4150 * since it will not result in the app launching with the correct
4151 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004152 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004153 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004154 */
4155 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4156 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4157
4158 /**
4159 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004160 * The activity should be able to play, browse, or manipulate music files
4161 * stored on the device.
4162 * <p>NOTE: This should not be used as the primary key of an Intent,
4163 * since it will not result in the app launching with the correct
4164 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004165 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004166 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004167 */
4168 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4169 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4170
4171 // ---------------------------------------------------------------------
4172 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004173 // Standard extra data keys.
4174
4175 /**
4176 * The initial data to place in a newly created record. Use with
4177 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4178 * fields as would be given to the underlying ContentProvider.insert()
4179 * call.
4180 */
4181 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4182
4183 /**
4184 * A constant CharSequence that is associated with the Intent, used with
4185 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4186 * this may be a styled CharSequence, so you must use
4187 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4188 * retrieve it.
4189 */
4190 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4191
4192 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004193 * A constant String that is associated with the Intent, used with
4194 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4195 * as HTML formatted text. Note that you <em>must</em> also supply
4196 * {@link #EXTRA_TEXT}.
4197 */
4198 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4199
4200 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004201 * A content: URI holding a stream of data associated with the Intent,
4202 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004203 */
4204 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4205
4206 /**
4207 * A String[] holding e-mail addresses that should be delivered to.
4208 */
4209 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4210
4211 /**
4212 * A String[] holding e-mail addresses that should be carbon copied.
4213 */
4214 public static final String EXTRA_CC = "android.intent.extra.CC";
4215
4216 /**
4217 * A String[] holding e-mail addresses that should be blind carbon copied.
4218 */
4219 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4220
4221 /**
4222 * A constant string holding the desired subject line of a message.
4223 */
4224 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4225
4226 /**
4227 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004228 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004229 */
4230 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4231
4232 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004233 * An int representing the user id to be used.
4234 *
4235 * @hide
4236 */
4237 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4238
4239 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004240 * An int representing the task id to be retrieved. This is used when a launch from recents is
4241 * intercepted by another action such as credentials confirmation to remember which task should
4242 * be resumed when complete.
4243 *
4244 * @hide
4245 */
4246 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4247
4248 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004249 * An Intent[] describing additional, alternate choices you would like shown with
4250 * {@link #ACTION_CHOOSER}.
4251 *
4252 * <p>An app may be capable of providing several different payload types to complete a
4253 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4254 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4255 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4256 * photo data or a hosted link where the photos can be viewed.</p>
4257 *
4258 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4259 * first/primary/preferred intent in the set. Additional intents specified in
4260 * this extra are ordered; by default intents that appear earlier in the array will be
4261 * preferred over intents that appear later in the array as matches for the same
4262 * target component. To alter this preference, a calling app may also supply
4263 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4264 */
4265 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4266
4267 /**
Adam Powell52c39212016-04-07 15:14:18 -07004268 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4269 * and omitted from a list of components presented to the user.
4270 *
4271 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4272 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4273 * from your own package or other apps from your organization if the idea of sending to those
4274 * targets would be redundant with other app functionality. Filtered components will not
4275 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4276 */
4277 public static final String EXTRA_EXCLUDE_COMPONENTS
4278 = "android.intent.extra.EXCLUDE_COMPONENTS";
4279
4280 /**
4281 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4282 * describing additional high-priority deep-link targets for the chooser to present to the user.
4283 *
4284 * <p>Targets provided in this way will be presented inline with all other targets provided
4285 * by services from other apps. They will be prioritized before other service targets, but
4286 * after those targets provided by sources that the user has manually pinned to the front.</p>
4287 *
4288 * @see #ACTION_CHOOSER
4289 */
4290 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4291
4292 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004293 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4294 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4295 *
4296 * <p>An app preparing an action for another app to complete may wish to allow the user to
4297 * disambiguate between several options for completing the action based on the chosen target
4298 * or otherwise refine the action before it is invoked.
4299 * </p>
4300 *
4301 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4302 * <ul>
4303 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4304 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4305 * chosen target beyond the first</li>
4306 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4307 * should fill in and send once the disambiguation is complete</li>
4308 * </ul>
4309 */
4310 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4311 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4312
4313 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004314 * An {@code ArrayList} of {@code String} annotations describing content for
4315 * {@link #ACTION_CHOOSER}.
4316 *
4317 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4318 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4319 *
4320 * <p>Annotations should describe the major components or topics of the content. It is up to
4321 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4322 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004323 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4324 * character. Performance on customized annotations can suffer, if they are rarely used for
4325 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4326 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004327 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004328 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004329 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004330 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004331 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004332 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004333 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004334 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004335 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004336 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4337 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4338 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4339 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4340 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004341 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004342 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4343 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004344 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004345 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004346 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004347 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004348 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004349 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004350 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004351 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004352 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004353 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004354 * Christmas and Thanksgiving.</li>
4355 * </ul>
4356 */
4357 public static final String EXTRA_CONTENT_ANNOTATIONS
4358 = "android.intent.extra.CONTENT_ANNOTATIONS";
4359
4360 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004361 * A {@link ResultReceiver} used to return data back to the sender.
4362 *
4363 * <p>Used to complete an app-specific
4364 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4365 *
4366 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4367 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4368 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4369 * when the user selects a target component from the chooser. It is up to the recipient
4370 * to send a result to this ResultReceiver to signal that disambiguation is complete
4371 * and that the chooser should invoke the user's choice.</p>
4372 *
4373 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4374 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4375 * to match and fill in the final Intent or ChooserTarget before starting it.
4376 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4377 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4378 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4379 *
4380 * <p>The result code passed to the ResultReceiver should be
4381 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4382 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4383 * the chooser should finish without starting a target.</p>
4384 */
4385 public static final String EXTRA_RESULT_RECEIVER
4386 = "android.intent.extra.RESULT_RECEIVER";
4387
4388 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004389 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004390 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004391 */
4392 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4393
4394 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004395 * A Parcelable[] of {@link Intent} or
4396 * {@link android.content.pm.LabeledIntent} objects as set with
4397 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4398 * a the front of the list of choices, when shown to the user with a
4399 * {@link #ACTION_CHOOSER}.
4400 */
4401 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4402
4403 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004404 * A {@link IntentSender} to start after ephemeral installation success.
4405 * @hide
4406 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004407 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4408
4409 /**
4410 * A {@link IntentSender} to start after ephemeral installation failure.
4411 * @hide
4412 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004413 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4414
4415 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004416 * The host name that triggered an ephemeral resolution.
4417 * @hide
4418 */
4419 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4420
4421 /**
4422 * An opaque token to track ephemeral resolution.
4423 * @hide
4424 */
4425 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4426
4427 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004428 * The version code of the app to install components from.
4429 * @hide
4430 */
4431 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4432
4433 /**
Chad Brubaker06068612017-04-06 09:43:47 -07004434 * The app that triggered the ephemeral installation.
4435 * @hide
4436 */
4437 public static final String EXTRA_CALLING_PACKAGE
4438 = "android.intent.extra.CALLING_PACKAGE";
4439
4440 /**
4441 * Optional calling app provided bundle containing additional launch information the
4442 * installer may use.
4443 * @hide
4444 */
4445 public static final String EXTRA_VERIFICATION_BUNDLE
4446 = "android.intent.extra.VERIFICATION_BUNDLE";
4447
4448 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004449 * A Bundle forming a mapping of potential target package names to different extras Bundles
4450 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4451 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4452 * be currently installed on the device.
4453 *
4454 * <p>An application may choose to provide alternate extras for the case where a user
4455 * selects an activity from a predetermined set of target packages. If the activity
4456 * the user selects from the chooser belongs to a package with its package name as
4457 * a key in this bundle, the corresponding extras for that package will be merged with
4458 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4459 * extra has the same key as an extra already present in the intent it will overwrite
4460 * the extra from the intent.</p>
4461 *
4462 * <p><em>Examples:</em>
4463 * <ul>
4464 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4465 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4466 * parameters for that target.</li>
4467 * <li>An application may offer additional metadata for known targets of a given intent
4468 * to pass along information only relevant to that target such as account or content
4469 * identifiers already known to that application.</li>
4470 * </ul></p>
4471 */
4472 public static final String EXTRA_REPLACEMENT_EXTRAS =
4473 "android.intent.extra.REPLACEMENT_EXTRAS";
4474
4475 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004476 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4477 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4478 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4479 * {@link ComponentName} of the chosen component.
4480 *
4481 * <p>In some situations this callback may never come, for example if the user abandons
4482 * the chooser, switches to another task or any number of other reasons. Apps should not
4483 * be written assuming that this callback will always occur.</p>
4484 */
4485 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4486 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4487
4488 /**
4489 * The {@link ComponentName} chosen by the user to complete an action.
4490 *
4491 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4492 */
4493 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4494
4495 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004496 * A {@link android.view.KeyEvent} object containing the event that
4497 * triggered the creation of the Intent it is in.
4498 */
4499 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4500
4501 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004502 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4503 * before shutting down.
4504 *
4505 * {@hide}
4506 */
4507 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4508
4509 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004510 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4511 * requested by the user.
4512 *
4513 * {@hide}
4514 */
4515 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4516 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4517
4518 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004519 * 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 -07004520 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4521 * of restarting the application.
4522 */
4523 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4524
4525 /**
4526 * A String holding the phone number originally entered in
4527 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4528 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4529 */
4530 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004531
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 /**
4533 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4534 * intents to supply the uid the package had been assigned. Also an optional
4535 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4536 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4537 * purpose.
4538 */
4539 public static final String EXTRA_UID = "android.intent.extra.UID";
4540
4541 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004542 * @hide String array of package names.
4543 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004544 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004545 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4546
4547 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004548 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4549 * intents to indicate whether this represents a full uninstall (removing
4550 * both the code and its data) or a partial uninstall (leaving its data,
4551 * implying that this is an update).
4552 */
4553 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004554
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004555 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004556 * @hide
4557 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4558 * intents to indicate that at this point the package has been removed for
4559 * all users on the device.
4560 */
4561 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4562 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4563
4564 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004565 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4566 * intents to indicate that this is a replacement of the package, so this
4567 * broadcast will immediately be followed by an add broadcast for a
4568 * different version of the same package.
4569 */
4570 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004571
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004572 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004573 * Used as an int extra field in {@link android.app.AlarmManager} intents
4574 * to tell the application being invoked how many pending alarms are being
4575 * delievered with the intent. For one-shot alarms this will always be 1.
4576 * For recurring alarms, this might be greater than 1 if the device was
4577 * asleep or powered off at the time an earlier alarm would have been
4578 * delivered.
4579 */
4580 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004581
Jacek Surazski86b6c532009-05-13 14:38:28 +02004582 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004583 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4584 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004585 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4586 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004587 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4588 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4589 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004590 */
4591 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4592
4593 /**
4594 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4595 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004596 */
4597 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4598
4599 /**
4600 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4601 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004602 */
4603 public static final int EXTRA_DOCK_STATE_DESK = 1;
4604
4605 /**
4606 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4607 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004608 */
4609 public static final int EXTRA_DOCK_STATE_CAR = 2;
4610
4611 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004612 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4613 * to represent that the phone is in a analog (low end) dock.
4614 */
4615 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4616
4617 /**
4618 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4619 * to represent that the phone is in a digital (high end) dock.
4620 */
4621 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4622
4623 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004624 * Boolean that can be supplied as meta-data with a dock activity, to
4625 * indicate that the dock should take over the home key when it is active.
4626 */
4627 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004628
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004629 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004630 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4631 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004632 */
4633 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4634
4635 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004636 * Used in the extra field in the remote intent. It's astring token passed with the
4637 * remote intent.
4638 */
4639 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4640 "android.intent.extra.remote_intent_token";
4641
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004642 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004643 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004644 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004645 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004646 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004647 "android.intent.extra.changed_component_name";
4648
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004649 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004650 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004651 * and contains a string array of all of the components that have changed. If
4652 * the state of the overall package has changed, then it will contain an entry
4653 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004654 */
4655 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4656 "android.intent.extra.changed_component_name_list";
4657
4658 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004659 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004660 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004661 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4662 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4663 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004664 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004665 */
4666 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4667 "android.intent.extra.changed_package_list";
4668
4669 /**
4670 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004671 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4672 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004673 * and contains an integer array of uids of all of the components
4674 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004675 */
4676 public static final String EXTRA_CHANGED_UID_LIST =
4677 "android.intent.extra.changed_uid_list";
4678
4679 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004680 * @hide
4681 * Magic extra system code can use when binding, to give a label for
4682 * who it is that has bound to a service. This is an integer giving
4683 * a framework string resource that can be displayed to the user.
4684 */
4685 public static final String EXTRA_CLIENT_LABEL =
4686 "android.intent.extra.client_label";
4687
4688 /**
4689 * @hide
4690 * Magic extra system code can use when binding, to give a PendingIntent object
4691 * that can be launched for the user to disable the system's use of this
4692 * service.
4693 */
4694 public static final String EXTRA_CLIENT_INTENT =
4695 "android.intent.extra.client_intent";
4696
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004697 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004698 * Extra used to indicate that an intent should only return data that is on
4699 * the local device. This is a boolean extra; the default is false. If true,
4700 * an implementation should only allow the user to select data that is
4701 * already on the device, not requiring it be downloaded from a remote
4702 * service when opened.
4703 *
4704 * @see #ACTION_GET_CONTENT
4705 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004706 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004707 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004708 */
4709 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004710 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004711
Amith Yamasani13593602012-03-22 16:16:17 -07004712 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004713 * Extra used to indicate that an intent can allow the user to select and
4714 * return multiple items. This is a boolean extra; the default is false. If
4715 * true, an implementation is allowed to present the user with a UI where
4716 * they can pick multiple items that are all returned to the caller. When
4717 * this happens, they should be returned as the {@link #getClipData()} part
4718 * of the result Intent.
4719 *
4720 * @see #ACTION_GET_CONTENT
4721 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004722 */
4723 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004724 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004725
4726 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004727 * The integer userHandle carried with broadcast intents related to addition, removal and
4728 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4729 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4730 *
Amith Yamasani13593602012-03-22 16:16:17 -07004731 * @hide
4732 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004733 public static final String EXTRA_USER_HANDLE =
4734 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004735
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004736 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004737 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4738 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4739 */
4740 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004741 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004742
4743 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004744 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004745 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4746 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004747 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004748 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4749
4750 /**
4751 * Extra sent in the intent to the BroadcastReceiver that handles
4752 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4753 * the restrictions as key/value pairs.
4754 */
4755 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4756 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004757
Amith Yamasani86118ba2013-03-28 14:33:16 -07004758 /**
4759 * Extra used in the response from a BroadcastReceiver that handles
4760 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4761 */
4762 public static final String EXTRA_RESTRICTIONS_INTENT =
4763 "android.intent.extra.restrictions_intent";
4764
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004765 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004766 * Extra used to communicate a set of acceptable MIME types. The type of the
4767 * extra is {@code String[]}. Values may be a combination of concrete MIME
4768 * types (such as "image/png") and/or partial MIME types (such as
4769 * "audio/*").
4770 *
4771 * @see #ACTION_GET_CONTENT
4772 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004773 */
4774 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4775
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004776 /**
4777 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4778 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004779 * When this is true, hardware devices can use this information to determine that
4780 * they shouldn't do a complete shutdown of their device since this is not a
4781 * complete shutdown down to the kernel, but only user space restarting.
4782 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004783 */
4784 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4785 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4786
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004787 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004788 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4789 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4790 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4791 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004792 *
4793 * @hide for internal use only.
4794 */
4795 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4796 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004797 /** @hide */
4798 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4799 /** @hide */
4800 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4801 /** @hide */
4802 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004803
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004804 /** {@hide} */
4805 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4806
Rubin Xue8490f12015-06-25 12:17:48 +01004807 /** {@hide} */
4808 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4809
Santos Cordon15a13782015-03-31 18:32:31 -07004810 /**
4811 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4812 * activation request.
4813 * TODO: Add information about the structure and response data used with the pending intent.
4814 * @hide
4815 */
4816 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4817 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4818
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004819 /**
4820 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004821 *
4822 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004823 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004824 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004825 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4826
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004827 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004828 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4829 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4830 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004831 *
4832 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004833 * @see #ACTION_QUICK_VIEW
4834 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004835 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004836 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004837 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4838 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004839
4840 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004841 * An optional extra of {@code String[]} indicating which quick view features should be made
4842 * available to the user in the quick view UI while handing a
4843 * {@link Intent#ACTION_QUICK_VIEW} intent.
4844 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4845 * Quick viewer can implement features not listed below.
4846 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4847 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4848 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4849 * <p>
4850 * Requirements:
4851 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4852 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4853 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4854 * internal policies.
4855 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4856 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4857 * disable or hide features.
4858 *
4859 * @see #ACTION_QUICK_VIEW
4860 */
4861 public static final String EXTRA_QUICK_VIEW_FEATURES =
4862 "android.intent.extra.QUICK_VIEW_FEATURES";
4863
4864 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004865 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004866 * When a profile goes into quiet mode, all apps in the profile are killed and the
4867 * profile user is stopped. Widgets originating from the profile are masked, and app
4868 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004869 */
4870 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004871
4872 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004873 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004874 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004875 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4876 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004877 *
4878 * @hide
4879 */
4880 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4881 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4882
4883 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004884 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4885 * whether to show the chooser or not when there is only one application available
4886 * to choose from.
4887 *
4888 * @hide
4889 */
4890 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4891 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4892
4893 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004894 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004895 * to represent that a video codec is allowed to use.
4896 *
4897 * @hide
4898 */
4899 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4900
4901 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004902 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004903 * to represent that a audio codec is allowed to use.
4904 *
4905 * @hide
4906 */
4907 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4908
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004909 // ---------------------------------------------------------------------
4910 // ---------------------------------------------------------------------
4911 // Intent flags (see mFlags variable).
4912
Tor Norbyed9273d62013-05-30 15:59:53 -07004913 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004914 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004915 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4916 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004917 @Retention(RetentionPolicy.SOURCE)
4918 public @interface GrantUriMode {}
4919
Jeff Sharkey846318a2014-04-04 12:12:41 -07004920 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004921 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004922 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4923 @Retention(RetentionPolicy.SOURCE)
4924 public @interface AccessUriMode {}
4925
4926 /**
4927 * Test if given mode flags specify an access mode, which must be at least
4928 * read and/or write.
4929 *
4930 * @hide
4931 */
4932 public static boolean isAccessUriMode(int modeFlags) {
4933 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4934 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4935 }
4936
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004937 /** @hide */
4938 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4939 FLAG_GRANT_READ_URI_PERMISSION,
4940 FLAG_GRANT_WRITE_URI_PERMISSION,
4941 FLAG_FROM_BACKGROUND,
4942 FLAG_DEBUG_LOG_RESOLUTION,
4943 FLAG_EXCLUDE_STOPPED_PACKAGES,
4944 FLAG_INCLUDE_STOPPED_PACKAGES,
4945 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
4946 FLAG_GRANT_PREFIX_URI_PERMISSION,
4947 FLAG_DEBUG_TRIAGED_MISSING,
4948 FLAG_IGNORE_EPHEMERAL,
4949 FLAG_ACTIVITY_NO_HISTORY,
4950 FLAG_ACTIVITY_SINGLE_TOP,
4951 FLAG_ACTIVITY_NEW_TASK,
4952 FLAG_ACTIVITY_MULTIPLE_TASK,
4953 FLAG_ACTIVITY_CLEAR_TOP,
4954 FLAG_ACTIVITY_FORWARD_RESULT,
4955 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4956 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
4957 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
4958 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
4959 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
4960 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4961 FLAG_ACTIVITY_NEW_DOCUMENT,
4962 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4963 FLAG_ACTIVITY_NO_USER_ACTION,
4964 FLAG_ACTIVITY_REORDER_TO_FRONT,
4965 FLAG_ACTIVITY_NO_ANIMATION,
4966 FLAG_ACTIVITY_CLEAR_TASK,
4967 FLAG_ACTIVITY_TASK_ON_HOME,
4968 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
4969 FLAG_ACTIVITY_LAUNCH_ADJACENT,
4970 FLAG_RECEIVER_REGISTERED_ONLY,
4971 FLAG_RECEIVER_REPLACE_PENDING,
4972 FLAG_RECEIVER_FOREGROUND,
4973 FLAG_RECEIVER_NO_ABORT,
4974 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
4975 FLAG_RECEIVER_BOOT_UPGRADE,
4976 FLAG_RECEIVER_INCLUDE_BACKGROUND,
4977 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
4978 FLAG_RECEIVER_FROM_SHELL,
4979 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
4980 })
4981 @Retention(RetentionPolicy.SOURCE)
4982 public @interface Flags {}
4983
4984 /** @hide */
4985 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4986 FLAG_FROM_BACKGROUND,
4987 FLAG_DEBUG_LOG_RESOLUTION,
4988 FLAG_EXCLUDE_STOPPED_PACKAGES,
4989 FLAG_INCLUDE_STOPPED_PACKAGES,
4990 FLAG_DEBUG_TRIAGED_MISSING,
4991 FLAG_IGNORE_EPHEMERAL,
4992 FLAG_ACTIVITY_NO_HISTORY,
4993 FLAG_ACTIVITY_SINGLE_TOP,
4994 FLAG_ACTIVITY_NEW_TASK,
4995 FLAG_ACTIVITY_MULTIPLE_TASK,
4996 FLAG_ACTIVITY_CLEAR_TOP,
4997 FLAG_ACTIVITY_FORWARD_RESULT,
4998 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4999 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5000 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5001 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5002 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5003 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5004 FLAG_ACTIVITY_NEW_DOCUMENT,
5005 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5006 FLAG_ACTIVITY_NO_USER_ACTION,
5007 FLAG_ACTIVITY_REORDER_TO_FRONT,
5008 FLAG_ACTIVITY_NO_ANIMATION,
5009 FLAG_ACTIVITY_CLEAR_TASK,
5010 FLAG_ACTIVITY_TASK_ON_HOME,
5011 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5012 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5013 FLAG_RECEIVER_REGISTERED_ONLY,
5014 FLAG_RECEIVER_REPLACE_PENDING,
5015 FLAG_RECEIVER_FOREGROUND,
5016 FLAG_RECEIVER_NO_ABORT,
5017 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5018 FLAG_RECEIVER_BOOT_UPGRADE,
5019 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5020 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5021 FLAG_RECEIVER_FROM_SHELL,
5022 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5023 })
5024 @Retention(RetentionPolicy.SOURCE)
5025 public @interface MutableFlags {}
5026
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005027 /**
5028 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005029 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005030 * specified in its ClipData. When applying to an Intent's ClipData,
5031 * all URIs as well as recursive traversals through data or other ClipData
5032 * in Intent items will be granted; only the grant flags of the top-level
5033 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005034 */
5035 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5036 /**
5037 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005038 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005039 * specified in its ClipData. When applying to an Intent's ClipData,
5040 * all URIs as well as recursive traversals through data or other ClipData
5041 * in Intent items will be granted; only the grant flags of the top-level
5042 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005043 */
5044 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5045 /**
5046 * Can be set by the caller to indicate that this Intent is coming from
5047 * a background operation, not from direct user interaction.
5048 */
5049 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5050 /**
5051 * A flag you can enable for debugging: when set, log messages will be
5052 * printed during the resolution of this intent to show you what has
5053 * been found to create the final resolved list.
5054 */
5055 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005056 /**
5057 * If set, this intent will not match any components in packages that
5058 * are currently stopped. If this is not set, then the default behavior
5059 * is to include such applications in the result.
5060 */
5061 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5062 /**
5063 * If set, this intent will always match any components in packages that
5064 * are currently stopped. This is the default behavior when
5065 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5066 * flags are set, this one wins (it allows overriding of exclude for
5067 * places where the framework may automatically set the exclude flag).
5068 */
5069 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005070
5071 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005072 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005073 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005074 * persisted across device reboots until explicitly revoked with
5075 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5076 * grant for possible persisting; the receiving application must call
5077 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5078 * actually persist.
5079 *
5080 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5081 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5082 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005083 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005084 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005085 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005086
5087 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005088 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5089 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5090 * applies to any URI that is a prefix match against the original granted
5091 * URI. (Without this flag, the URI must match exactly for access to be
5092 * granted.) Another URI is considered a prefix match only when scheme,
5093 * authority, and all path segments defined by the prefix are an exact
5094 * match.
5095 */
5096 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5097
5098 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005099 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005100 * homework and verified that they correctly handle packages and components
5101 * that come and go over time. In particular:
5102 * <ul>
5103 * <li>Apps installed on external storage, which will appear to be
5104 * uninstalled while the the device is ejected.
5105 * <li>Apps with encryption unaware components, which will appear to not
5106 * exist while the device is locked.
5107 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005108 *
5109 * @hide
5110 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005111 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005112
5113 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005114 * Internal flag used to indicate ephemeral applications should not be
5115 * considered when resolving the intent.
5116 *
5117 * @hide
5118 */
5119 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5120
5121 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005122 * If set, the new activity is not kept in the history stack. As soon as
5123 * the user navigates away from it, the activity is finished. This may also
5124 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5125 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005126 *
5127 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5128 * is never invoked when the current activity starts a new activity which
5129 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005130 */
5131 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5132 /**
5133 * If set, the activity will not be launched if it is already running
5134 * at the top of the history stack.
5135 */
5136 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5137 /**
5138 * If set, this activity will become the start of a new task on this
5139 * history stack. A task (from the activity that started it to the
5140 * next task activity) defines an atomic group of activities that the
5141 * user can move to. Tasks can be moved to the foreground and background;
5142 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005143 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005144 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5145 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005146 *
5147 * <p>This flag is generally used by activities that want
5148 * to present a "launcher" style behavior: they give the user a list of
5149 * separate things that can be done, which otherwise run completely
5150 * independently of the activity launching them.
5151 *
5152 * <p>When using this flag, if a task is already running for the activity
5153 * you are now starting, then a new activity will not be started; instead,
5154 * the current task will simply be brought to the front of the screen with
5155 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5156 * to disable this behavior.
5157 *
5158 * <p>This flag can not be used when the caller is requesting a result from
5159 * the activity being launched.
5160 */
5161 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5162 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005163 * This flag is used to create a new task and launch an activity into it.
5164 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5165 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5166 * search through existing tasks for ones matching this Intent. Only if no such
5167 * task is found would a new task be created. When paired with
5168 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5169 * the search for a matching task and unconditionally start a new task.
5170 *
5171 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5172 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005173 * top-level application launcher.</strong> Used in conjunction with
5174 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5175 * behavior of bringing an existing task to the foreground. When set,
5176 * a new task is <em>always</em> started to host the Activity for the
5177 * Intent, regardless of whether there is already an existing task running
5178 * the same thing.
5179 *
5180 * <p><strong>Because the default system does not include graphical task management,
5181 * you should not use this flag unless you provide some way for a user to
5182 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005183 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005184 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5185 * creating new document tasks.
5186 *
5187 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005188 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005189 *
Scott Main7aee61f2011-02-08 11:25:01 -08005190 * <p>See
5191 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5192 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005193 *
5194 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5195 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005196 */
5197 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5198 /**
5199 * If set, and the activity being launched is already running in the
5200 * current task, then instead of launching a new instance of that activity,
5201 * all of the other activities on top of it will be closed and this Intent
5202 * will be delivered to the (now on top) old activity as a new Intent.
5203 *
5204 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5205 * If D calls startActivity() with an Intent that resolves to the component
5206 * of activity B, then C and D will be finished and B receive the given
5207 * Intent, resulting in the stack now being: A, B.
5208 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005209 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005210 * either receive the new intent you are starting here in its
5211 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005212 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005213 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5214 * the same intent, then it will be finished and re-created; for all other
5215 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5216 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005217 *
5218 * <p>This launch mode can also be used to good effect in conjunction with
5219 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5220 * of a task, it will bring any currently running instance of that task
5221 * to the foreground, and then clear it to its root state. This is
5222 * especially useful, for example, when launching an activity from the
5223 * notification manager.
5224 *
Scott Main7aee61f2011-02-08 11:25:01 -08005225 * <p>See
5226 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5227 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005228 */
5229 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5230 /**
5231 * If set and this intent is being used to launch a new activity from an
5232 * existing one, then the reply target of the existing activity will be
5233 * transfered to the new activity. This way the new activity can call
5234 * {@link android.app.Activity#setResult} and have that result sent back to
5235 * the reply target of the original activity.
5236 */
5237 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5238 /**
5239 * If set and this intent is being used to launch a new activity from an
5240 * existing one, the current activity will not be counted as the top
5241 * activity for deciding whether the new intent should be delivered to
5242 * the top instead of starting a new one. The previous activity will
5243 * be used as the top, with the assumption being that the current activity
5244 * will finish itself immediately.
5245 */
5246 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5247 /**
5248 * If set, the new activity is not kept in the list of recently launched
5249 * activities.
5250 */
5251 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5252 /**
5253 * This flag is not normally set by application code, but set for you by
5254 * the system as described in the
5255 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5256 * launchMode} documentation for the singleTask mode.
5257 */
5258 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5259 /**
5260 * If set, and this activity is either being started in a new task or
5261 * bringing to the top an existing task, then it will be launched as
5262 * the front door of the task. This will result in the application of
5263 * any affinities needed to have that task in the proper state (either
5264 * moving activities to or from it), or simply resetting that task to
5265 * its initial state if needed.
5266 */
5267 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5268 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005269 * This flag is not normally set by application code, but set for you by
5270 * the system if this activity is being launched from history
5271 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005272 */
5273 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005274 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005275 * @deprecated As of API 21 this performs identically to
5276 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005277 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005278 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005279 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005280 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005281 * This flag is used to open a document into a new task rooted at the activity launched
5282 * by this Intent. Through the use of this flag, or its equivalent attribute,
5283 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005284 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005285 *
Craig Mautner026596b2014-05-21 15:35:44 -07005286 * <p>The use of the activity attribute form of this,
5287 * {@link android.R.attr#documentLaunchMode}, is
5288 * preferred over the Intent flag described here. The attribute form allows the
5289 * Activity to specify multiple document behavior for all launchers of the Activity
5290 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005291 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005292 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5293 * it is kept after the activity is finished is different than the use of
5294 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5295 * this flag is being used to create a new recents entry, then by default that entry
5296 * will be removed once the activity is finished. You can modify this behavior with
5297 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5298 *
Craig Mautner026596b2014-05-21 15:35:44 -07005299 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5300 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5301 * equivalent of the Activity manifest specifying {@link
5302 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5303 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5304 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005305 *
Craig Mautner026596b2014-05-21 15:35:44 -07005306 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005307 *
Craig Mautner026596b2014-05-21 15:35:44 -07005308 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005309 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5310 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005311 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005312 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005313 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005314 * callback from occurring on the current frontmost activity before it is
5315 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005316 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005317 * <p>Typically, an activity can rely on that callback to indicate that an
5318 * explicit user action has caused their activity to be moved out of the
5319 * foreground. The callback marks an appropriate point in the activity's
5320 * lifecycle for it to dismiss any notifications that it intends to display
5321 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005322 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005323 * <p>If an activity is ever started via any non-user-driven events such as
5324 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5325 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005326 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005327 */
5328 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005329 /**
5330 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5331 * this flag will cause the launched activity to be brought to the front of its
5332 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005333 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005334 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5335 * If D calls startActivity() with an Intent that resolves to the component
5336 * of activity B, then B will be brought to the front of the history stack,
5337 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005338 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005339 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005340 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005341 */
5342 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005343 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005344 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5345 * this flag will prevent the system from applying an activity transition
5346 * animation to go to the next activity state. This doesn't mean an
5347 * animation will never run -- if another activity change happens that doesn't
5348 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005349 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005350 * when you are going to do a series of activity operations but the
5351 * animation seen by the user shouldn't be driven by the first activity
5352 * change but rather a later one.
5353 */
5354 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5355 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005356 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5357 * this flag will cause any existing task that would be associated with the
5358 * activity to be cleared before the activity is started. That is, the activity
5359 * becomes the new root of an otherwise empty task, and any old activities
5360 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5361 */
5362 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5363 /**
5364 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5365 * this flag will cause a newly launching task to be placed on top of the current
5366 * home activity task (if there is one). That is, pressing back from the task
5367 * will always return the user to home even if that was not the last activity they
5368 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5369 */
5370 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5371 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005372 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5373 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005374 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005375 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005376 * this flag. When set and the task's activity is finished, the recents
5377 * entry will remain in the interface for the user to re-launch it, like a
5378 * recents entry for a top-level application.
5379 * <p>
5380 * The receiving activity can override this request with
5381 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5382 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005383 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005384 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005385 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005386
5387 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005388 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5389 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005390 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5391 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005392 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005393 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005394
5395 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005396 * If set, when sending a broadcast only registered receivers will be
5397 * called -- no BroadcastReceiver components will be launched.
5398 */
5399 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005400 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005401 * If set, when sending a broadcast the new broadcast will replace
5402 * any existing pending broadcast that matches it. Matching is defined
5403 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5404 * true for the intents of the two broadcasts. When a match is found,
5405 * the new broadcast (and receivers associated with it) will replace the
5406 * existing one in the pending broadcast list, remaining at the same
5407 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005408 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005409 * <p>This flag is most typically used with sticky broadcasts, which
5410 * only care about delivering the most recent values of the broadcast
5411 * to their receivers.
5412 */
5413 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5414 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005415 * If set, when sending a broadcast the recipient is allowed to run at
5416 * foreground priority, with a shorter timeout interval. During normal
5417 * broadcasts the receivers are not automatically hoisted out of the
5418 * background priority class.
5419 */
5420 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5421 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005422 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5423 * They can still propagate results through to later receivers, but they can not prevent
5424 * later receivers from seeing the broadcast.
5425 */
5426 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5427 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005428 * If set, when sending a broadcast <i>before boot has completed</i> only
5429 * registered receivers will be called -- no BroadcastReceiver components
5430 * will be launched. Sticky intent state will be recorded properly even
5431 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5432 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005433 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005434 * <p>This flag is only for use by system sevices as a convenience to
5435 * avoid having to implement a more complex mechanism around detection
5436 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005437 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005438 * @hide
5439 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005440 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005441 /**
5442 * Set when this broadcast is for a boot upgrade, a special mode that
5443 * allows the broadcast to be sent before the system is ready and launches
5444 * the app process with no providers running in it.
5445 * @hide
5446 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005447 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005448 /**
5449 * If set, the broadcast will always go to manifest receivers in background (cached
5450 * or not running) apps, regardless of whether that would be done by default. By
5451 * default they will only receive broadcasts if the broadcast has specified an
5452 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005453 *
5454 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5455 * the broadcast code there must also be changed to match.
5456 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005457 * @hide
5458 */
5459 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5460 /**
5461 * If set, the broadcast will never go to manifest receivers in background (cached
5462 * or not running) apps, regardless of whether that would be done by default. By
5463 * default they will receive broadcasts if the broadcast has specified an
5464 * explicit component or package name.
5465 * @hide
5466 */
5467 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005468 /**
5469 * If set, this broadcast is being sent from the shell.
5470 * @hide
5471 */
5472 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005473
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005474 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005475 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5476 * will not receive broadcasts.
5477 *
5478 * <em>This flag has no effect when used by an Instant App.</em>
5479 */
5480 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5481
5482 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005483 * @hide Flags that can't be changed with PendingIntent.
5484 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005485 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5486 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5487 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005488
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005489 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005490 // ---------------------------------------------------------------------
5491 // toUri() and parseUri() options.
5492
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005493 /** @hide */
5494 @IntDef(flag = true, prefix = { "URI_" }, value = {
5495 URI_ALLOW_UNSAFE,
5496 URI_ANDROID_APP_SCHEME,
5497 URI_INTENT_SCHEME,
5498 })
5499 @Retention(RetentionPolicy.SOURCE)
5500 public @interface UriFlags {}
5501
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005502 /**
5503 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5504 * always has the "intent:" scheme. This syntax can be used when you want
5505 * to later disambiguate between URIs that are intended to describe an
5506 * Intent vs. all others that should be treated as raw URIs. When used
5507 * with {@link #parseUri}, any other scheme will result in a generic
5508 * VIEW action for that raw URI.
5509 */
5510 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005511
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005512 /**
5513 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5514 * always has the "android-app:" scheme. This is a variation of
5515 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5516 * http/https URI being delivered to a specific package name. The format
5517 * is:
5518 *
5519 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005520 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005521 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005522 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5523 * you must also include a scheme; including a path also requires both a host and a scheme.
5524 * The final #Intent; fragment can be used without a scheme, host, or path.
5525 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005526 * used with intents that have a {@link #setSelector}, since the base intent
5527 * will always have an explicit package name.</p>
5528 *
5529 * <p>Some examples of how this scheme maps to Intent objects:</p>
5530 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5531 * <colgroup align="left" />
5532 * <colgroup align="left" />
5533 * <thead>
5534 * <tr><th>URI</th> <th>Intent</th></tr>
5535 * </thead>
5536 *
5537 * <tbody>
5538 * <tr><td><code>android-app://com.example.app</code></td>
5539 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5540 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5541 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5542 * </table></td>
5543 * </tr>
5544 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5545 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5546 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5547 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5548 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5549 * </table></td>
5550 * </tr>
5551 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5552 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5553 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5554 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5555 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5556 * </table></td>
5557 * </tr>
5558 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5559 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5560 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5561 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5562 * </table></td>
5563 * </tr>
5564 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5565 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5566 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5567 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5568 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5569 * </table></td>
5570 * </tr>
5571 * <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>
5572 * <td><table border="" style="margin:0" >
5573 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5574 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5575 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5576 * </table></td>
5577 * </tr>
5578 * </tbody>
5579 * </table>
5580 */
5581 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5582
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005583 /**
5584 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5585 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5586 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5587 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5588 * generated Intent can not cause unexpected data access to happen.
5589 *
5590 * <p>If you do not trust the source of the URI being parsed, you should still do further
5591 * processing to protect yourself from it. In particular, when using it to start an
5592 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5593 * that can handle it.</p>
5594 */
5595 public static final int URI_ALLOW_UNSAFE = 1<<2;
5596
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005597 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005598
5599 private String mAction;
5600 private Uri mData;
5601 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005602 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005603 private ComponentName mComponent;
5604 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005605 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005606 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005607 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005608 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005609 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005610 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005611 /** Token to track instant app launches. Local only; do not copy cross-process. */
5612 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005613
5614 // ---------------------------------------------------------------------
5615
5616 /**
5617 * Create an empty intent.
5618 */
5619 public Intent() {
5620 }
5621
5622 /**
5623 * Copy constructor.
5624 */
5625 public Intent(Intent o) {
5626 this.mAction = o.mAction;
5627 this.mData = o.mData;
5628 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005629 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005630 this.mComponent = o.mComponent;
5631 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005632 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005633 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005634 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005635 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005636 }
5637 if (o.mExtras != null) {
5638 this.mExtras = new Bundle(o.mExtras);
5639 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005640 if (o.mSourceBounds != null) {
5641 this.mSourceBounds = new Rect(o.mSourceBounds);
5642 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005643 if (o.mSelector != null) {
5644 this.mSelector = new Intent(o.mSelector);
5645 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005646 if (o.mClipData != null) {
5647 this.mClipData = new ClipData(o.mClipData);
5648 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005649 }
5650
5651 @Override
5652 public Object clone() {
5653 return new Intent(this);
5654 }
5655
5656 private Intent(Intent o, boolean all) {
5657 this.mAction = o.mAction;
5658 this.mData = o.mData;
5659 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005660 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005661 this.mComponent = o.mComponent;
5662 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005663 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005664 }
5665 }
5666
5667 /**
5668 * Make a clone of only the parts of the Intent that are relevant for
5669 * filter matching: the action, data, type, component, and categories.
5670 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005671 public @NonNull Intent cloneFilter() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005672 return new Intent(this, false);
5673 }
5674
5675 /**
5676 * Create an intent with a given action. All other fields (data, type,
5677 * class) are null. Note that the action <em>must</em> be in a
5678 * namespace because Intents are used globally in the system -- for
5679 * example the system VIEW action is android.intent.action.VIEW; an
5680 * application's custom action would be something like
5681 * com.google.app.myapp.CUSTOM_ACTION.
5682 *
5683 * @param action The Intent action, such as ACTION_VIEW.
5684 */
5685 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005686 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005687 }
5688
5689 /**
5690 * Create an intent with a given action and for a given data url. Note
5691 * that the action <em>must</em> be in a namespace because Intents are
5692 * used globally in the system -- for example the system VIEW action is
5693 * android.intent.action.VIEW; an application's custom action would be
5694 * something like com.google.app.myapp.CUSTOM_ACTION.
5695 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005696 * <p><em>Note: scheme and host name matching in the Android framework is
5697 * case-sensitive, unlike the formal RFC. As a result,
5698 * you should always ensure that you write your Uri with these elements
5699 * using lower case letters, and normalize any Uris you receive from
5700 * outside of Android to ensure the scheme and host is lower case.</em></p>
5701 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005702 * @param action The Intent action, such as ACTION_VIEW.
5703 * @param uri The Intent data URI.
5704 */
5705 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005706 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005707 mData = uri;
5708 }
5709
5710 /**
5711 * Create an intent for a specific component. All other fields (action, data,
5712 * type, class) are null, though they can be modified later with explicit
5713 * calls. This provides a convenient way to create an intent that is
5714 * intended to execute a hard-coded class name, rather than relying on the
5715 * system to find an appropriate class for you; see {@link #setComponent}
5716 * for more information on the repercussions of this.
5717 *
5718 * @param packageContext A Context of the application package implementing
5719 * this class.
5720 * @param cls The component class that is to be used for the intent.
5721 *
5722 * @see #setClass
5723 * @see #setComponent
5724 * @see #Intent(String, android.net.Uri , Context, Class)
5725 */
5726 public Intent(Context packageContext, Class<?> cls) {
5727 mComponent = new ComponentName(packageContext, cls);
5728 }
5729
5730 /**
5731 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005732 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005733 * construct the Intent and then calling {@link #setClass} to set its
5734 * class.
5735 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005736 * <p><em>Note: scheme and host name matching in the Android framework is
5737 * case-sensitive, unlike the formal RFC. As a result,
5738 * you should always ensure that you write your Uri with these elements
5739 * using lower case letters, and normalize any Uris you receive from
5740 * outside of Android to ensure the scheme and host is lower case.</em></p>
5741 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005742 * @param action The Intent action, such as ACTION_VIEW.
5743 * @param uri The Intent data URI.
5744 * @param packageContext A Context of the application package implementing
5745 * this class.
5746 * @param cls The component class that is to be used for the intent.
5747 *
5748 * @see #Intent(String, android.net.Uri)
5749 * @see #Intent(Context, Class)
5750 * @see #setClass
5751 * @see #setComponent
5752 */
5753 public Intent(String action, Uri uri,
5754 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005755 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005756 mData = uri;
5757 mComponent = new ComponentName(packageContext, cls);
5758 }
5759
5760 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005761 * Create an intent to launch the main (root) activity of a task. This
5762 * is the Intent that is started when the application's is launched from
5763 * Home. For anything else that wants to launch an application in the
5764 * same way, it is important that they use an Intent structured the same
5765 * way, and can use this function to ensure this is the case.
5766 *
5767 * <p>The returned Intent has the given Activity component as its explicit
5768 * component, {@link #ACTION_MAIN} as its action, and includes the
5769 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5770 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5771 * to do that through {@link #addFlags(int)} on the returned Intent.
5772 *
5773 * @param mainActivity The main activity component that this Intent will
5774 * launch.
5775 * @return Returns a newly created Intent that can be used to launch the
5776 * activity as a main application entry.
5777 *
5778 * @see #setClass
5779 * @see #setComponent
5780 */
5781 public static Intent makeMainActivity(ComponentName mainActivity) {
5782 Intent intent = new Intent(ACTION_MAIN);
5783 intent.setComponent(mainActivity);
5784 intent.addCategory(CATEGORY_LAUNCHER);
5785 return intent;
5786 }
5787
5788 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005789 * Make an Intent for the main activity of an application, without
5790 * specifying a specific activity to run but giving a selector to find
5791 * the activity. This results in a final Intent that is structured
5792 * the same as when the application is launched from
5793 * Home. For anything else that wants to launch an application in the
5794 * same way, it is important that they use an Intent structured the same
5795 * way, and can use this function to ensure this is the case.
5796 *
5797 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5798 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5799 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5800 * to do that through {@link #addFlags(int)} on the returned Intent.
5801 *
5802 * @param selectorAction The action name of the Intent's selector.
5803 * @param selectorCategory The name of a category to add to the Intent's
5804 * selector.
5805 * @return Returns a newly created Intent that can be used to launch the
5806 * activity as a main application entry.
5807 *
5808 * @see #setSelector(Intent)
5809 */
5810 public static Intent makeMainSelectorActivity(String selectorAction,
5811 String selectorCategory) {
5812 Intent intent = new Intent(ACTION_MAIN);
5813 intent.addCategory(CATEGORY_LAUNCHER);
5814 Intent selector = new Intent();
5815 selector.setAction(selectorAction);
5816 selector.addCategory(selectorCategory);
5817 intent.setSelector(selector);
5818 return intent;
5819 }
5820
5821 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005822 * Make an Intent that can be used to re-launch an application's task
5823 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5824 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5825 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5826 *
5827 * @param mainActivity The activity component that is the root of the
5828 * task; this is the activity that has been published in the application's
5829 * manifest as the main launcher icon.
5830 *
5831 * @return Returns a newly created Intent that can be used to relaunch the
5832 * activity's task in its root state.
5833 */
5834 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5835 Intent intent = makeMainActivity(mainActivity);
5836 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5837 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5838 return intent;
5839 }
5840
5841 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005842 * Call {@link #parseUri} with 0 flags.
5843 * @deprecated Use {@link #parseUri} instead.
5844 */
5845 @Deprecated
5846 public static Intent getIntent(String uri) throws URISyntaxException {
5847 return parseUri(uri, 0);
5848 }
Tom Taylord4a47292009-12-21 13:59:18 -08005849
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005850 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005851 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005852 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005853 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005854 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005855 *
5856 * <p>The URI given here must not be relative -- that is, it must include
5857 * the scheme and full path.
5858 *
5859 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005860 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005861 *
5862 * @return Intent The newly created Intent object.
5863 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005864 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5865 * it bad (as parsed by the Uri class) or the Intent data within the
5866 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005867 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005868 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005869 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005870 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005871 int i = 0;
5872 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005873 final boolean androidApp = uri.startsWith("android-app:");
5874
5875 // Validate intent scheme if requested.
5876 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5877 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005878 Intent intent = new Intent(ACTION_VIEW);
5879 try {
5880 intent.setData(Uri.parse(uri));
5881 } catch (IllegalArgumentException e) {
5882 throw new URISyntaxException(uri, e.getMessage());
5883 }
5884 return intent;
5885 }
5886 }
Tom Taylord4a47292009-12-21 13:59:18 -08005887
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005888 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005889 // simple case
5890 if (i == -1) {
5891 if (!androidApp) {
5892 return new Intent(ACTION_VIEW, Uri.parse(uri));
5893 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005894
5895 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005896 } else if (!uri.startsWith("#Intent;", i)) {
5897 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005898 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005899 } else {
5900 i = -1;
5901 }
5902 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005903
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005904 // new format
5905 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005906 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005907 boolean explicitAction = false;
5908 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005909
5910 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005911 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005912 String data;
5913 if (i >= 0) {
5914 data = uri.substring(0, i);
5915 i += 8; // length of "#Intent;"
5916 } else {
5917 data = uri;
5918 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005919
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005920 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005921 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005922 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005923 if (eq < 0) eq = i-1;
5924 int semi = uri.indexOf(';', i);
5925 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005926
5927 // action
5928 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005929 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005930 if (!inSelector) {
5931 explicitAction = true;
5932 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005933 }
5934
5935 // categories
5936 else if (uri.startsWith("category=", i)) {
5937 intent.addCategory(value);
5938 }
5939
5940 // type
5941 else if (uri.startsWith("type=", i)) {
5942 intent.mType = value;
5943 }
5944
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005945 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005946 else if (uri.startsWith("launchFlags=", i)) {
5947 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005948 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5949 intent.mFlags &= ~IMMUTABLE_FLAGS;
5950 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005951 }
5952
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005953 // package
5954 else if (uri.startsWith("package=", i)) {
5955 intent.mPackage = value;
5956 }
5957
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005958 // component
5959 else if (uri.startsWith("component=", i)) {
5960 intent.mComponent = ComponentName.unflattenFromString(value);
5961 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005962
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005963 // scheme
5964 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005965 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005966 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005967 } else {
5968 scheme = value;
5969 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005970 }
5971
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005972 // source bounds
5973 else if (uri.startsWith("sourceBounds=", i)) {
5974 intent.mSourceBounds = Rect.unflattenFromString(value);
5975 }
5976
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005977 // selector
5978 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5979 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005980 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005981 }
5982
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005983 // extra
5984 else {
5985 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005986 // create Bundle if it doesn't already exist
5987 if (intent.mExtras == null) intent.mExtras = new Bundle();
5988 Bundle b = intent.mExtras;
5989 // add EXTRA
5990 if (uri.startsWith("S.", i)) b.putString(key, value);
5991 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5992 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5993 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5994 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5995 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5996 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5997 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5998 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5999 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6000 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006001
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006002 // move to the next item
6003 i = semi + 1;
6004 }
6005
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006006 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006007 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006008 if (baseIntent.mPackage == null) {
6009 baseIntent.setSelector(intent);
6010 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006011 intent = baseIntent;
6012 }
6013
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006014 if (data != null) {
6015 if (data.startsWith("intent:")) {
6016 data = data.substring(7);
6017 if (scheme != null) {
6018 data = scheme + ':' + data;
6019 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006020 } else if (data.startsWith("android-app:")) {
6021 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6022 // Correctly formed android-app, first part is package name.
6023 int end = data.indexOf('/', 14);
6024 if (end < 0) {
6025 // All we have is a package name.
6026 intent.mPackage = data.substring(14);
6027 if (!explicitAction) {
6028 intent.setAction(ACTION_MAIN);
6029 }
6030 data = "";
6031 } else {
6032 // Target the Intent at the given package name always.
6033 String authority = null;
6034 intent.mPackage = data.substring(14, end);
6035 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006036 if ((end+1) < data.length()) {
6037 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6038 // Found a scheme, remember it.
6039 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006040 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006041 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6042 // Found a authority, remember it.
6043 authority = data.substring(end+1, newEnd);
6044 end = newEnd;
6045 }
6046 } else {
6047 // All we have is a scheme.
6048 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006049 }
6050 }
6051 if (scheme == null) {
6052 // If there was no scheme, then this just targets the package.
6053 if (!explicitAction) {
6054 intent.setAction(ACTION_MAIN);
6055 }
6056 data = "";
6057 } else if (authority == null) {
6058 data = scheme + ":";
6059 } else {
6060 data = scheme + "://" + authority + data.substring(end);
6061 }
6062 }
6063 } else {
6064 data = "";
6065 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006066 }
Tom Taylord4a47292009-12-21 13:59:18 -08006067
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006068 if (data.length() > 0) {
6069 try {
6070 intent.mData = Uri.parse(data);
6071 } catch (IllegalArgumentException e) {
6072 throw new URISyntaxException(uri, e.getMessage());
6073 }
6074 }
6075 }
Tom Taylord4a47292009-12-21 13:59:18 -08006076
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006077 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006078
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006079 } catch (IndexOutOfBoundsException e) {
6080 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6081 }
6082 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006083
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006084 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006085 return getIntentOld(uri, 0);
6086 }
6087
6088 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006089 Intent intent;
6090
6091 int i = uri.lastIndexOf('#');
6092 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006093 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006094 final int intentFragmentStart = i;
6095 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006096
6097 i++;
6098
6099 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006100 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006101 i += 7;
6102 int j = uri.indexOf(')', i);
6103 action = uri.substring(i, j);
6104 i = j + 1;
6105 }
6106
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006107 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006108
6109 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006110 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006111 i += 11;
6112 int j = uri.indexOf(')', i);
6113 while (i < j) {
6114 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006115 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006116 if (i < sep) {
6117 intent.addCategory(uri.substring(i, sep));
6118 }
6119 i = sep + 1;
6120 }
6121 i = j + 1;
6122 }
6123
6124 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006125 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006126 i += 5;
6127 int j = uri.indexOf(')', i);
6128 intent.mType = uri.substring(i, j);
6129 i = j + 1;
6130 }
6131
6132 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006133 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006134 i += 12;
6135 int j = uri.indexOf(')', i);
6136 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006137 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6138 intent.mFlags &= ~IMMUTABLE_FLAGS;
6139 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006140 i = j + 1;
6141 }
6142
6143 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006144 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006145 i += 10;
6146 int j = uri.indexOf(')', i);
6147 int sep = uri.indexOf('!', i);
6148 if (sep >= 0 && sep < j) {
6149 String pkg = uri.substring(i, sep);
6150 String cls = uri.substring(sep + 1, j);
6151 intent.mComponent = new ComponentName(pkg, cls);
6152 }
6153 i = j + 1;
6154 }
6155
6156 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006157 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006158 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006159
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006160 final int closeParen = uri.indexOf(')', i);
6161 if (closeParen == -1) throw new URISyntaxException(uri,
6162 "EXTRA missing trailing ')'", i);
6163
6164 while (i < closeParen) {
6165 // fetch the key value
6166 int j = uri.indexOf('=', i);
6167 if (j <= i + 1 || i >= closeParen) {
6168 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6169 }
6170 char type = uri.charAt(i);
6171 i++;
6172 String key = uri.substring(i, j);
6173 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006174
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006175 // get type-value
6176 j = uri.indexOf('!', i);
6177 if (j == -1 || j >= closeParen) j = closeParen;
6178 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6179 String value = uri.substring(i, j);
6180 i = j;
6181
6182 // create Bundle if it doesn't already exist
6183 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006184
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006185 // add item to bundle
6186 try {
6187 switch (type) {
6188 case 'S':
6189 intent.mExtras.putString(key, Uri.decode(value));
6190 break;
6191 case 'B':
6192 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6193 break;
6194 case 'b':
6195 intent.mExtras.putByte(key, Byte.parseByte(value));
6196 break;
6197 case 'c':
6198 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6199 break;
6200 case 'd':
6201 intent.mExtras.putDouble(key, Double.parseDouble(value));
6202 break;
6203 case 'f':
6204 intent.mExtras.putFloat(key, Float.parseFloat(value));
6205 break;
6206 case 'i':
6207 intent.mExtras.putInt(key, Integer.parseInt(value));
6208 break;
6209 case 'l':
6210 intent.mExtras.putLong(key, Long.parseLong(value));
6211 break;
6212 case 's':
6213 intent.mExtras.putShort(key, Short.parseShort(value));
6214 break;
6215 default:
6216 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6217 }
6218 } catch (NumberFormatException e) {
6219 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6220 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006221
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006222 char ch = uri.charAt(i);
6223 if (ch == ')') break;
6224 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6225 i++;
6226 }
6227 }
6228
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006229 if (isIntentFragment) {
6230 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6231 } else {
6232 intent.mData = Uri.parse(uri);
6233 }
Tom Taylord4a47292009-12-21 13:59:18 -08006234
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006235 if (intent.mAction == null) {
6236 // By default, if no action is specified, then use VIEW.
6237 intent.mAction = ACTION_VIEW;
6238 }
6239
6240 } else {
6241 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6242 }
6243
6244 return intent;
6245 }
6246
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006247 /** @hide */
6248 public interface CommandOptionHandler {
6249 boolean handleOption(String opt, ShellCommand cmd);
6250 }
6251
6252 /** @hide */
6253 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6254 throws URISyntaxException {
6255 Intent intent = new Intent();
6256 Intent baseIntent = intent;
6257 boolean hasIntentInfo = false;
6258
6259 Uri data = null;
6260 String type = null;
6261
6262 String opt;
6263 while ((opt=cmd.getNextOption()) != null) {
6264 switch (opt) {
6265 case "-a":
6266 intent.setAction(cmd.getNextArgRequired());
6267 if (intent == baseIntent) {
6268 hasIntentInfo = true;
6269 }
6270 break;
6271 case "-d":
6272 data = Uri.parse(cmd.getNextArgRequired());
6273 if (intent == baseIntent) {
6274 hasIntentInfo = true;
6275 }
6276 break;
6277 case "-t":
6278 type = cmd.getNextArgRequired();
6279 if (intent == baseIntent) {
6280 hasIntentInfo = true;
6281 }
6282 break;
6283 case "-c":
6284 intent.addCategory(cmd.getNextArgRequired());
6285 if (intent == baseIntent) {
6286 hasIntentInfo = true;
6287 }
6288 break;
6289 case "-e":
6290 case "--es": {
6291 String key = cmd.getNextArgRequired();
6292 String value = cmd.getNextArgRequired();
6293 intent.putExtra(key, value);
6294 }
6295 break;
6296 case "--esn": {
6297 String key = cmd.getNextArgRequired();
6298 intent.putExtra(key, (String) null);
6299 }
6300 break;
6301 case "--ei": {
6302 String key = cmd.getNextArgRequired();
6303 String value = cmd.getNextArgRequired();
6304 intent.putExtra(key, Integer.decode(value));
6305 }
6306 break;
6307 case "--eu": {
6308 String key = cmd.getNextArgRequired();
6309 String value = cmd.getNextArgRequired();
6310 intent.putExtra(key, Uri.parse(value));
6311 }
6312 break;
6313 case "--ecn": {
6314 String key = cmd.getNextArgRequired();
6315 String value = cmd.getNextArgRequired();
6316 ComponentName cn = ComponentName.unflattenFromString(value);
6317 if (cn == null)
6318 throw new IllegalArgumentException("Bad component name: " + value);
6319 intent.putExtra(key, cn);
6320 }
6321 break;
6322 case "--eia": {
6323 String key = cmd.getNextArgRequired();
6324 String value = cmd.getNextArgRequired();
6325 String[] strings = value.split(",");
6326 int[] list = new int[strings.length];
6327 for (int i = 0; i < strings.length; i++) {
6328 list[i] = Integer.decode(strings[i]);
6329 }
6330 intent.putExtra(key, list);
6331 }
6332 break;
6333 case "--eial": {
6334 String key = cmd.getNextArgRequired();
6335 String value = cmd.getNextArgRequired();
6336 String[] strings = value.split(",");
6337 ArrayList<Integer> list = new ArrayList<>(strings.length);
6338 for (int i = 0; i < strings.length; i++) {
6339 list.add(Integer.decode(strings[i]));
6340 }
6341 intent.putExtra(key, list);
6342 }
6343 break;
6344 case "--el": {
6345 String key = cmd.getNextArgRequired();
6346 String value = cmd.getNextArgRequired();
6347 intent.putExtra(key, Long.valueOf(value));
6348 }
6349 break;
6350 case "--ela": {
6351 String key = cmd.getNextArgRequired();
6352 String value = cmd.getNextArgRequired();
6353 String[] strings = value.split(",");
6354 long[] list = new long[strings.length];
6355 for (int i = 0; i < strings.length; i++) {
6356 list[i] = Long.valueOf(strings[i]);
6357 }
6358 intent.putExtra(key, list);
6359 hasIntentInfo = true;
6360 }
6361 break;
6362 case "--elal": {
6363 String key = cmd.getNextArgRequired();
6364 String value = cmd.getNextArgRequired();
6365 String[] strings = value.split(",");
6366 ArrayList<Long> list = new ArrayList<>(strings.length);
6367 for (int i = 0; i < strings.length; i++) {
6368 list.add(Long.valueOf(strings[i]));
6369 }
6370 intent.putExtra(key, list);
6371 hasIntentInfo = true;
6372 }
6373 break;
6374 case "--ef": {
6375 String key = cmd.getNextArgRequired();
6376 String value = cmd.getNextArgRequired();
6377 intent.putExtra(key, Float.valueOf(value));
6378 hasIntentInfo = true;
6379 }
6380 break;
6381 case "--efa": {
6382 String key = cmd.getNextArgRequired();
6383 String value = cmd.getNextArgRequired();
6384 String[] strings = value.split(",");
6385 float[] list = new float[strings.length];
6386 for (int i = 0; i < strings.length; i++) {
6387 list[i] = Float.valueOf(strings[i]);
6388 }
6389 intent.putExtra(key, list);
6390 hasIntentInfo = true;
6391 }
6392 break;
6393 case "--efal": {
6394 String key = cmd.getNextArgRequired();
6395 String value = cmd.getNextArgRequired();
6396 String[] strings = value.split(",");
6397 ArrayList<Float> list = new ArrayList<>(strings.length);
6398 for (int i = 0; i < strings.length; i++) {
6399 list.add(Float.valueOf(strings[i]));
6400 }
6401 intent.putExtra(key, list);
6402 hasIntentInfo = true;
6403 }
6404 break;
6405 case "--esa": {
6406 String key = cmd.getNextArgRequired();
6407 String value = cmd.getNextArgRequired();
6408 // Split on commas unless they are preceeded by an escape.
6409 // The escape character must be escaped for the string and
6410 // again for the regex, thus four escape characters become one.
6411 String[] strings = value.split("(?<!\\\\),");
6412 intent.putExtra(key, strings);
6413 hasIntentInfo = true;
6414 }
6415 break;
6416 case "--esal": {
6417 String key = cmd.getNextArgRequired();
6418 String value = cmd.getNextArgRequired();
6419 // Split on commas unless they are preceeded by an escape.
6420 // The escape character must be escaped for the string and
6421 // again for the regex, thus four escape characters become one.
6422 String[] strings = value.split("(?<!\\\\),");
6423 ArrayList<String> list = new ArrayList<>(strings.length);
6424 for (int i = 0; i < strings.length; i++) {
6425 list.add(strings[i]);
6426 }
6427 intent.putExtra(key, list);
6428 hasIntentInfo = true;
6429 }
6430 break;
6431 case "--ez": {
6432 String key = cmd.getNextArgRequired();
6433 String value = cmd.getNextArgRequired().toLowerCase();
6434 // Boolean.valueOf() results in false for anything that is not "true", which is
6435 // error-prone in shell commands
6436 boolean arg;
6437 if ("true".equals(value) || "t".equals(value)) {
6438 arg = true;
6439 } else if ("false".equals(value) || "f".equals(value)) {
6440 arg = false;
6441 } else {
6442 try {
6443 arg = Integer.decode(value) != 0;
6444 } catch (NumberFormatException ex) {
6445 throw new IllegalArgumentException("Invalid boolean value: " + value);
6446 }
6447 }
6448
6449 intent.putExtra(key, arg);
6450 }
6451 break;
6452 case "-n": {
6453 String str = cmd.getNextArgRequired();
6454 ComponentName cn = ComponentName.unflattenFromString(str);
6455 if (cn == null)
6456 throw new IllegalArgumentException("Bad component name: " + str);
6457 intent.setComponent(cn);
6458 if (intent == baseIntent) {
6459 hasIntentInfo = true;
6460 }
6461 }
6462 break;
6463 case "-p": {
6464 String str = cmd.getNextArgRequired();
6465 intent.setPackage(str);
6466 if (intent == baseIntent) {
6467 hasIntentInfo = true;
6468 }
6469 }
6470 break;
6471 case "-f":
6472 String str = cmd.getNextArgRequired();
6473 intent.setFlags(Integer.decode(str).intValue());
6474 break;
6475 case "--grant-read-uri-permission":
6476 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6477 break;
6478 case "--grant-write-uri-permission":
6479 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6480 break;
6481 case "--grant-persistable-uri-permission":
6482 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6483 break;
6484 case "--grant-prefix-uri-permission":
6485 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6486 break;
6487 case "--exclude-stopped-packages":
6488 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6489 break;
6490 case "--include-stopped-packages":
6491 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6492 break;
6493 case "--debug-log-resolution":
6494 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6495 break;
6496 case "--activity-brought-to-front":
6497 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6498 break;
6499 case "--activity-clear-top":
6500 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6501 break;
6502 case "--activity-clear-when-task-reset":
6503 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6504 break;
6505 case "--activity-exclude-from-recents":
6506 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6507 break;
6508 case "--activity-launched-from-history":
6509 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6510 break;
6511 case "--activity-multiple-task":
6512 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6513 break;
6514 case "--activity-no-animation":
6515 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6516 break;
6517 case "--activity-no-history":
6518 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6519 break;
6520 case "--activity-no-user-action":
6521 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6522 break;
6523 case "--activity-previous-is-top":
6524 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6525 break;
6526 case "--activity-reorder-to-front":
6527 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6528 break;
6529 case "--activity-reset-task-if-needed":
6530 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6531 break;
6532 case "--activity-single-top":
6533 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6534 break;
6535 case "--activity-clear-task":
6536 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6537 break;
6538 case "--activity-task-on-home":
6539 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6540 break;
6541 case "--receiver-registered-only":
6542 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6543 break;
6544 case "--receiver-replace-pending":
6545 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6546 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006547 case "--receiver-foreground":
6548 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6549 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006550 case "--receiver-no-abort":
6551 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6552 break;
6553 case "--receiver-include-background":
6554 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6555 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006556 case "--selector":
6557 intent.setDataAndType(data, type);
6558 intent = new Intent();
6559 break;
6560 default:
6561 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6562 // Okay, caller handled this option.
6563 } else {
6564 throw new IllegalArgumentException("Unknown option: " + opt);
6565 }
6566 break;
6567 }
6568 }
6569 intent.setDataAndType(data, type);
6570
6571 final boolean hasSelector = intent != baseIntent;
6572 if (hasSelector) {
6573 // A selector was specified; fix up.
6574 baseIntent.setSelector(intent);
6575 intent = baseIntent;
6576 }
6577
6578 String arg = cmd.getNextArg();
6579 baseIntent = null;
6580 if (arg == null) {
6581 if (hasSelector) {
6582 // If a selector has been specified, and no arguments
6583 // have been supplied for the main Intent, then we can
6584 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6585 // need to have a component name specified yet, the
6586 // selector will take care of that.
6587 baseIntent = new Intent(Intent.ACTION_MAIN);
6588 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6589 }
6590 } else if (arg.indexOf(':') >= 0) {
6591 // The argument is a URI. Fully parse it, and use that result
6592 // to fill in any data not specified so far.
6593 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6594 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6595 } else if (arg.indexOf('/') >= 0) {
6596 // The argument is a component name. Build an Intent to launch
6597 // it.
6598 baseIntent = new Intent(Intent.ACTION_MAIN);
6599 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6600 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6601 } else {
6602 // Assume the argument is a package name.
6603 baseIntent = new Intent(Intent.ACTION_MAIN);
6604 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6605 baseIntent.setPackage(arg);
6606 }
6607 if (baseIntent != null) {
6608 Bundle extras = intent.getExtras();
6609 intent.replaceExtras((Bundle)null);
6610 Bundle uriExtras = baseIntent.getExtras();
6611 baseIntent.replaceExtras((Bundle)null);
6612 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6613 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6614 for (String c : cats) {
6615 baseIntent.removeCategory(c);
6616 }
6617 }
6618 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6619 if (extras == null) {
6620 extras = uriExtras;
6621 } else if (uriExtras != null) {
6622 uriExtras.putAll(extras);
6623 extras = uriExtras;
6624 }
6625 intent.replaceExtras(extras);
6626 hasIntentInfo = true;
6627 }
6628
6629 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6630 return intent;
6631 }
6632
6633 /** @hide */
6634 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6635 final String[] lines = new String[] {
6636 "<INTENT> specifications include these flags and arguments:",
6637 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6638 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6639 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6640 " [--esn <EXTRA_KEY> ...]",
6641 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6642 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6643 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6644 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6645 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6646 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6647 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6648 " (mutiple extras passed as Integer[])",
6649 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6650 " (mutiple extras passed as List<Integer>)",
6651 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6652 " (mutiple extras passed as Long[])",
6653 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6654 " (mutiple extras passed as List<Long>)",
6655 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6656 " (mutiple extras passed as Float[])",
6657 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6658 " (mutiple extras passed as List<Float>)",
6659 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6660 " (mutiple extras passed as String[]; to embed a comma into a string,",
6661 " escape it using \"\\,\")",
6662 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6663 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6664 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006665 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006666 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6667 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6668 " [--debug-log-resolution] [--exclude-stopped-packages]",
6669 " [--include-stopped-packages]",
6670 " [--activity-brought-to-front] [--activity-clear-top]",
6671 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6672 " [--activity-launched-from-history] [--activity-multiple-task]",
6673 " [--activity-no-animation] [--activity-no-history]",
6674 " [--activity-no-user-action] [--activity-previous-is-top]",
6675 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6676 " [--activity-single-top] [--activity-clear-task]",
6677 " [--activity-task-on-home]",
6678 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006679 " [--receiver-foreground] [--receiver-no-abort]",
6680 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006681 " [--selector]",
6682 " [<URI> | <PACKAGE> | <COMPONENT>]"
6683 };
6684 for (String line : lines) {
6685 pw.print(prefix);
6686 pw.println(line);
6687 }
6688 }
6689
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006690 /**
6691 * Retrieve the general action to be performed, such as
6692 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6693 * the information in the intent should be interpreted -- most importantly,
6694 * what to do with the data returned by {@link #getData}.
6695 *
6696 * @return The action of this intent or null if none is specified.
6697 *
6698 * @see #setAction
6699 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006700 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006701 return mAction;
6702 }
6703
6704 /**
6705 * Retrieve data this intent is operating on. This URI specifies the name
6706 * of the data; often it uses the content: scheme, specifying data in a
6707 * content provider. Other schemes may be handled by specific activities,
6708 * such as http: by the web browser.
6709 *
6710 * @return The URI of the data this intent is targeting or null.
6711 *
6712 * @see #getScheme
6713 * @see #setData
6714 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006715 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006716 return mData;
6717 }
6718
6719 /**
6720 * The same as {@link #getData()}, but returns the URI as an encoded
6721 * String.
6722 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006723 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006724 return mData != null ? mData.toString() : null;
6725 }
6726
6727 /**
6728 * Return the scheme portion of the intent's data. If the data is null or
6729 * does not include a scheme, null is returned. Otherwise, the scheme
6730 * prefix without the final ':' is returned, i.e. "http".
6731 *
6732 * <p>This is the same as calling getData().getScheme() (and checking for
6733 * null data).
6734 *
6735 * @return The scheme of this intent.
6736 *
6737 * @see #getData
6738 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006739 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006740 return mData != null ? mData.getScheme() : null;
6741 }
6742
6743 /**
6744 * Retrieve any explicit MIME type included in the intent. This is usually
6745 * null, as the type is determined by the intent data.
6746 *
6747 * @return If a type was manually set, it is returned; else null is
6748 * returned.
6749 *
6750 * @see #resolveType(ContentResolver)
6751 * @see #setType
6752 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006753 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006754 return mType;
6755 }
6756
6757 /**
6758 * Return the MIME data type of this intent. If the type field is
6759 * explicitly set, that is simply returned. Otherwise, if the data is set,
6760 * the type of that data is returned. If neither fields are set, a null is
6761 * returned.
6762 *
6763 * @return The MIME type of this intent.
6764 *
6765 * @see #getType
6766 * @see #resolveType(ContentResolver)
6767 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006768 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006769 return resolveType(context.getContentResolver());
6770 }
6771
6772 /**
6773 * Return the MIME data type of this intent. If the type field is
6774 * explicitly set, that is simply returned. Otherwise, if the data is set,
6775 * the type of that data is returned. If neither fields are set, a null is
6776 * returned.
6777 *
6778 * @param resolver A ContentResolver that can be used to determine the MIME
6779 * type of the intent's data.
6780 *
6781 * @return The MIME type of this intent.
6782 *
6783 * @see #getType
6784 * @see #resolveType(Context)
6785 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006786 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006787 if (mType != null) {
6788 return mType;
6789 }
6790 if (mData != null) {
6791 if ("content".equals(mData.getScheme())) {
6792 return resolver.getType(mData);
6793 }
6794 }
6795 return null;
6796 }
6797
6798 /**
6799 * Return the MIME data type of this intent, only if it will be needed for
6800 * intent resolution. This is not generally useful for application code;
6801 * it is used by the frameworks for communicating with back-end system
6802 * services.
6803 *
6804 * @param resolver A ContentResolver that can be used to determine the MIME
6805 * type of the intent's data.
6806 *
6807 * @return The MIME type of this intent, or null if it is unknown or not
6808 * needed.
6809 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006810 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006811 if (mComponent != null) {
6812 return mType;
6813 }
6814 return resolveType(resolver);
6815 }
6816
6817 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006818 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006819 *
6820 * @param category The category to check.
6821 *
6822 * @return boolean True if the intent contains the category, else false.
6823 *
6824 * @see #getCategories
6825 * @see #addCategory
6826 */
6827 public boolean hasCategory(String category) {
6828 return mCategories != null && mCategories.contains(category);
6829 }
6830
6831 /**
6832 * Return the set of all categories in the intent. If there are no categories,
6833 * returns NULL.
6834 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006835 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006836 *
6837 * @see #hasCategory
6838 * @see #addCategory
6839 */
6840 public Set<String> getCategories() {
6841 return mCategories;
6842 }
6843
6844 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006845 * Return the specific selector associated with this Intent. If there is
6846 * none, returns null. See {@link #setSelector} for more information.
6847 *
6848 * @see #setSelector
6849 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006850 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006851 return mSelector;
6852 }
6853
6854 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006855 * Return the {@link ClipData} associated with this Intent. If there is
6856 * none, returns null. See {@link #setClipData} for more information.
6857 *
John Spurlock125d1332013-11-25 11:58:37 -05006858 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006859 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006860 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006861 return mClipData;
6862 }
6863
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006864 /** @hide */
6865 public int getContentUserHint() {
6866 return mContentUserHint;
6867 }
6868
Todd Kennedyb3b431302017-03-20 16:05:48 -07006869 /** @hide */
6870 public String getLaunchToken() {
6871 return mLaunchToken;
6872 }
6873
6874 /** @hide */
6875 public void setLaunchToken(String launchToken) {
6876 mLaunchToken = launchToken;
6877 }
6878
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006879 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006880 * Sets the ClassLoader that will be used when unmarshalling
6881 * any Parcelable values from the extras of this Intent.
6882 *
6883 * @param loader a ClassLoader, or null to use the default loader
6884 * at the time of unmarshalling.
6885 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006886 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006887 if (mExtras != null) {
6888 mExtras.setClassLoader(loader);
6889 }
6890 }
6891
6892 /**
6893 * Returns true if an extra value is associated with the given name.
6894 * @param name the extra's name
6895 * @return true if the given extra is present.
6896 */
6897 public boolean hasExtra(String name) {
6898 return mExtras != null && mExtras.containsKey(name);
6899 }
6900
6901 /**
6902 * Returns true if the Intent's extras contain a parcelled file descriptor.
6903 * @return true if the Intent contains a parcelled file descriptor.
6904 */
6905 public boolean hasFileDescriptors() {
6906 return mExtras != null && mExtras.hasFileDescriptors();
6907 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006908
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006909 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006910 public void setAllowFds(boolean allowFds) {
6911 if (mExtras != null) {
6912 mExtras.setAllowFds(allowFds);
6913 }
6914 }
6915
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006916 /** {@hide} */
6917 public void setDefusable(boolean defusable) {
6918 if (mExtras != null) {
6919 mExtras.setDefusable(defusable);
6920 }
6921 }
6922
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006923 /**
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 none was found.
6930 *
6931 * @deprecated
6932 * @hide
6933 */
6934 @Deprecated
6935 public Object getExtra(String name) {
6936 return getExtra(name, null);
6937 }
6938
6939 /**
6940 * Retrieve extended data from the intent.
6941 *
6942 * @param name The name of the desired item.
6943 * @param defaultValue the value to be returned if no value of the desired
6944 * type is stored with the given name.
6945 *
6946 * @return the value of an item that previously added with putExtra()
6947 * or the default value if none was found.
6948 *
6949 * @see #putExtra(String, boolean)
6950 */
6951 public boolean getBooleanExtra(String name, boolean defaultValue) {
6952 return mExtras == null ? defaultValue :
6953 mExtras.getBoolean(name, defaultValue);
6954 }
6955
6956 /**
6957 * Retrieve extended data from the intent.
6958 *
6959 * @param name The name of the desired item.
6960 * @param defaultValue the value to be returned if no value of the desired
6961 * type is stored with the given name.
6962 *
6963 * @return the value of an item that previously added with putExtra()
6964 * or the default value if none was found.
6965 *
6966 * @see #putExtra(String, byte)
6967 */
6968 public byte getByteExtra(String name, byte defaultValue) {
6969 return mExtras == null ? defaultValue :
6970 mExtras.getByte(name, defaultValue);
6971 }
6972
6973 /**
6974 * Retrieve extended data from the intent.
6975 *
6976 * @param name The name of the desired item.
6977 * @param defaultValue the value to be returned if no value of the desired
6978 * type is stored with the given name.
6979 *
6980 * @return the value of an item that previously added with putExtra()
6981 * or the default value if none was found.
6982 *
6983 * @see #putExtra(String, short)
6984 */
6985 public short getShortExtra(String name, short defaultValue) {
6986 return mExtras == null ? defaultValue :
6987 mExtras.getShort(name, defaultValue);
6988 }
6989
6990 /**
6991 * Retrieve extended data from the intent.
6992 *
6993 * @param name The name of the desired item.
6994 * @param defaultValue the value to be returned if no value of the desired
6995 * type is stored with the given name.
6996 *
6997 * @return the value of an item that previously added with putExtra()
6998 * or the default value if none was found.
6999 *
7000 * @see #putExtra(String, char)
7001 */
7002 public char getCharExtra(String name, char defaultValue) {
7003 return mExtras == null ? defaultValue :
7004 mExtras.getChar(name, defaultValue);
7005 }
7006
7007 /**
7008 * Retrieve extended data from the intent.
7009 *
7010 * @param name The name of the desired item.
7011 * @param defaultValue the value to be returned if no value of the desired
7012 * type is stored with the given name.
7013 *
7014 * @return the value of an item that previously added with putExtra()
7015 * or the default value if none was found.
7016 *
7017 * @see #putExtra(String, int)
7018 */
7019 public int getIntExtra(String name, int defaultValue) {
7020 return mExtras == null ? defaultValue :
7021 mExtras.getInt(name, defaultValue);
7022 }
7023
7024 /**
7025 * Retrieve extended data from the intent.
7026 *
7027 * @param name The name of the desired item.
7028 * @param defaultValue the value to be returned if no value of the desired
7029 * type is stored with the given name.
7030 *
7031 * @return the value of an item that previously added with putExtra()
7032 * or the default value if none was found.
7033 *
7034 * @see #putExtra(String, long)
7035 */
7036 public long getLongExtra(String name, long defaultValue) {
7037 return mExtras == null ? defaultValue :
7038 mExtras.getLong(name, defaultValue);
7039 }
7040
7041 /**
7042 * Retrieve extended data from the intent.
7043 *
7044 * @param name The name of the desired item.
7045 * @param defaultValue the value to be returned if no value of the desired
7046 * type is stored with the given name.
7047 *
7048 * @return the value of an item that previously added with putExtra(),
7049 * or the default value if no such item is present
7050 *
7051 * @see #putExtra(String, float)
7052 */
7053 public float getFloatExtra(String name, float defaultValue) {
7054 return mExtras == null ? defaultValue :
7055 mExtras.getFloat(name, defaultValue);
7056 }
7057
7058 /**
7059 * Retrieve extended data from the intent.
7060 *
7061 * @param name The name of the desired item.
7062 * @param defaultValue the value to be returned if no value of the desired
7063 * type is stored with the given name.
7064 *
7065 * @return the value of an item that previously added with putExtra()
7066 * or the default value if none was found.
7067 *
7068 * @see #putExtra(String, double)
7069 */
7070 public double getDoubleExtra(String name, double defaultValue) {
7071 return mExtras == null ? defaultValue :
7072 mExtras.getDouble(name, defaultValue);
7073 }
7074
7075 /**
7076 * Retrieve extended data from the intent.
7077 *
7078 * @param name The name of the desired item.
7079 *
7080 * @return the value of an item that previously added with putExtra()
7081 * or null if no String value was found.
7082 *
7083 * @see #putExtra(String, String)
7084 */
7085 public String getStringExtra(String name) {
7086 return mExtras == null ? null : mExtras.getString(name);
7087 }
7088
7089 /**
7090 * Retrieve extended data from the intent.
7091 *
7092 * @param name The name of the desired item.
7093 *
7094 * @return the value of an item that previously added with putExtra()
7095 * or null if no CharSequence value was found.
7096 *
7097 * @see #putExtra(String, CharSequence)
7098 */
7099 public CharSequence getCharSequenceExtra(String name) {
7100 return mExtras == null ? null : mExtras.getCharSequence(name);
7101 }
7102
7103 /**
7104 * Retrieve extended data from the intent.
7105 *
7106 * @param name The name of the desired item.
7107 *
7108 * @return the value of an item that previously added with putExtra()
7109 * or null if no Parcelable value was found.
7110 *
7111 * @see #putExtra(String, Parcelable)
7112 */
7113 public <T extends Parcelable> T getParcelableExtra(String name) {
7114 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7115 }
7116
7117 /**
7118 * Retrieve extended data from the intent.
7119 *
7120 * @param name The name of the desired item.
7121 *
7122 * @return the value of an item that previously added with putExtra()
7123 * or null if no Parcelable[] value was found.
7124 *
7125 * @see #putExtra(String, Parcelable[])
7126 */
7127 public Parcelable[] getParcelableArrayExtra(String name) {
7128 return mExtras == null ? null : mExtras.getParcelableArray(name);
7129 }
7130
7131 /**
7132 * Retrieve extended data from the intent.
7133 *
7134 * @param name The name of the desired item.
7135 *
7136 * @return the value of an item that previously added with putExtra()
7137 * or null if no ArrayList<Parcelable> value was found.
7138 *
7139 * @see #putParcelableArrayListExtra(String, ArrayList)
7140 */
7141 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7142 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7143 }
7144
7145 /**
7146 * Retrieve extended data from the intent.
7147 *
7148 * @param name The name of the desired item.
7149 *
7150 * @return the value of an item that previously added with putExtra()
7151 * or null if no Serializable value was found.
7152 *
7153 * @see #putExtra(String, Serializable)
7154 */
7155 public Serializable getSerializableExtra(String name) {
7156 return mExtras == null ? null : mExtras.getSerializable(name);
7157 }
7158
7159 /**
7160 * Retrieve extended data from the intent.
7161 *
7162 * @param name The name of the desired item.
7163 *
7164 * @return the value of an item that previously added with putExtra()
7165 * or null if no ArrayList<Integer> value was found.
7166 *
7167 * @see #putIntegerArrayListExtra(String, ArrayList)
7168 */
7169 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7170 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7171 }
7172
7173 /**
7174 * Retrieve extended data from the intent.
7175 *
7176 * @param name The name of the desired item.
7177 *
7178 * @return the value of an item that previously added with putExtra()
7179 * or null if no ArrayList<String> value was found.
7180 *
7181 * @see #putStringArrayListExtra(String, ArrayList)
7182 */
7183 public ArrayList<String> getStringArrayListExtra(String name) {
7184 return mExtras == null ? null : mExtras.getStringArrayList(name);
7185 }
7186
7187 /**
7188 * Retrieve extended data from the intent.
7189 *
7190 * @param name The name of the desired item.
7191 *
7192 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007193 * or null if no ArrayList<CharSequence> value was found.
7194 *
7195 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7196 */
7197 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7198 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7199 }
7200
7201 /**
7202 * Retrieve extended data from the intent.
7203 *
7204 * @param name The name of the desired item.
7205 *
7206 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007207 * or null if no boolean array value was found.
7208 *
7209 * @see #putExtra(String, boolean[])
7210 */
7211 public boolean[] getBooleanArrayExtra(String name) {
7212 return mExtras == null ? null : mExtras.getBooleanArray(name);
7213 }
7214
7215 /**
7216 * Retrieve extended data from the intent.
7217 *
7218 * @param name The name of the desired item.
7219 *
7220 * @return the value of an item that previously added with putExtra()
7221 * or null if no byte array value was found.
7222 *
7223 * @see #putExtra(String, byte[])
7224 */
7225 public byte[] getByteArrayExtra(String name) {
7226 return mExtras == null ? null : mExtras.getByteArray(name);
7227 }
7228
7229 /**
7230 * Retrieve extended data from the intent.
7231 *
7232 * @param name The name of the desired item.
7233 *
7234 * @return the value of an item that previously added with putExtra()
7235 * or null if no short array value was found.
7236 *
7237 * @see #putExtra(String, short[])
7238 */
7239 public short[] getShortArrayExtra(String name) {
7240 return mExtras == null ? null : mExtras.getShortArray(name);
7241 }
7242
7243 /**
7244 * Retrieve extended data from the intent.
7245 *
7246 * @param name The name of the desired item.
7247 *
7248 * @return the value of an item that previously added with putExtra()
7249 * or null if no char array value was found.
7250 *
7251 * @see #putExtra(String, char[])
7252 */
7253 public char[] getCharArrayExtra(String name) {
7254 return mExtras == null ? null : mExtras.getCharArray(name);
7255 }
7256
7257 /**
7258 * Retrieve extended data from the intent.
7259 *
7260 * @param name The name of the desired item.
7261 *
7262 * @return the value of an item that previously added with putExtra()
7263 * or null if no int array value was found.
7264 *
7265 * @see #putExtra(String, int[])
7266 */
7267 public int[] getIntArrayExtra(String name) {
7268 return mExtras == null ? null : mExtras.getIntArray(name);
7269 }
7270
7271 /**
7272 * Retrieve extended data from the intent.
7273 *
7274 * @param name The name of the desired item.
7275 *
7276 * @return the value of an item that previously added with putExtra()
7277 * or null if no long array value was found.
7278 *
7279 * @see #putExtra(String, long[])
7280 */
7281 public long[] getLongArrayExtra(String name) {
7282 return mExtras == null ? null : mExtras.getLongArray(name);
7283 }
7284
7285 /**
7286 * Retrieve extended data from the intent.
7287 *
7288 * @param name The name of the desired item.
7289 *
7290 * @return the value of an item that previously added with putExtra()
7291 * or null if no float array value was found.
7292 *
7293 * @see #putExtra(String, float[])
7294 */
7295 public float[] getFloatArrayExtra(String name) {
7296 return mExtras == null ? null : mExtras.getFloatArray(name);
7297 }
7298
7299 /**
7300 * Retrieve extended data from the intent.
7301 *
7302 * @param name The name of the desired item.
7303 *
7304 * @return the value of an item that previously added with putExtra()
7305 * or null if no double array value was found.
7306 *
7307 * @see #putExtra(String, double[])
7308 */
7309 public double[] getDoubleArrayExtra(String name) {
7310 return mExtras == null ? null : mExtras.getDoubleArray(name);
7311 }
7312
7313 /**
7314 * Retrieve extended data from the intent.
7315 *
7316 * @param name The name of the desired item.
7317 *
7318 * @return the value of an item that previously added with putExtra()
7319 * or null if no String array value was found.
7320 *
7321 * @see #putExtra(String, String[])
7322 */
7323 public String[] getStringArrayExtra(String name) {
7324 return mExtras == null ? null : mExtras.getStringArray(name);
7325 }
7326
7327 /**
7328 * Retrieve extended data from the intent.
7329 *
7330 * @param name The name of the desired item.
7331 *
7332 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007333 * or null if no CharSequence array value was found.
7334 *
7335 * @see #putExtra(String, CharSequence[])
7336 */
7337 public CharSequence[] getCharSequenceArrayExtra(String name) {
7338 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7339 }
7340
7341 /**
7342 * Retrieve extended data from the intent.
7343 *
7344 * @param name The name of the desired item.
7345 *
7346 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007347 * or null if no Bundle value was found.
7348 *
7349 * @see #putExtra(String, Bundle)
7350 */
7351 public Bundle getBundleExtra(String name) {
7352 return mExtras == null ? null : mExtras.getBundle(name);
7353 }
7354
7355 /**
7356 * Retrieve extended data from the intent.
7357 *
7358 * @param name The name of the desired item.
7359 *
7360 * @return the value of an item that previously added with putExtra()
7361 * or null if no IBinder value was found.
7362 *
7363 * @see #putExtra(String, IBinder)
7364 *
7365 * @deprecated
7366 * @hide
7367 */
7368 @Deprecated
7369 public IBinder getIBinderExtra(String name) {
7370 return mExtras == null ? null : mExtras.getIBinder(name);
7371 }
7372
7373 /**
7374 * Retrieve extended data from the intent.
7375 *
7376 * @param name The name of the desired item.
7377 * @param defaultValue The default value to return in case no item is
7378 * associated with the key 'name'
7379 *
7380 * @return the value of an item that previously added with putExtra()
7381 * or defaultValue if none was found.
7382 *
7383 * @see #putExtra
7384 *
7385 * @deprecated
7386 * @hide
7387 */
7388 @Deprecated
7389 public Object getExtra(String name, Object defaultValue) {
7390 Object result = defaultValue;
7391 if (mExtras != null) {
7392 Object result2 = mExtras.get(name);
7393 if (result2 != null) {
7394 result = result2;
7395 }
7396 }
7397
7398 return result;
7399 }
7400
7401 /**
7402 * Retrieves a map of extended data from the intent.
7403 *
7404 * @return the map of all extras previously added with putExtra(),
7405 * or null if none have been added.
7406 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007407 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007408 return (mExtras != null)
7409 ? new Bundle(mExtras)
7410 : null;
7411 }
7412
7413 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007414 * Filter extras to only basic types.
7415 * @hide
7416 */
7417 public void removeUnsafeExtras() {
7418 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007419 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007420 }
7421 }
7422
7423 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007424 * Retrieve any special flags associated with this intent. You will
7425 * normally just set them with {@link #setFlags} and let the system
7426 * take the appropriate action with them.
7427 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007428 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007429 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007430 * @see #addFlags
7431 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007432 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007433 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007434 return mFlags;
7435 }
7436
Dianne Hackborne7f97212011-02-24 14:40:20 -08007437 /** @hide */
7438 public boolean isExcludingStopped() {
7439 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7440 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7441 }
7442
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007443 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007444 * Retrieve the application package name this Intent is limited to. When
7445 * resolving an Intent, if non-null this limits the resolution to only
7446 * components in the given application package.
7447 *
7448 * @return The name of the application package for the Intent.
7449 *
7450 * @see #resolveActivity
7451 * @see #setPackage
7452 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007453 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007454 return mPackage;
7455 }
7456
7457 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007458 * Retrieve the concrete component associated with the intent. When receiving
7459 * an intent, this is the component that was found to best handle it (that is,
7460 * yourself) and will always be non-null; in all other cases it will be
7461 * null unless explicitly set.
7462 *
7463 * @return The name of the application component to handle the intent.
7464 *
7465 * @see #resolveActivity
7466 * @see #setComponent
7467 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007468 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007469 return mComponent;
7470 }
7471
7472 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007473 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7474 * used as a hint to the receiver for animations and the like. Null means that there
7475 * is no source bounds.
7476 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007477 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007478 return mSourceBounds;
7479 }
7480
7481 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007482 * Return the Activity component that should be used to handle this intent.
7483 * The appropriate component is determined based on the information in the
7484 * intent, evaluated as follows:
7485 *
7486 * <p>If {@link #getComponent} returns an explicit class, that is returned
7487 * without any further consideration.
7488 *
7489 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7490 * category to be considered.
7491 *
7492 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7493 * action.
7494 *
7495 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7496 * this type.
7497 *
7498 * <p>If {@link #addCategory} has added any categories, the activity must
7499 * handle ALL of the categories specified.
7500 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007501 * <p>If {@link #getPackage} is non-NULL, only activity components in
7502 * that application package will be considered.
7503 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007504 * <p>If there are no activities that satisfy all of these conditions, a
7505 * null string is returned.
7506 *
7507 * <p>If multiple activities are found to satisfy the intent, the one with
7508 * the highest priority will be used. If there are multiple activities
7509 * with the same priority, the system will either pick the best activity
7510 * based on user preference, or resolve to a system class that will allow
7511 * the user to pick an activity and forward from there.
7512 *
7513 * <p>This method is implemented simply by calling
7514 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7515 * true.</p>
7516 * <p> This API is called for you as part of starting an activity from an
7517 * intent. You do not normally need to call it yourself.</p>
7518 *
7519 * @param pm The package manager with which to resolve the Intent.
7520 *
7521 * @return Name of the component implementing an activity that can
7522 * display the intent.
7523 *
7524 * @see #setComponent
7525 * @see #getComponent
7526 * @see #resolveActivityInfo
7527 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007528 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007529 if (mComponent != null) {
7530 return mComponent;
7531 }
7532
7533 ResolveInfo info = pm.resolveActivity(
7534 this, PackageManager.MATCH_DEFAULT_ONLY);
7535 if (info != null) {
7536 return new ComponentName(
7537 info.activityInfo.applicationInfo.packageName,
7538 info.activityInfo.name);
7539 }
7540
7541 return null;
7542 }
7543
7544 /**
7545 * Resolve the Intent into an {@link ActivityInfo}
7546 * describing the activity that should execute the intent. Resolution
7547 * follows the same rules as described for {@link #resolveActivity}, but
7548 * you get back the completely information about the resolved activity
7549 * instead of just its class name.
7550 *
7551 * @param pm The package manager with which to resolve the Intent.
7552 * @param flags Addition information to retrieve as per
7553 * {@link PackageManager#getActivityInfo(ComponentName, int)
7554 * PackageManager.getActivityInfo()}.
7555 *
7556 * @return PackageManager.ActivityInfo
7557 *
7558 * @see #resolveActivity
7559 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007560 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7561 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007562 ActivityInfo ai = null;
7563 if (mComponent != null) {
7564 try {
7565 ai = pm.getActivityInfo(mComponent, flags);
7566 } catch (PackageManager.NameNotFoundException e) {
7567 // ignore
7568 }
7569 } else {
7570 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007571 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007572 if (info != null) {
7573 ai = info.activityInfo;
7574 }
7575 }
7576
7577 return ai;
7578 }
7579
7580 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007581 * Special function for use by the system to resolve service
7582 * intents to system apps. Throws an exception if there are
7583 * multiple potential matches to the Intent. Returns null if
7584 * there are no matches.
7585 * @hide
7586 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007587 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7588 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007589 if (mComponent != null) {
7590 return mComponent;
7591 }
7592
7593 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7594 if (results == null) {
7595 return null;
7596 }
7597 ComponentName comp = null;
7598 for (int i=0; i<results.size(); i++) {
7599 ResolveInfo ri = results.get(i);
7600 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7601 continue;
7602 }
7603 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7604 ri.serviceInfo.name);
7605 if (comp != null) {
7606 throw new IllegalStateException("Multiple system services handle " + this
7607 + ": " + comp + ", " + foundComp);
7608 }
7609 comp = foundComp;
7610 }
7611 return comp;
7612 }
7613
7614 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007615 * Set the general action to be performed.
7616 *
7617 * @param action An action name, such as ACTION_VIEW. Application-specific
7618 * actions should be prefixed with the vendor's package name.
7619 *
7620 * @return Returns the same Intent object, for chaining multiple calls
7621 * into a single statement.
7622 *
7623 * @see #getAction
7624 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007625 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007626 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007627 return this;
7628 }
7629
7630 /**
7631 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007632 * clears any type that was previously set by {@link #setType} or
7633 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007634 *
Nick Pellyccae4122012-01-09 14:12:58 -08007635 * <p><em>Note: scheme matching in the Android framework is
7636 * case-sensitive, unlike the formal RFC. As a result,
7637 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007638 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007639 * {@link #setDataAndNormalize}
7640 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007641 *
Nick Pellyccae4122012-01-09 14:12:58 -08007642 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007643 *
7644 * @return Returns the same Intent object, for chaining multiple calls
7645 * into a single statement.
7646 *
7647 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007648 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007649 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007650 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007651 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007652 mData = data;
7653 mType = null;
7654 return this;
7655 }
7656
7657 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007658 * Normalize and set the data this intent is operating on.
7659 *
7660 * <p>This method automatically clears any type that was
7661 * previously set (for example, by {@link #setType}).
7662 *
7663 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007664 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007665 * so really this is just a convenience method for
7666 * <pre>
7667 * setData(data.normalize())
7668 * </pre>
7669 *
7670 * @param data The Uri of the data this intent is now targeting.
7671 *
7672 * @return Returns the same Intent object, for chaining multiple calls
7673 * into a single statement.
7674 *
7675 * @see #getData
7676 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007677 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007678 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007679 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007680 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007681 }
7682
7683 /**
7684 * Set an explicit MIME data type.
7685 *
7686 * <p>This is used to create intents that only specify a type and not data,
7687 * for example to indicate the type of data to return.
7688 *
7689 * <p>This method automatically clears any data that was
7690 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007691 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007692 * <p><em>Note: MIME type matching in the Android framework is
7693 * case-sensitive, unlike formal RFC MIME types. As a result,
7694 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007695 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7696 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007697 *
7698 * @param type The MIME type of the data being handled by this intent.
7699 *
7700 * @return Returns the same Intent object, for chaining multiple calls
7701 * into a single statement.
7702 *
7703 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007704 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007705 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007706 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007707 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007708 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007709 mData = null;
7710 mType = type;
7711 return this;
7712 }
7713
7714 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007715 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007716 *
Nick Pellyccae4122012-01-09 14:12:58 -08007717 * <p>This is used to create intents that only specify a type and not data,
7718 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007719 *
Nick Pellyccae4122012-01-09 14:12:58 -08007720 * <p>This method automatically clears any data that was
7721 * previously set (for example by {@link #setData}).
7722 *
7723 * <p>The MIME type is normalized using
7724 * {@link #normalizeMimeType} before it is set,
7725 * so really this is just a convenience method for
7726 * <pre>
7727 * setType(Intent.normalizeMimeType(type))
7728 * </pre>
7729 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007730 * @param type The MIME type of the data being handled by this intent.
7731 *
7732 * @return Returns the same Intent object, for chaining multiple calls
7733 * into a single statement.
7734 *
Nick Pellyccae4122012-01-09 14:12:58 -08007735 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007736 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007737 * @see #normalizeMimeType
7738 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007739 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007740 return setType(normalizeMimeType(type));
7741 }
7742
7743 /**
7744 * (Usually optional) Set the data for the intent along with an explicit
7745 * MIME data type. This method should very rarely be used -- it allows you
7746 * to override the MIME type that would ordinarily be inferred from the
7747 * data with your own type given here.
7748 *
7749 * <p><em>Note: MIME type and Uri scheme matching in the
7750 * Android framework is case-sensitive, unlike the formal RFC definitions.
7751 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007752 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007753 * {@link #setDataAndTypeAndNormalize}
7754 * to ensure that they are converted to lower case.</em>
7755 *
7756 * @param data The Uri of the data this intent is now targeting.
7757 * @param type The MIME type of the data being handled by this intent.
7758 *
7759 * @return Returns the same Intent object, for chaining multiple calls
7760 * into a single statement.
7761 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007762 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007763 * @see #setData
7764 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007765 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007766 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007767 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007768 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007769 mData = data;
7770 mType = type;
7771 return this;
7772 }
7773
7774 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007775 * (Usually optional) Normalize and set both the data Uri and an explicit
7776 * MIME data type. This method should very rarely be used -- it allows you
7777 * to override the MIME type that would ordinarily be inferred from the
7778 * data with your own type given here.
7779 *
7780 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007781 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007782 * before they are set, so really this is just a convenience method for
7783 * <pre>
7784 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7785 * </pre>
7786 *
7787 * @param data The Uri of the data this intent is now targeting.
7788 * @param type The MIME type of the data being handled by this intent.
7789 *
7790 * @return Returns the same Intent object, for chaining multiple calls
7791 * into a single statement.
7792 *
7793 * @see #setType
7794 * @see #setData
7795 * @see #setDataAndType
7796 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007797 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007798 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007799 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007800 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007801 }
7802
7803 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007804 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007805 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007806 * activities that provide <em>all</em> of the requested categories will be
7807 * used.
7808 *
7809 * @param category The desired category. This can be either one of the
7810 * predefined Intent categories, or a custom category in your own
7811 * namespace.
7812 *
7813 * @return Returns the same Intent object, for chaining multiple calls
7814 * into a single statement.
7815 *
7816 * @see #hasCategory
7817 * @see #removeCategory
7818 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007819 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007820 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007821 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007822 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007823 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007824 return this;
7825 }
7826
7827 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007828 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007829 *
7830 * @param category The category to remove.
7831 *
7832 * @see #addCategory
7833 */
7834 public void removeCategory(String category) {
7835 if (mCategories != null) {
7836 mCategories.remove(category);
7837 if (mCategories.size() == 0) {
7838 mCategories = null;
7839 }
7840 }
7841 }
7842
7843 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007844 * Set a selector for this Intent. This is a modification to the kinds of
7845 * things the Intent will match. If the selector is set, it will be used
7846 * when trying to find entities that can handle the Intent, instead of the
7847 * main contents of the Intent. This allows you build an Intent containing
7848 * a generic protocol while targeting it more specifically.
7849 *
7850 * <p>An example of where this may be used is with things like
7851 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7852 * Intent that will launch the Browser application. However, the correct
7853 * main entry point of an application is actually {@link #ACTION_MAIN}
7854 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7855 * used to specify the actual Activity to launch. If you launch the browser
7856 * with something different, undesired behavior may happen if the user has
7857 * previously or later launches it the normal way, since they do not match.
7858 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7859 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7860 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7861 *
7862 * <p>Setting a selector does not impact the behavior of
7863 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7864 * desired behavior of a selector -- it does not impact the base meaning
7865 * of the Intent, just what kinds of things will be matched against it
7866 * when determining who can handle it.</p>
7867 *
7868 * <p>You can not use both a selector and {@link #setPackage(String)} on
7869 * the same base Intent.</p>
7870 *
7871 * @param selector The desired selector Intent; set to null to not use
7872 * a special selector.
7873 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007874 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007875 if (selector == this) {
7876 throw new IllegalArgumentException(
7877 "Intent being set as a selector of itself");
7878 }
7879 if (selector != null && mPackage != null) {
7880 throw new IllegalArgumentException(
7881 "Can't set selector when package name is already set");
7882 }
7883 mSelector = selector;
7884 }
7885
7886 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007887 * Set a {@link ClipData} associated with this Intent. This replaces any
7888 * previously set ClipData.
7889 *
7890 * <p>The ClipData in an intent is not used for Intent matching or other
7891 * such operations. Semantically it is like extras, used to transmit
7892 * additional data with the Intent. The main feature of using this over
7893 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7894 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7895 * items included in the clip data. This is useful, in particular, if
7896 * you want to transmit an Intent containing multiple <code>content:</code>
7897 * URIs for which the recipient may not have global permission to access the
7898 * content provider.
7899 *
7900 * <p>If the ClipData contains items that are themselves Intents, any
7901 * grant flags in those Intents will be ignored. Only the top-level flags
7902 * of the main Intent are respected, and will be applied to all Uri or
7903 * Intent items in the clip (or sub-items of the clip).
7904 *
7905 * <p>The MIME type, label, and icon in the ClipData object are not
7906 * directly used by Intent. Applications should generally rely on the
7907 * MIME type of the Intent itself, not what it may find in the ClipData.
7908 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007909 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007910 *
7911 * @param clip The new clip to set. May be null to clear the current clip.
7912 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007913 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007914 mClipData = clip;
7915 }
7916
7917 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007918 * This is NOT a secure mechanism to identify the user who sent the intent.
7919 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7920 * who sent the intent.
7921 * @hide
7922 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007923 public void prepareToLeaveUser(int userId) {
7924 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7925 // We want mContentUserHint to refer to the original user, so don't do anything.
7926 if (mContentUserHint == UserHandle.USER_CURRENT) {
7927 mContentUserHint = userId;
7928 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007929 }
7930
7931 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007932 * Add extended data to the intent. The name must include a package
7933 * prefix, for example the app com.android.contacts would use names
7934 * like "com.android.contacts.ShowAll".
7935 *
7936 * @param name The name of the extra data, with package prefix.
7937 * @param value The boolean data value.
7938 *
7939 * @return Returns the same Intent object, for chaining multiple calls
7940 * into a single statement.
7941 *
7942 * @see #putExtras
7943 * @see #removeExtra
7944 * @see #getBooleanExtra(String, boolean)
7945 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007946 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007947 if (mExtras == null) {
7948 mExtras = new Bundle();
7949 }
7950 mExtras.putBoolean(name, value);
7951 return this;
7952 }
7953
7954 /**
7955 * Add extended data to the intent. The name must include a package
7956 * prefix, for example the app com.android.contacts would use names
7957 * like "com.android.contacts.ShowAll".
7958 *
7959 * @param name The name of the extra data, with package prefix.
7960 * @param value The byte data value.
7961 *
7962 * @return Returns the same Intent object, for chaining multiple calls
7963 * into a single statement.
7964 *
7965 * @see #putExtras
7966 * @see #removeExtra
7967 * @see #getByteExtra(String, byte)
7968 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007969 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007970 if (mExtras == null) {
7971 mExtras = new Bundle();
7972 }
7973 mExtras.putByte(name, value);
7974 return this;
7975 }
7976
7977 /**
7978 * Add extended data to the intent. The name must include a package
7979 * prefix, for example the app com.android.contacts would use names
7980 * like "com.android.contacts.ShowAll".
7981 *
7982 * @param name The name of the extra data, with package prefix.
7983 * @param value The char data value.
7984 *
7985 * @return Returns the same Intent object, for chaining multiple calls
7986 * into a single statement.
7987 *
7988 * @see #putExtras
7989 * @see #removeExtra
7990 * @see #getCharExtra(String, char)
7991 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007992 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007993 if (mExtras == null) {
7994 mExtras = new Bundle();
7995 }
7996 mExtras.putChar(name, value);
7997 return this;
7998 }
7999
8000 /**
8001 * Add extended data to the intent. The name must include a package
8002 * prefix, for example the app com.android.contacts would use names
8003 * like "com.android.contacts.ShowAll".
8004 *
8005 * @param name The name of the extra data, with package prefix.
8006 * @param value The short data value.
8007 *
8008 * @return Returns the same Intent object, for chaining multiple calls
8009 * into a single statement.
8010 *
8011 * @see #putExtras
8012 * @see #removeExtra
8013 * @see #getShortExtra(String, short)
8014 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008015 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008016 if (mExtras == null) {
8017 mExtras = new Bundle();
8018 }
8019 mExtras.putShort(name, value);
8020 return this;
8021 }
8022
8023 /**
8024 * Add extended data to the intent. The name must include a package
8025 * prefix, for example the app com.android.contacts would use names
8026 * like "com.android.contacts.ShowAll".
8027 *
8028 * @param name The name of the extra data, with package prefix.
8029 * @param value The integer data value.
8030 *
8031 * @return Returns the same Intent object, for chaining multiple calls
8032 * into a single statement.
8033 *
8034 * @see #putExtras
8035 * @see #removeExtra
8036 * @see #getIntExtra(String, int)
8037 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008038 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008039 if (mExtras == null) {
8040 mExtras = new Bundle();
8041 }
8042 mExtras.putInt(name, value);
8043 return this;
8044 }
8045
8046 /**
8047 * Add extended data to the intent. The name must include a package
8048 * prefix, for example the app com.android.contacts would use names
8049 * like "com.android.contacts.ShowAll".
8050 *
8051 * @param name The name of the extra data, with package prefix.
8052 * @param value The long data value.
8053 *
8054 * @return Returns the same Intent object, for chaining multiple calls
8055 * into a single statement.
8056 *
8057 * @see #putExtras
8058 * @see #removeExtra
8059 * @see #getLongExtra(String, long)
8060 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008061 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008062 if (mExtras == null) {
8063 mExtras = new Bundle();
8064 }
8065 mExtras.putLong(name, value);
8066 return this;
8067 }
8068
8069 /**
8070 * Add extended data to the intent. The name must include a package
8071 * prefix, for example the app com.android.contacts would use names
8072 * like "com.android.contacts.ShowAll".
8073 *
8074 * @param name The name of the extra data, with package prefix.
8075 * @param value The float data value.
8076 *
8077 * @return Returns the same Intent object, for chaining multiple calls
8078 * into a single statement.
8079 *
8080 * @see #putExtras
8081 * @see #removeExtra
8082 * @see #getFloatExtra(String, float)
8083 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008084 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008085 if (mExtras == null) {
8086 mExtras = new Bundle();
8087 }
8088 mExtras.putFloat(name, value);
8089 return this;
8090 }
8091
8092 /**
8093 * Add extended data to the intent. The name must include a package
8094 * prefix, for example the app com.android.contacts would use names
8095 * like "com.android.contacts.ShowAll".
8096 *
8097 * @param name The name of the extra data, with package prefix.
8098 * @param value The double data value.
8099 *
8100 * @return Returns the same Intent object, for chaining multiple calls
8101 * into a single statement.
8102 *
8103 * @see #putExtras
8104 * @see #removeExtra
8105 * @see #getDoubleExtra(String, double)
8106 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008107 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008108 if (mExtras == null) {
8109 mExtras = new Bundle();
8110 }
8111 mExtras.putDouble(name, value);
8112 return this;
8113 }
8114
8115 /**
8116 * Add extended data to the intent. The name must include a package
8117 * prefix, for example the app com.android.contacts would use names
8118 * like "com.android.contacts.ShowAll".
8119 *
8120 * @param name The name of the extra data, with package prefix.
8121 * @param value The String data value.
8122 *
8123 * @return Returns the same Intent object, for chaining multiple calls
8124 * into a single statement.
8125 *
8126 * @see #putExtras
8127 * @see #removeExtra
8128 * @see #getStringExtra(String)
8129 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008130 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008131 if (mExtras == null) {
8132 mExtras = new Bundle();
8133 }
8134 mExtras.putString(name, value);
8135 return this;
8136 }
8137
8138 /**
8139 * Add extended data to the intent. The name must include a package
8140 * prefix, for example the app com.android.contacts would use names
8141 * like "com.android.contacts.ShowAll".
8142 *
8143 * @param name The name of the extra data, with package prefix.
8144 * @param value The CharSequence data value.
8145 *
8146 * @return Returns the same Intent object, for chaining multiple calls
8147 * into a single statement.
8148 *
8149 * @see #putExtras
8150 * @see #removeExtra
8151 * @see #getCharSequenceExtra(String)
8152 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008153 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008154 if (mExtras == null) {
8155 mExtras = new Bundle();
8156 }
8157 mExtras.putCharSequence(name, value);
8158 return this;
8159 }
8160
8161 /**
8162 * Add extended data to the intent. The name must include a package
8163 * prefix, for example the app com.android.contacts would use names
8164 * like "com.android.contacts.ShowAll".
8165 *
8166 * @param name The name of the extra data, with package prefix.
8167 * @param value The Parcelable data value.
8168 *
8169 * @return Returns the same Intent object, for chaining multiple calls
8170 * into a single statement.
8171 *
8172 * @see #putExtras
8173 * @see #removeExtra
8174 * @see #getParcelableExtra(String)
8175 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008176 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008177 if (mExtras == null) {
8178 mExtras = new Bundle();
8179 }
8180 mExtras.putParcelable(name, value);
8181 return this;
8182 }
8183
8184 /**
8185 * Add extended data to the intent. The name must include a package
8186 * prefix, for example the app com.android.contacts would use names
8187 * like "com.android.contacts.ShowAll".
8188 *
8189 * @param name The name of the extra data, with package prefix.
8190 * @param value The Parcelable[] data value.
8191 *
8192 * @return Returns the same Intent object, for chaining multiple calls
8193 * into a single statement.
8194 *
8195 * @see #putExtras
8196 * @see #removeExtra
8197 * @see #getParcelableArrayExtra(String)
8198 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008199 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008200 if (mExtras == null) {
8201 mExtras = new Bundle();
8202 }
8203 mExtras.putParcelableArray(name, value);
8204 return this;
8205 }
8206
8207 /**
8208 * Add extended data to the intent. The name must include a package
8209 * prefix, for example the app com.android.contacts would use names
8210 * like "com.android.contacts.ShowAll".
8211 *
8212 * @param name The name of the extra data, with package prefix.
8213 * @param value The ArrayList<Parcelable> data value.
8214 *
8215 * @return Returns the same Intent object, for chaining multiple calls
8216 * into a single statement.
8217 *
8218 * @see #putExtras
8219 * @see #removeExtra
8220 * @see #getParcelableArrayListExtra(String)
8221 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008222 public @NonNull Intent putParcelableArrayListExtra(String name,
8223 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008224 if (mExtras == null) {
8225 mExtras = new Bundle();
8226 }
8227 mExtras.putParcelableArrayList(name, value);
8228 return this;
8229 }
8230
8231 /**
8232 * Add extended data to the intent. The name must include a package
8233 * prefix, for example the app com.android.contacts would use names
8234 * like "com.android.contacts.ShowAll".
8235 *
8236 * @param name The name of the extra data, with package prefix.
8237 * @param value The ArrayList<Integer> data value.
8238 *
8239 * @return Returns the same Intent object, for chaining multiple calls
8240 * into a single statement.
8241 *
8242 * @see #putExtras
8243 * @see #removeExtra
8244 * @see #getIntegerArrayListExtra(String)
8245 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008246 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008247 if (mExtras == null) {
8248 mExtras = new Bundle();
8249 }
8250 mExtras.putIntegerArrayList(name, value);
8251 return this;
8252 }
8253
8254 /**
8255 * Add extended data to the intent. The name must include a package
8256 * prefix, for example the app com.android.contacts would use names
8257 * like "com.android.contacts.ShowAll".
8258 *
8259 * @param name The name of the extra data, with package prefix.
8260 * @param value The ArrayList<String> data value.
8261 *
8262 * @return Returns the same Intent object, for chaining multiple calls
8263 * into a single statement.
8264 *
8265 * @see #putExtras
8266 * @see #removeExtra
8267 * @see #getStringArrayListExtra(String)
8268 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008269 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008270 if (mExtras == null) {
8271 mExtras = new Bundle();
8272 }
8273 mExtras.putStringArrayList(name, value);
8274 return this;
8275 }
8276
8277 /**
8278 * Add extended data to the intent. The name must include a package
8279 * prefix, for example the app com.android.contacts would use names
8280 * like "com.android.contacts.ShowAll".
8281 *
8282 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008283 * @param value The ArrayList<CharSequence> data value.
8284 *
8285 * @return Returns the same Intent object, for chaining multiple calls
8286 * into a single statement.
8287 *
8288 * @see #putExtras
8289 * @see #removeExtra
8290 * @see #getCharSequenceArrayListExtra(String)
8291 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008292 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8293 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008294 if (mExtras == null) {
8295 mExtras = new Bundle();
8296 }
8297 mExtras.putCharSequenceArrayList(name, value);
8298 return this;
8299 }
8300
8301 /**
8302 * Add extended data to the intent. The name must include a package
8303 * prefix, for example the app com.android.contacts would use names
8304 * like "com.android.contacts.ShowAll".
8305 *
8306 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008307 * @param value The Serializable data value.
8308 *
8309 * @return Returns the same Intent object, for chaining multiple calls
8310 * into a single statement.
8311 *
8312 * @see #putExtras
8313 * @see #removeExtra
8314 * @see #getSerializableExtra(String)
8315 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008316 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008317 if (mExtras == null) {
8318 mExtras = new Bundle();
8319 }
8320 mExtras.putSerializable(name, value);
8321 return this;
8322 }
8323
8324 /**
8325 * Add extended data to the intent. The name must include a package
8326 * prefix, for example the app com.android.contacts would use names
8327 * like "com.android.contacts.ShowAll".
8328 *
8329 * @param name The name of the extra data, with package prefix.
8330 * @param value The boolean array data value.
8331 *
8332 * @return Returns the same Intent object, for chaining multiple calls
8333 * into a single statement.
8334 *
8335 * @see #putExtras
8336 * @see #removeExtra
8337 * @see #getBooleanArrayExtra(String)
8338 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008339 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008340 if (mExtras == null) {
8341 mExtras = new Bundle();
8342 }
8343 mExtras.putBooleanArray(name, value);
8344 return this;
8345 }
8346
8347 /**
8348 * Add extended data to the intent. The name must include a package
8349 * prefix, for example the app com.android.contacts would use names
8350 * like "com.android.contacts.ShowAll".
8351 *
8352 * @param name The name of the extra data, with package prefix.
8353 * @param value The byte array data value.
8354 *
8355 * @return Returns the same Intent object, for chaining multiple calls
8356 * into a single statement.
8357 *
8358 * @see #putExtras
8359 * @see #removeExtra
8360 * @see #getByteArrayExtra(String)
8361 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008362 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008363 if (mExtras == null) {
8364 mExtras = new Bundle();
8365 }
8366 mExtras.putByteArray(name, value);
8367 return this;
8368 }
8369
8370 /**
8371 * Add extended data to the intent. The name must include a package
8372 * prefix, for example the app com.android.contacts would use names
8373 * like "com.android.contacts.ShowAll".
8374 *
8375 * @param name The name of the extra data, with package prefix.
8376 * @param value The short array data value.
8377 *
8378 * @return Returns the same Intent object, for chaining multiple calls
8379 * into a single statement.
8380 *
8381 * @see #putExtras
8382 * @see #removeExtra
8383 * @see #getShortArrayExtra(String)
8384 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008385 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008386 if (mExtras == null) {
8387 mExtras = new Bundle();
8388 }
8389 mExtras.putShortArray(name, value);
8390 return this;
8391 }
8392
8393 /**
8394 * Add extended data to the intent. The name must include a package
8395 * prefix, for example the app com.android.contacts would use names
8396 * like "com.android.contacts.ShowAll".
8397 *
8398 * @param name The name of the extra data, with package prefix.
8399 * @param value The char array data value.
8400 *
8401 * @return Returns the same Intent object, for chaining multiple calls
8402 * into a single statement.
8403 *
8404 * @see #putExtras
8405 * @see #removeExtra
8406 * @see #getCharArrayExtra(String)
8407 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008408 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008409 if (mExtras == null) {
8410 mExtras = new Bundle();
8411 }
8412 mExtras.putCharArray(name, value);
8413 return this;
8414 }
8415
8416 /**
8417 * Add extended data to the intent. The name must include a package
8418 * prefix, for example the app com.android.contacts would use names
8419 * like "com.android.contacts.ShowAll".
8420 *
8421 * @param name The name of the extra data, with package prefix.
8422 * @param value The int array data value.
8423 *
8424 * @return Returns the same Intent object, for chaining multiple calls
8425 * into a single statement.
8426 *
8427 * @see #putExtras
8428 * @see #removeExtra
8429 * @see #getIntArrayExtra(String)
8430 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008431 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008432 if (mExtras == null) {
8433 mExtras = new Bundle();
8434 }
8435 mExtras.putIntArray(name, value);
8436 return this;
8437 }
8438
8439 /**
8440 * Add extended data to the intent. The name must include a package
8441 * prefix, for example the app com.android.contacts would use names
8442 * like "com.android.contacts.ShowAll".
8443 *
8444 * @param name The name of the extra data, with package prefix.
8445 * @param value The byte array data value.
8446 *
8447 * @return Returns the same Intent object, for chaining multiple calls
8448 * into a single statement.
8449 *
8450 * @see #putExtras
8451 * @see #removeExtra
8452 * @see #getLongArrayExtra(String)
8453 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008454 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008455 if (mExtras == null) {
8456 mExtras = new Bundle();
8457 }
8458 mExtras.putLongArray(name, value);
8459 return this;
8460 }
8461
8462 /**
8463 * Add extended data to the intent. The name must include a package
8464 * prefix, for example the app com.android.contacts would use names
8465 * like "com.android.contacts.ShowAll".
8466 *
8467 * @param name The name of the extra data, with package prefix.
8468 * @param value The float array data value.
8469 *
8470 * @return Returns the same Intent object, for chaining multiple calls
8471 * into a single statement.
8472 *
8473 * @see #putExtras
8474 * @see #removeExtra
8475 * @see #getFloatArrayExtra(String)
8476 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008477 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008478 if (mExtras == null) {
8479 mExtras = new Bundle();
8480 }
8481 mExtras.putFloatArray(name, value);
8482 return this;
8483 }
8484
8485 /**
8486 * Add extended data to the intent. The name must include a package
8487 * prefix, for example the app com.android.contacts would use names
8488 * like "com.android.contacts.ShowAll".
8489 *
8490 * @param name The name of the extra data, with package prefix.
8491 * @param value The double array data value.
8492 *
8493 * @return Returns the same Intent object, for chaining multiple calls
8494 * into a single statement.
8495 *
8496 * @see #putExtras
8497 * @see #removeExtra
8498 * @see #getDoubleArrayExtra(String)
8499 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008500 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008501 if (mExtras == null) {
8502 mExtras = new Bundle();
8503 }
8504 mExtras.putDoubleArray(name, value);
8505 return this;
8506 }
8507
8508 /**
8509 * Add extended data to the intent. The name must include a package
8510 * prefix, for example the app com.android.contacts would use names
8511 * like "com.android.contacts.ShowAll".
8512 *
8513 * @param name The name of the extra data, with package prefix.
8514 * @param value The String array data value.
8515 *
8516 * @return Returns the same Intent object, for chaining multiple calls
8517 * into a single statement.
8518 *
8519 * @see #putExtras
8520 * @see #removeExtra
8521 * @see #getStringArrayExtra(String)
8522 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008523 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008524 if (mExtras == null) {
8525 mExtras = new Bundle();
8526 }
8527 mExtras.putStringArray(name, value);
8528 return this;
8529 }
8530
8531 /**
8532 * Add extended data to the intent. The name must include a package
8533 * prefix, for example the app com.android.contacts would use names
8534 * like "com.android.contacts.ShowAll".
8535 *
8536 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008537 * @param value The CharSequence array data value.
8538 *
8539 * @return Returns the same Intent object, for chaining multiple calls
8540 * into a single statement.
8541 *
8542 * @see #putExtras
8543 * @see #removeExtra
8544 * @see #getCharSequenceArrayExtra(String)
8545 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008546 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008547 if (mExtras == null) {
8548 mExtras = new Bundle();
8549 }
8550 mExtras.putCharSequenceArray(name, value);
8551 return this;
8552 }
8553
8554 /**
8555 * Add extended data to the intent. The name must include a package
8556 * prefix, for example the app com.android.contacts would use names
8557 * like "com.android.contacts.ShowAll".
8558 *
8559 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008560 * @param value The Bundle data value.
8561 *
8562 * @return Returns the same Intent object, for chaining multiple calls
8563 * into a single statement.
8564 *
8565 * @see #putExtras
8566 * @see #removeExtra
8567 * @see #getBundleExtra(String)
8568 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008569 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008570 if (mExtras == null) {
8571 mExtras = new Bundle();
8572 }
8573 mExtras.putBundle(name, value);
8574 return this;
8575 }
8576
8577 /**
8578 * Add extended data to the intent. The name must include a package
8579 * prefix, for example the app com.android.contacts would use names
8580 * like "com.android.contacts.ShowAll".
8581 *
8582 * @param name The name of the extra data, with package prefix.
8583 * @param value The IBinder data value.
8584 *
8585 * @return Returns the same Intent object, for chaining multiple calls
8586 * into a single statement.
8587 *
8588 * @see #putExtras
8589 * @see #removeExtra
8590 * @see #getIBinderExtra(String)
8591 *
8592 * @deprecated
8593 * @hide
8594 */
8595 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008596 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008597 if (mExtras == null) {
8598 mExtras = new Bundle();
8599 }
8600 mExtras.putIBinder(name, value);
8601 return this;
8602 }
8603
8604 /**
8605 * Copy all extras in 'src' in to this intent.
8606 *
8607 * @param src Contains the extras to copy.
8608 *
8609 * @see #putExtra
8610 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008611 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008612 if (src.mExtras != null) {
8613 if (mExtras == null) {
8614 mExtras = new Bundle(src.mExtras);
8615 } else {
8616 mExtras.putAll(src.mExtras);
8617 }
8618 }
8619 return this;
8620 }
8621
8622 /**
8623 * Add a set of extended data to the intent. The keys must include a package
8624 * prefix, for example the app com.android.contacts would use names
8625 * like "com.android.contacts.ShowAll".
8626 *
8627 * @param extras The Bundle of extras to add to this intent.
8628 *
8629 * @see #putExtra
8630 * @see #removeExtra
8631 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008632 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008633 if (mExtras == null) {
8634 mExtras = new Bundle();
8635 }
8636 mExtras.putAll(extras);
8637 return this;
8638 }
8639
8640 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008641 * Completely replace the extras in the Intent with the extras in the
8642 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008643 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008644 * @param src The exact extras contained in this Intent are copied
8645 * into the target intent, replacing any that were previously there.
8646 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008647 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008648 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8649 return this;
8650 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008651
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008652 /**
8653 * Completely replace the extras in the Intent with the given Bundle of
8654 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008655 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008656 * @param extras The new set of extras in the Intent, or null to erase
8657 * all extras.
8658 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008659 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008660 mExtras = extras != null ? new Bundle(extras) : null;
8661 return this;
8662 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008663
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008664 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008665 * Remove extended data from the intent.
8666 *
8667 * @see #putExtra
8668 */
8669 public void removeExtra(String name) {
8670 if (mExtras != null) {
8671 mExtras.remove(name);
8672 if (mExtras.size() == 0) {
8673 mExtras = null;
8674 }
8675 }
8676 }
8677
8678 /**
8679 * Set special flags controlling how this intent is handled. Most values
8680 * here depend on the type of component being executed by the Intent,
8681 * specifically the FLAG_ACTIVITY_* flags are all for use with
8682 * {@link Context#startActivity Context.startActivity()} and the
8683 * FLAG_RECEIVER_* flags are all for use with
8684 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8685 *
Scott Main7aee61f2011-02-08 11:25:01 -08008686 * <p>See the
8687 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8688 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008689 * the behavior of your application.
8690 *
8691 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008692 * @return Returns the same Intent object, for chaining multiple calls
8693 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008694 * @see #getFlags
8695 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008696 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008697 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008698 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008699 mFlags = flags;
8700 return this;
8701 }
8702
8703 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008704 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008705 *
8706 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008707 * @return Returns the same Intent object, for chaining multiple calls into
8708 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008709 * @see #setFlags
8710 * @see #getFlags
8711 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008712 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008713 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008714 mFlags |= flags;
8715 return this;
8716 }
8717
8718 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008719 * Remove these flags from the intent.
8720 *
8721 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008722 * @see #setFlags
8723 * @see #getFlags
8724 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008725 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008726 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008727 mFlags &= ~flags;
8728 }
8729
8730 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008731 * (Usually optional) Set an explicit application package name that limits
8732 * the components this Intent will resolve to. If left to the default
8733 * value of null, all components in all applications will considered.
8734 * If non-null, the Intent can only match the components in the given
8735 * application package.
8736 *
8737 * @param packageName The name of the application package to handle the
8738 * intent, or null to allow any application package.
8739 *
8740 * @return Returns the same Intent object, for chaining multiple calls
8741 * into a single statement.
8742 *
8743 * @see #getPackage
8744 * @see #resolveActivity
8745 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008746 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008747 if (packageName != null && mSelector != null) {
8748 throw new IllegalArgumentException(
8749 "Can't set package name when selector is already set");
8750 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008751 mPackage = packageName;
8752 return this;
8753 }
8754
8755 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008756 * (Usually optional) Explicitly set the component to handle the intent.
8757 * If left with the default value of null, the system will determine the
8758 * appropriate class to use based on the other fields (action, data,
8759 * type, categories) in the Intent. If this class is defined, the
8760 * specified class will always be used regardless of the other fields. You
8761 * should only set this value when you know you absolutely want a specific
8762 * class to be used; otherwise it is better to let the system find the
8763 * appropriate class so that you will respect the installed applications
8764 * and user preferences.
8765 *
8766 * @param component The name of the application component to handle the
8767 * intent, or null to let the system find one for you.
8768 *
8769 * @return Returns the same Intent object, for chaining multiple calls
8770 * into a single statement.
8771 *
8772 * @see #setClass
8773 * @see #setClassName(Context, String)
8774 * @see #setClassName(String, String)
8775 * @see #getComponent
8776 * @see #resolveActivity
8777 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008778 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008779 mComponent = component;
8780 return this;
8781 }
8782
8783 /**
8784 * Convenience for calling {@link #setComponent} with an
8785 * explicit class name.
8786 *
8787 * @param packageContext A Context of the application package implementing
8788 * this class.
8789 * @param className The name of a class inside of the application package
8790 * that will be used as the component for this Intent.
8791 *
8792 * @return Returns the same Intent object, for chaining multiple calls
8793 * into a single statement.
8794 *
8795 * @see #setComponent
8796 * @see #setClass
8797 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008798 public @NonNull Intent setClassName(@NonNull Context packageContext,
8799 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008800 mComponent = new ComponentName(packageContext, className);
8801 return this;
8802 }
8803
8804 /**
8805 * Convenience for calling {@link #setComponent} with an
8806 * explicit application package name and class name.
8807 *
8808 * @param packageName The name of the package implementing the desired
8809 * component.
8810 * @param className The name of a class inside of the application package
8811 * that will be used as the component for this Intent.
8812 *
8813 * @return Returns the same Intent object, for chaining multiple calls
8814 * into a single statement.
8815 *
8816 * @see #setComponent
8817 * @see #setClass
8818 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008819 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008820 mComponent = new ComponentName(packageName, className);
8821 return this;
8822 }
8823
8824 /**
8825 * Convenience for calling {@link #setComponent(ComponentName)} with the
8826 * name returned by a {@link Class} object.
8827 *
8828 * @param packageContext A Context of the application package implementing
8829 * this class.
8830 * @param cls The class name to set, equivalent to
8831 * <code>setClassName(context, cls.getName())</code>.
8832 *
8833 * @return Returns the same Intent object, for chaining multiple calls
8834 * into a single statement.
8835 *
8836 * @see #setComponent
8837 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008838 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008839 mComponent = new ComponentName(packageContext, cls);
8840 return this;
8841 }
8842
8843 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008844 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8845 * used as a hint to the receiver for animations and the like. Null means that there
8846 * is no source bounds.
8847 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008848 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008849 if (r != null) {
8850 mSourceBounds = new Rect(r);
8851 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008852 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008853 }
8854 }
8855
Tor Norbyed9273d62013-05-30 15:59:53 -07008856 /** @hide */
8857 @IntDef(flag = true,
8858 value = {
8859 FILL_IN_ACTION,
8860 FILL_IN_DATA,
8861 FILL_IN_CATEGORIES,
8862 FILL_IN_COMPONENT,
8863 FILL_IN_PACKAGE,
8864 FILL_IN_SOURCE_BOUNDS,
8865 FILL_IN_SELECTOR,
8866 FILL_IN_CLIP_DATA
8867 })
8868 @Retention(RetentionPolicy.SOURCE)
8869 public @interface FillInFlags {}
8870
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008871 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008872 * Use with {@link #fillIn} to allow the current action value to be
8873 * overwritten, even if it is already set.
8874 */
8875 public static final int FILL_IN_ACTION = 1<<0;
8876
8877 /**
8878 * Use with {@link #fillIn} to allow the current data or type value
8879 * overwritten, even if it is already set.
8880 */
8881 public static final int FILL_IN_DATA = 1<<1;
8882
8883 /**
8884 * Use with {@link #fillIn} to allow the current categories to be
8885 * overwritten, even if they are already set.
8886 */
8887 public static final int FILL_IN_CATEGORIES = 1<<2;
8888
8889 /**
8890 * Use with {@link #fillIn} to allow the current component value to be
8891 * overwritten, even if it is already set.
8892 */
8893 public static final int FILL_IN_COMPONENT = 1<<3;
8894
8895 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008896 * Use with {@link #fillIn} to allow the current package value to be
8897 * overwritten, even if it is already set.
8898 */
8899 public static final int FILL_IN_PACKAGE = 1<<4;
8900
8901 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008902 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008903 * overwritten, even if it is already set.
8904 */
8905 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8906
8907 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008908 * Use with {@link #fillIn} to allow the current selector to be
8909 * overwritten, even if it is already set.
8910 */
8911 public static final int FILL_IN_SELECTOR = 1<<6;
8912
8913 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008914 * Use with {@link #fillIn} to allow the current ClipData to be
8915 * overwritten, even if it is already set.
8916 */
8917 public static final int FILL_IN_CLIP_DATA = 1<<7;
8918
8919 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008920 * Copy the contents of <var>other</var> in to this object, but only
8921 * where fields are not defined by this object. For purposes of a field
8922 * being defined, the following pieces of data in the Intent are
8923 * considered to be separate fields:
8924 *
8925 * <ul>
8926 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008927 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008928 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8929 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008930 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008931 * <li> component, as set by {@link #setComponent(ComponentName)} or
8932 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008933 * <li> source bounds, as set by {@link #setSourceBounds}.
8934 * <li> selector, as set by {@link #setSelector(Intent)}.
8935 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008936 * <li> each top-level name in the associated extras.
8937 * </ul>
8938 *
8939 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008940 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008941 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8942 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8943 * the restriction where the corresponding field will not be replaced if
8944 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008945 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008946 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8947 * is explicitly specified. The selector will only be copied if
8948 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008949 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008950 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8951 * and Intent B with {action="gotit", data-type="some/thing",
8952 * categories="one","two"}.
8953 *
8954 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8955 * containing: {action="gotit", data-type="some/thing",
8956 * categories="bar"}.
8957 *
8958 * @param other Another Intent whose values are to be used to fill in
8959 * the current one.
8960 * @param flags Options to control which fields can be filled in.
8961 *
8962 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008963 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008964 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008965 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008966 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008967 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008968 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008969 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008970 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008971 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008972 if (other.mAction != null
8973 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008974 mAction = other.mAction;
8975 changes |= FILL_IN_ACTION;
8976 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008977 if ((other.mData != null || other.mType != null)
8978 && ((mData == null && mType == null)
8979 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008980 mData = other.mData;
8981 mType = other.mType;
8982 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008983 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008984 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008985 if (other.mCategories != null
8986 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008987 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008988 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008989 }
8990 changes |= FILL_IN_CATEGORIES;
8991 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008992 if (other.mPackage != null
8993 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008994 // Only do this if mSelector is not set.
8995 if (mSelector == null) {
8996 mPackage = other.mPackage;
8997 changes |= FILL_IN_PACKAGE;
8998 }
8999 }
9000 // Selector is special: it can only be set if explicitly allowed,
9001 // for the same reason as the component name.
9002 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9003 if (mPackage == null) {
9004 mSelector = new Intent(other.mSelector);
9005 mPackage = null;
9006 changes |= FILL_IN_SELECTOR;
9007 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009008 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009009 if (other.mClipData != null
9010 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9011 mClipData = other.mClipData;
9012 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009013 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009014 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009015 // Component is special: it can -only- be set if explicitly allowed,
9016 // since otherwise the sender could force the intent somewhere the
9017 // originator didn't intend.
9018 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009019 mComponent = other.mComponent;
9020 changes |= FILL_IN_COMPONENT;
9021 }
9022 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009023 if (other.mSourceBounds != null
9024 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9025 mSourceBounds = new Rect(other.mSourceBounds);
9026 changes |= FILL_IN_SOURCE_BOUNDS;
9027 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009028 if (mExtras == null) {
9029 if (other.mExtras != null) {
9030 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009031 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009032 }
9033 } else if (other.mExtras != null) {
9034 try {
9035 Bundle newb = new Bundle(other.mExtras);
9036 newb.putAll(mExtras);
9037 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009038 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009039 } catch (RuntimeException e) {
9040 // Modifying the extras can cause us to unparcel the contents
9041 // of the bundle, and if we do this in the system process that
9042 // may fail. We really should handle this (i.e., the Bundle
9043 // impl shouldn't be on top of a plain map), but for now just
9044 // ignore it and keep the original contents. :(
9045 Log.w("Intent", "Failure filling in extras", e);
9046 }
9047 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009048 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9049 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9050 mContentUserHint = other.mContentUserHint;
9051 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009052 return changes;
9053 }
9054
9055 /**
9056 * Wrapper class holding an Intent and implementing comparisons on it for
9057 * the purpose of filtering. The class implements its
9058 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9059 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9060 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9061 * on the wrapped Intent.
9062 */
9063 public static final class FilterComparison {
9064 private final Intent mIntent;
9065 private final int mHashCode;
9066
9067 public FilterComparison(Intent intent) {
9068 mIntent = intent;
9069 mHashCode = intent.filterHashCode();
9070 }
9071
9072 /**
9073 * Return the Intent that this FilterComparison represents.
9074 * @return Returns the Intent held by the FilterComparison. Do
9075 * not modify!
9076 */
9077 public Intent getIntent() {
9078 return mIntent;
9079 }
9080
9081 @Override
9082 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009083 if (obj instanceof FilterComparison) {
9084 Intent other = ((FilterComparison)obj).mIntent;
9085 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009086 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009087 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009088 }
9089
9090 @Override
9091 public int hashCode() {
9092 return mHashCode;
9093 }
9094 }
9095
9096 /**
9097 * Determine if two intents are the same for the purposes of intent
9098 * resolution (filtering). That is, if their action, data, type,
9099 * class, and categories are the same. This does <em>not</em> compare
9100 * any extra data included in the intents.
9101 *
9102 * @param other The other Intent to compare against.
9103 *
9104 * @return Returns true if action, data, type, class, and categories
9105 * are the same.
9106 */
9107 public boolean filterEquals(Intent other) {
9108 if (other == null) {
9109 return false;
9110 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009111 if (!Objects.equals(this.mAction, other.mAction)) return false;
9112 if (!Objects.equals(this.mData, other.mData)) return false;
9113 if (!Objects.equals(this.mType, other.mType)) return false;
9114 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9115 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9116 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009117
9118 return true;
9119 }
9120
9121 /**
9122 * Generate hash code that matches semantics of filterEquals().
9123 *
9124 * @return Returns the hash value of the action, data, type, class, and
9125 * categories.
9126 *
9127 * @see #filterEquals
9128 */
9129 public int filterHashCode() {
9130 int code = 0;
9131 if (mAction != null) {
9132 code += mAction.hashCode();
9133 }
9134 if (mData != null) {
9135 code += mData.hashCode();
9136 }
9137 if (mType != null) {
9138 code += mType.hashCode();
9139 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009140 if (mPackage != null) {
9141 code += mPackage.hashCode();
9142 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009143 if (mComponent != null) {
9144 code += mComponent.hashCode();
9145 }
9146 if (mCategories != null) {
9147 code += mCategories.hashCode();
9148 }
9149 return code;
9150 }
9151
9152 @Override
9153 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009154 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009155
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009156 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009157 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009158 b.append(" }");
9159
9160 return b.toString();
9161 }
9162
9163 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009164 public String toInsecureString() {
9165 StringBuilder b = new StringBuilder(128);
9166
9167 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009168 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009169 b.append(" }");
9170
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009171 return b.toString();
9172 }
Romain Guy4969af72009-06-17 10:53:19 -07009173
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009174 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009175 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009176 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009177
9178 b.append("Intent { ");
9179 toShortString(b, false, true, true, true);
9180 b.append(" }");
9181
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009182 return b.toString();
9183 }
9184
9185 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009186 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9187 StringBuilder b = new StringBuilder(128);
9188 toShortString(b, secure, comp, extras, clip);
9189 return b.toString();
9190 }
9191
9192 /** @hide */
9193 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9194 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009195 boolean first = true;
9196 if (mAction != null) {
9197 b.append("act=").append(mAction);
9198 first = false;
9199 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009200 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009201 if (!first) {
9202 b.append(' ');
9203 }
9204 first = false;
9205 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009206 for (int i=0; i<mCategories.size(); i++) {
9207 if (i > 0) b.append(',');
9208 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009209 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009210 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009211 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009212 if (mData != null) {
9213 if (!first) {
9214 b.append(' ');
9215 }
9216 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009217 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009218 if (secure) {
9219 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009220 } else {
9221 b.append(mData);
9222 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009223 }
9224 if (mType != null) {
9225 if (!first) {
9226 b.append(' ');
9227 }
9228 first = false;
9229 b.append("typ=").append(mType);
9230 }
9231 if (mFlags != 0) {
9232 if (!first) {
9233 b.append(' ');
9234 }
9235 first = false;
9236 b.append("flg=0x").append(Integer.toHexString(mFlags));
9237 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009238 if (mPackage != null) {
9239 if (!first) {
9240 b.append(' ');
9241 }
9242 first = false;
9243 b.append("pkg=").append(mPackage);
9244 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009245 if (comp && mComponent != null) {
9246 if (!first) {
9247 b.append(' ');
9248 }
9249 first = false;
9250 b.append("cmp=").append(mComponent.flattenToShortString());
9251 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009252 if (mSourceBounds != null) {
9253 if (!first) {
9254 b.append(' ');
9255 }
9256 first = false;
9257 b.append("bnds=").append(mSourceBounds.toShortString());
9258 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009259 if (mClipData != null) {
9260 if (!first) {
9261 b.append(' ');
9262 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009263 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009264 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009265 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009266 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009267 if (mClipData.getDescription() != null) {
9268 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9269 } else {
9270 first = true;
9271 }
9272 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009273 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009274 first = false;
9275 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009276 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009277 if (extras && mExtras != null) {
9278 if (!first) {
9279 b.append(' ');
9280 }
9281 first = false;
9282 b.append("(has extras)");
9283 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009284 if (mContentUserHint != UserHandle.USER_CURRENT) {
9285 if (!first) {
9286 b.append(' ');
9287 }
9288 first = false;
9289 b.append("u=").append(mContentUserHint);
9290 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009291 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009292 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009293 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009294 b.append("}");
9295 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009296 }
9297
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009298 /**
9299 * Call {@link #toUri} with 0 flags.
9300 * @deprecated Use {@link #toUri} instead.
9301 */
9302 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009303 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009304 return toUri(0);
9305 }
9306
9307 /**
9308 * Convert this Intent into a String holding a URI representation of it.
9309 * The returned URI string has been properly URI encoded, so it can be
9310 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9311 * Intent's data as the base URI, with an additional fragment describing
9312 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009313 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009314 * <p>You can convert the returned string back to an Intent with
9315 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009316 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009317 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009318 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009319 * @return Returns a URI encoding URI string describing the entire contents
9320 * of the Intent.
9321 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009322 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009323 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009324 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9325 if (mPackage == null) {
9326 throw new IllegalArgumentException(
9327 "Intent must include an explicit package name to build an android-app: "
9328 + this);
9329 }
9330 uri.append("android-app://");
9331 uri.append(mPackage);
9332 String scheme = null;
9333 if (mData != null) {
9334 scheme = mData.getScheme();
9335 if (scheme != null) {
9336 uri.append('/');
9337 uri.append(scheme);
9338 String authority = mData.getEncodedAuthority();
9339 if (authority != null) {
9340 uri.append('/');
9341 uri.append(authority);
9342 String path = mData.getEncodedPath();
9343 if (path != null) {
9344 uri.append(path);
9345 }
9346 String queryParams = mData.getEncodedQuery();
9347 if (queryParams != null) {
9348 uri.append('?');
9349 uri.append(queryParams);
9350 }
9351 String fragment = mData.getEncodedFragment();
9352 if (fragment != null) {
9353 uri.append('#');
9354 uri.append(fragment);
9355 }
9356 }
9357 }
9358 }
9359 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9360 mPackage, flags);
9361 return uri.toString();
9362 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009363 String scheme = null;
9364 if (mData != null) {
9365 String data = mData.toString();
9366 if ((flags&URI_INTENT_SCHEME) != 0) {
9367 final int N = data.length();
9368 for (int i=0; i<N; i++) {
9369 char c = data.charAt(i);
9370 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9371 || c == '.' || c == '-') {
9372 continue;
9373 }
9374 if (c == ':' && i > 0) {
9375 // Valid scheme.
9376 scheme = data.substring(0, i);
9377 uri.append("intent:");
9378 data = data.substring(i+1);
9379 break;
9380 }
Tom Taylord4a47292009-12-21 13:59:18 -08009381
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009382 // No scheme.
9383 break;
9384 }
9385 }
9386 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009387
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009388 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9389 uri.append("intent:");
9390 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009391
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009392 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009393
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009394 return uri.toString();
9395 }
9396
9397 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9398 String defPackage, int flags) {
9399 StringBuilder frag = new StringBuilder(128);
9400
9401 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009402 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009403 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009404 // Note that for now we are not going to try to handle the
9405 // data part; not clear how to represent this as a URI, and
9406 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009407 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9408 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009409 }
9410
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009411 if (frag.length() > 0) {
9412 uri.append("#Intent;");
9413 uri.append(frag);
9414 uri.append("end");
9415 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009416 }
9417
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009418 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9419 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009420 if (scheme != null) {
9421 uri.append("scheme=").append(scheme).append(';');
9422 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009423 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009424 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009425 }
9426 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009427 for (int i=0; i<mCategories.size(); i++) {
9428 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009429 }
9430 }
9431 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009432 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009433 }
9434 if (mFlags != 0) {
9435 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9436 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009437 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009438 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9439 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009440 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009441 uri.append("component=").append(Uri.encode(
9442 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009443 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009444 if (mSourceBounds != null) {
9445 uri.append("sourceBounds=")
9446 .append(Uri.encode(mSourceBounds.flattenToString()))
9447 .append(';');
9448 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009449 if (mExtras != null) {
9450 for (String key : mExtras.keySet()) {
9451 final Object value = mExtras.get(key);
9452 char entryType =
9453 value instanceof String ? 'S' :
9454 value instanceof Boolean ? 'B' :
9455 value instanceof Byte ? 'b' :
9456 value instanceof Character ? 'c' :
9457 value instanceof Double ? 'd' :
9458 value instanceof Float ? 'f' :
9459 value instanceof Integer ? 'i' :
9460 value instanceof Long ? 'l' :
9461 value instanceof Short ? 's' :
9462 '\0';
9463
9464 if (entryType != '\0') {
9465 uri.append(entryType);
9466 uri.append('.');
9467 uri.append(Uri.encode(key));
9468 uri.append('=');
9469 uri.append(Uri.encode(value.toString()));
9470 uri.append(';');
9471 }
9472 }
9473 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009474 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009475
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009476 public int describeContents() {
9477 return (mExtras != null) ? mExtras.describeContents() : 0;
9478 }
9479
9480 public void writeToParcel(Parcel out, int flags) {
9481 out.writeString(mAction);
9482 Uri.writeToParcel(out, mData);
9483 out.writeString(mType);
9484 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009485 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009486 ComponentName.writeToParcel(mComponent, out);
9487
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009488 if (mSourceBounds != null) {
9489 out.writeInt(1);
9490 mSourceBounds.writeToParcel(out, flags);
9491 } else {
9492 out.writeInt(0);
9493 }
9494
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009495 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009496 final int N = mCategories.size();
9497 out.writeInt(N);
9498 for (int i=0; i<N; i++) {
9499 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009500 }
9501 } else {
9502 out.writeInt(0);
9503 }
9504
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009505 if (mSelector != null) {
9506 out.writeInt(1);
9507 mSelector.writeToParcel(out, flags);
9508 } else {
9509 out.writeInt(0);
9510 }
9511
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009512 if (mClipData != null) {
9513 out.writeInt(1);
9514 mClipData.writeToParcel(out, flags);
9515 } else {
9516 out.writeInt(0);
9517 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009518 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009519 out.writeBundle(mExtras);
9520 }
9521
9522 public static final Parcelable.Creator<Intent> CREATOR
9523 = new Parcelable.Creator<Intent>() {
9524 public Intent createFromParcel(Parcel in) {
9525 return new Intent(in);
9526 }
9527 public Intent[] newArray(int size) {
9528 return new Intent[size];
9529 }
9530 };
9531
Dianne Hackborneb034652009-09-07 00:49:58 -07009532 /** @hide */
9533 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009534 readFromParcel(in);
9535 }
9536
9537 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009538 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009539 mData = Uri.CREATOR.createFromParcel(in);
9540 mType = in.readString();
9541 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009542 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009543 mComponent = ComponentName.readFromParcel(in);
9544
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009545 if (in.readInt() != 0) {
9546 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9547 }
9548
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009549 int N = in.readInt();
9550 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009551 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009552 int i;
9553 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009554 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009555 }
9556 } else {
9557 mCategories = null;
9558 }
9559
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009560 if (in.readInt() != 0) {
9561 mSelector = new Intent(in);
9562 }
9563
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009564 if (in.readInt() != 0) {
9565 mClipData = new ClipData(in);
9566 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009567 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009568 mExtras = in.readBundle();
9569 }
9570
9571 /**
9572 * Parses the "intent" element (and its children) from XML and instantiates
9573 * an Intent object. The given XML parser should be located at the tag
9574 * where parsing should start (often named "intent"), from which the
9575 * basic action, data, type, and package and class name will be
9576 * retrieved. The function will then parse in to any child elements,
9577 * looking for <category android:name="xxx"> tags to add categories and
9578 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9579 * to the intent.
9580 *
9581 * @param resources The Resources to use when inflating resources.
9582 * @param parser The XML parser pointing at an "intent" tag.
9583 * @param attrs The AttributeSet interface for retrieving extended
9584 * attribute data at the current <var>parser</var> location.
9585 * @return An Intent object matching the XML data.
9586 * @throws XmlPullParserException If there was an XML parsing error.
9587 * @throws IOException If there was an I/O error.
9588 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009589 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9590 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009591 throws XmlPullParserException, IOException {
9592 Intent intent = new Intent();
9593
9594 TypedArray sa = resources.obtainAttributes(attrs,
9595 com.android.internal.R.styleable.Intent);
9596
9597 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9598
9599 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9600 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9601 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9602
9603 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9604 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9605 if (packageName != null && className != null) {
9606 intent.setComponent(new ComponentName(packageName, className));
9607 }
9608
9609 sa.recycle();
9610
9611 int outerDepth = parser.getDepth();
9612 int type;
9613 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9614 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9615 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9616 continue;
9617 }
9618
9619 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009620 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009621 sa = resources.obtainAttributes(attrs,
9622 com.android.internal.R.styleable.IntentCategory);
9623 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9624 sa.recycle();
9625
9626 if (cat != null) {
9627 intent.addCategory(cat);
9628 }
9629 XmlUtils.skipCurrentTag(parser);
9630
Craig Mautner21d24a22014-04-23 11:45:37 -07009631 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009632 if (intent.mExtras == null) {
9633 intent.mExtras = new Bundle();
9634 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009635 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009636 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009637
9638 } else {
9639 XmlUtils.skipCurrentTag(parser);
9640 }
9641 }
9642
9643 return intent;
9644 }
Nick Pellyccae4122012-01-09 14:12:58 -08009645
Craig Mautner21d24a22014-04-23 11:45:37 -07009646 /** @hide */
9647 public void saveToXml(XmlSerializer out) throws IOException {
9648 if (mAction != null) {
9649 out.attribute(null, ATTR_ACTION, mAction);
9650 }
9651 if (mData != null) {
9652 out.attribute(null, ATTR_DATA, mData.toString());
9653 }
9654 if (mType != null) {
9655 out.attribute(null, ATTR_TYPE, mType);
9656 }
9657 if (mComponent != null) {
9658 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9659 }
9660 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9661
9662 if (mCategories != null) {
9663 out.startTag(null, TAG_CATEGORIES);
9664 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9665 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9666 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009667 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009668 }
9669 }
9670
9671 /** @hide */
9672 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9673 XmlPullParserException {
9674 Intent intent = new Intent();
9675 final int outerDepth = in.getDepth();
9676
9677 int attrCount = in.getAttributeCount();
9678 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9679 final String attrName = in.getAttributeName(attrNdx);
9680 final String attrValue = in.getAttributeValue(attrNdx);
9681 if (ATTR_ACTION.equals(attrName)) {
9682 intent.setAction(attrValue);
9683 } else if (ATTR_DATA.equals(attrName)) {
9684 intent.setData(Uri.parse(attrValue));
9685 } else if (ATTR_TYPE.equals(attrName)) {
9686 intent.setType(attrValue);
9687 } else if (ATTR_COMPONENT.equals(attrName)) {
9688 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9689 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009690 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009691 } else {
9692 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9693 }
9694 }
9695
9696 int event;
9697 String name;
9698 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9699 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9700 if (event == XmlPullParser.START_TAG) {
9701 name = in.getName();
9702 if (TAG_CATEGORIES.equals(name)) {
9703 attrCount = in.getAttributeCount();
9704 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9705 intent.addCategory(in.getAttributeValue(attrNdx));
9706 }
9707 } else {
9708 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9709 XmlUtils.skipCurrentTag(in);
9710 }
9711 }
9712 }
9713
9714 return intent;
9715 }
9716
Nick Pellyccae4122012-01-09 14:12:58 -08009717 /**
9718 * Normalize a MIME data type.
9719 *
9720 * <p>A normalized MIME type has white-space trimmed,
9721 * content-type parameters removed, and is lower-case.
9722 * This aligns the type with Android best practices for
9723 * intent filtering.
9724 *
9725 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9726 * "text/x-vCard" becomes "text/x-vcard".
9727 *
9728 * <p>All MIME types received from outside Android (such as user input,
9729 * or external sources like Bluetooth, NFC, or the Internet) should
9730 * be normalized before they are used to create an Intent.
9731 *
9732 * @param type MIME data type to normalize
9733 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009734 * @see #setType
9735 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009736 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009737 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08009738 if (type == null) {
9739 return null;
9740 }
9741
Elliott Hughescb64d432013-08-02 10:00:44 -07009742 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009743
9744 final int semicolonIndex = type.indexOf(';');
9745 if (semicolonIndex != -1) {
9746 type = type.substring(0, semicolonIndex);
9747 }
9748 return type;
9749 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009750
9751 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009752 * Prepare this {@link Intent} to leave an app process.
9753 *
9754 * @hide
9755 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009756 public void prepareToLeaveProcess(Context context) {
9757 final boolean leavingPackage = (mComponent == null)
9758 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9759 prepareToLeaveProcess(leavingPackage);
9760 }
9761
9762 /**
9763 * Prepare this {@link Intent} to leave an app process.
9764 *
9765 * @hide
9766 */
9767 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009768 setAllowFds(false);
9769
9770 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009771 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009772 }
9773 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009774 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009775 }
9776
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009777 if (mExtras != null && !mExtras.isParcelled()) {
9778 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9779 if (intent instanceof Intent) {
9780 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9781 }
9782 }
9783
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009784 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9785 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009786 switch (mAction) {
9787 case ACTION_MEDIA_REMOVED:
9788 case ACTION_MEDIA_UNMOUNTED:
9789 case ACTION_MEDIA_CHECKING:
9790 case ACTION_MEDIA_NOFS:
9791 case ACTION_MEDIA_MOUNTED:
9792 case ACTION_MEDIA_SHARED:
9793 case ACTION_MEDIA_UNSHARED:
9794 case ACTION_MEDIA_BAD_REMOVAL:
9795 case ACTION_MEDIA_UNMOUNTABLE:
9796 case ACTION_MEDIA_EJECT:
9797 case ACTION_MEDIA_SCANNER_STARTED:
9798 case ACTION_MEDIA_SCANNER_FINISHED:
9799 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009800 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9801 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009802 // Ignore legacy actions
9803 break;
9804 default:
9805 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009806 }
9807 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009808
9809 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9810 && leavingPackage) {
9811 switch (mAction) {
9812 case ACTION_PROVIDER_CHANGED:
9813 // Ignore actions that don't need to grant
9814 break;
9815 default:
9816 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9817 }
9818 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009819 }
9820
9821 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009822 * @hide
9823 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009824 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009825 // We just entered destination process, so we should be able to read all
9826 // parcelables inside.
9827 setDefusable(true);
9828
9829 if (mSelector != null) {
9830 mSelector.prepareToEnterProcess();
9831 }
9832 if (mClipData != null) {
9833 mClipData.prepareToEnterProcess();
9834 }
9835
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009836 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009837 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9838 fixUris(mContentUserHint);
9839 mContentUserHint = UserHandle.USER_CURRENT;
9840 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009841 }
9842 }
9843
9844 /**
9845 * @hide
9846 */
9847 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009848 Uri data = getData();
9849 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009850 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009851 }
9852 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009853 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009854 }
9855 String action = getAction();
9856 if (ACTION_SEND.equals(action)) {
9857 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9858 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009859 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009860 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009861 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009862 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9863 if (streams != null) {
9864 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9865 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009866 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009867 }
9868 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9869 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009870 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9871 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9872 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9873 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9874 if (output != null) {
9875 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9876 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009877 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009878 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009879
9880 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009881 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009882 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9883 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009884 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009885 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009886 * @hide
9887 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009888 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009889 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009890 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009891
9892 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009893 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009894
9895 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009896 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009897 // Inspect contained intents to see if we need to migrate extras. We
9898 // don't promote ClipData to the parent, since ChooserActivity will
9899 // already start the picked item as the caller, and we can't combine
9900 // the flags in a safe way.
9901
9902 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009903 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009904 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9905 if (intent != null) {
9906 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009907 }
9908 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009909 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009910 try {
9911 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9912 if (intents != null) {
9913 for (int i = 0; i < intents.length; i++) {
9914 final Intent intent = (Intent) intents[i];
9915 if (intent != null) {
9916 migrated |= intent.migrateExtraStreamToClipData();
9917 }
9918 }
9919 }
9920 } catch (ClassCastException e) {
9921 }
9922 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009923
9924 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009925 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009926 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9927 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9928 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9929 if (stream != null || text != null || htmlText != null) {
9930 final ClipData clipData = new ClipData(
9931 null, new String[] { getType() },
9932 new ClipData.Item(text, htmlText, null, stream));
9933 setClipData(clipData);
9934 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009935 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009936 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009937 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009938 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009939
9940 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009941 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009942 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9943 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9944 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9945 int num = -1;
9946 if (streams != null) {
9947 num = streams.size();
9948 }
9949 if (texts != null) {
9950 if (num >= 0 && num != texts.size()) {
9951 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009952 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009953 }
9954 num = texts.size();
9955 }
9956 if (htmlTexts != null) {
9957 if (num >= 0 && num != htmlTexts.size()) {
9958 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009959 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009960 }
9961 num = htmlTexts.size();
9962 }
9963 if (num > 0) {
9964 final ClipData clipData = new ClipData(
9965 null, new String[] { getType() },
9966 makeClipItem(streams, texts, htmlTexts, 0));
9967
9968 for (int i = 1; i < num; i++) {
9969 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9970 }
9971
9972 setClipData(clipData);
9973 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009974 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009975 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009976 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009977 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009978 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9979 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9980 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9981 final Uri output;
9982 try {
9983 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9984 } catch (ClassCastException e) {
9985 return false;
9986 }
9987 if (output != null) {
9988 setClipData(ClipData.newRawUri("", output));
9989 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9990 return true;
9991 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009992 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009993
9994 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009995 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009996
9997 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9998 ArrayList<String> htmlTexts, int which) {
9999 Uri uri = streams != null ? streams.get(which) : null;
10000 CharSequence text = texts != null ? texts.get(which) : null;
10001 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10002 return new ClipData.Item(text, htmlText, null, uri);
10003 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010004
10005 /** @hide */
10006 public boolean isDocument() {
10007 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10008 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010009}