blob: 9c87ff27caafafa85f88bfa40c820b73de65711a [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 */
1402 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1403
1404 /**
1405 * Activity Action: The user pressed the "call" button to go to the dialer
1406 * or other appropriate UI for placing a call.
1407 * <p>Input: Nothing.
1408 * <p>Output: Nothing.
1409 */
1410 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1411 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1412
1413 /**
1414 * Activity Action: Start Voice Command.
1415 * <p>Input: Nothing.
1416 * <p>Output: Nothing.
1417 */
1418 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1419 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001420
1421 /**
1422 * Activity Action: Start action associated with long pressing on the
1423 * search key.
1424 * <p>Input: Nothing.
1425 * <p>Output: Nothing.
1426 */
1427 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1428 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001429
Jacek Surazski86b6c532009-05-13 14:38:28 +02001430 /**
1431 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1432 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001433 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001434 * <p>Input: No data is specified. The bug report is passed in using
1435 * an {@link #EXTRA_BUG_REPORT} field.
1436 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001437 *
1438 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001439 */
1440 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1441 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001442
1443 /**
1444 * Activity Action: Show power usage information to the user.
1445 * <p>Input: Nothing.
1446 * <p>Output: Nothing.
1447 */
1448 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1449 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001450
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001451 /**
Russell Brenner880994d2017-02-24 11:11:47 -08001452 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1453 * to run.
1454 * <p>Input: Nothing.
1455 * <p>Output: Nothing.
1456 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1457 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1458 * @hide
1459 */
1460 @Deprecated
1461 @SystemApi
1462 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1463 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1464
1465 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001466 * Activity Action: Setup wizard to launch after a platform update. This
1467 * activity should have a string meta-data field associated with it,
1468 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1469 * the platform for setup. The activity will be launched only if
1470 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1471 * same value.
1472 * <p>Input: Nothing.
1473 * <p>Output: Nothing.
1474 * @hide
1475 */
Russell Brenner880994d2017-02-24 11:11:47 -08001476 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001477 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1478 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001479
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001480 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001481 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1482 * <p>Input: Nothing.
1483 * <p>Output: Nothing.
1484 * @hide
1485 */
1486 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1487 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001488 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001489
1490 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001491 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1492 * <p>Input: Nothing.
1493 * <p>Output: Nothing.
1494 * @hide
1495 */
1496 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1497 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001498 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001499
1500 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001501 * Activity Action: Show settings for managing network data usage of a
1502 * specific application. Applications should define an activity that offers
1503 * options to control data usage.
1504 */
1505 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1506 public static final String ACTION_MANAGE_NETWORK_USAGE =
1507 "android.intent.action.MANAGE_NETWORK_USAGE";
1508
1509 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001510 * Activity Action: Launch application installer.
1511 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001512 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001513 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1514 * you can also use "package:<package-name>" to install an application for the
1515 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001516 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1517 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1518 * <p>
1519 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1520 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001521 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001522 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001523 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1524 * in order to launch the application installer.
1525 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001526 *
1527 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1528 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1529 * @see #EXTRA_RETURN_RESULT
1530 */
1531 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1532 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1533
1534 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001535 * @hide
1536 * @deprecated Do not use. This will go away.
1537 * Replace with {@link #ACTION_INSTALL_INSTANT_APP_PACKAGE}.
1538 */
1539 @SystemApi
1540 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1541 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1542 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1543 /**
1544 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001545 * <p class="note">
1546 * This is a protected intent that can only be sent by the system.
1547 * </p>
1548 *
1549 * @hide
1550 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001551 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001552 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001553 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1554 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001555
1556 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001557 * @hide
1558 * @deprecated Do not use. This will go away.
1559 * Replace with {@link #ACTION_RESOLVE_INSTANT_APP_PACKAGE}.
1560 */
1561 @SystemApi
1562 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1563 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1564 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1565 /**
1566 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001567 * <p>
1568 * The system will have a persistent connection to this service.
1569 * This is a protected intent that can only be sent by the system.
1570 * </p>
1571 *
1572 * @hide
1573 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001574 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001575 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001576 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1577 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001578
1579 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001580 * @hide
1581 * @deprecated Do not use. This will go away.
1582 * Replace with {@link #ACTION_INSTANT_APP_RESOLVER_SETTINGS}.
1583 */
1584 @SystemApi
1585 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1586 public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1587 = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1588 /**
1589 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001590 *
1591 * <p class="note">
1592 * This is a protected intent that can only be sent by the system.
1593 * </p>
1594 *
1595 * @hide
1596 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001597 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001598 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001599 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1600 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001601
1602 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001603 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1604 * package. Specifies the installer package name; this package will receive the
1605 * {@link #ACTION_APP_ERROR} intent.
1606 */
1607 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1608 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1609
1610 /**
1611 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1612 * package. Specifies that the application being installed should not be
1613 * treated as coming from an unknown source, but as coming from the app
1614 * invoking the Intent. For this to work you must start the installer with
1615 * startActivityForResult().
1616 */
1617 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1618 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1619
1620 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001621 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1622 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001623 * data field originated from.
1624 */
rich cannings706e8ba2012-08-20 13:20:14 -07001625 public static final String EXTRA_ORIGINATING_URI
1626 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001627
1628 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001629 * This extra can be used with any Intent used to launch an activity, supplying information
1630 * about who is launching that activity. This field contains a {@link android.net.Uri}
1631 * object, typically an http: or https: URI of the web site that the referral came from;
1632 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1633 * a native application that it came from.
1634 *
1635 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1636 * instead of directly retrieving the extra. It is also valid for applications to
1637 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1638 * a string, not a Uri; the field here, if supplied, will always take precedence,
1639 * however.</p>
1640 *
1641 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001642 */
1643 public static final String EXTRA_REFERRER
1644 = "android.intent.extra.REFERRER";
1645
1646 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001647 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1648 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1649 * not be created, in particular when Intent extras are supplied through the
1650 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1651 * schemes.
1652 *
1653 * @see #EXTRA_REFERRER
1654 */
1655 public static final String EXTRA_REFERRER_NAME
1656 = "android.intent.extra.REFERRER_NAME";
1657
1658 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001659 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001660 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001661 * Currently only a system app that hosts the provider authority "downloads" or holds the
1662 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001663 * @hide
1664 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001665 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001666 public static final String EXTRA_ORIGINATING_UID
1667 = "android.intent.extra.ORIGINATING_UID";
1668
1669 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001670 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1671 * package. Tells the installer UI to skip the confirmation with the user
1672 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001673 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1674 * will no longer show an interstitial message about updating existing
1675 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001676 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001677 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001678 public static final String EXTRA_ALLOW_REPLACE
1679 = "android.intent.extra.ALLOW_REPLACE";
1680
1681 /**
1682 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1683 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1684 * return to the application the result code of the install/uninstall. The returned result
1685 * code will be {@link android.app.Activity#RESULT_OK} on success or
1686 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1687 */
1688 public static final String EXTRA_RETURN_RESULT
1689 = "android.intent.extra.RETURN_RESULT";
1690
1691 /**
1692 * Package manager install result code. @hide because result codes are not
1693 * yet ready to be exposed.
1694 */
1695 public static final String EXTRA_INSTALL_RESULT
1696 = "android.intent.extra.INSTALL_RESULT";
1697
1698 /**
1699 * Activity Action: Launch application uninstaller.
1700 * <p>
1701 * Input: The data must be a package: URI whose scheme specific part is
1702 * the package name of the current installed package to be uninstalled.
1703 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1704 * <p>
1705 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1706 * succeeded.
1707 */
1708 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1709 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1710
1711 /**
msnider3c191b82017-01-23 14:23:16 -08001712 * Activity Action: Launch application uninstaller.
1713 * <p>
1714 * Input: The data must be a package: URI whose scheme specific part is
1715 * the package name of the current installed package to be uninstalled.
1716 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1717 * <p>
1718 * Output: Nothing.
1719 * </p>
1720 */
1721 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1722 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1723
1724 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001725 * Specify whether the package should be uninstalled for all users.
1726 * @hide because these should not be part of normal application flow.
1727 */
1728 public static final String EXTRA_UNINSTALL_ALL_USERS
1729 = "android.intent.extra.UNINSTALL_ALL_USERS";
1730
1731 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001732 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1733 * describing the last run version of the platform that was setup.
1734 * @hide
1735 */
1736 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1737
Svet Ganov3695b8a2015-03-24 16:30:25 -07001738 /**
1739 * Activity action: Launch UI to manage the permissions of an app.
1740 * <p>
1741 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1742 * will be managed by the launched UI.
1743 * </p>
1744 * <p>
1745 * Output: Nothing.
1746 * </p>
1747 *
1748 * @see #EXTRA_PACKAGE_NAME
1749 *
1750 * @hide
1751 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001752 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001753 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1754 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1755 "android.intent.action.MANAGE_APP_PERMISSIONS";
1756
1757 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001758 * Activity action: Launch UI to manage permissions.
1759 * <p>
1760 * Input: Nothing.
1761 * </p>
1762 * <p>
1763 * Output: Nothing.
1764 * </p>
1765 *
1766 * @hide
1767 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001768 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001769 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1770 public static final String ACTION_MANAGE_PERMISSIONS =
1771 "android.intent.action.MANAGE_PERMISSIONS";
1772
1773 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001774 * Activity action: Launch UI to review permissions for an app.
1775 * The system uses this intent if permission review for apps not
1776 * supporting the new runtime permissions model is enabled. In
1777 * this mode a permission review is required before any of the
1778 * app components can run.
1779 * <p>
1780 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1781 * permissions will be reviewed (mandatory).
1782 * </p>
1783 * <p>
1784 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1785 * be fired after the permission review (optional).
1786 * </p>
1787 * <p>
1788 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1789 * be invoked after the permission review (optional).
1790 * </p>
1791 * <p>
1792 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1793 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1794 * </p>
1795 * <p>
1796 * Output: Nothing.
1797 * </p>
1798 *
1799 * @see #EXTRA_PACKAGE_NAME
1800 * @see #EXTRA_INTENT
1801 * @see #EXTRA_REMOTE_CALLBACK
1802 * @see #EXTRA_RESULT_NEEDED
1803 *
1804 * @hide
1805 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001806 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001807 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1808 public static final String ACTION_REVIEW_PERMISSIONS =
1809 "android.intent.action.REVIEW_PERMISSIONS";
1810
1811 /**
1812 * Intent extra: A callback for reporting remote result as a bundle.
1813 * <p>
1814 * Type: IRemoteCallback
1815 * </p>
1816 *
1817 * @hide
1818 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001819 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001820 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1821
1822 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001823 * Intent extra: An app package name.
1824 * <p>
1825 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001826 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001827 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001828 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001829 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1830
1831 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001832 * Intent extra: An app split name.
1833 * <p>
1834 * Type: String
1835 * </p>
1836 * @hide
1837 */
1838 @SystemApi
1839 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1840
1841 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001842 * Intent extra: An extra for specifying whether a result is needed.
1843 * <p>
1844 * Type: boolean
1845 * </p>
1846 *
1847 * @hide
1848 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001849 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001850 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1851
1852 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001853 * Activity action: Launch UI to manage which apps have a given permission.
1854 * <p>
1855 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1856 * to which will be managed by the launched UI.
1857 * </p>
1858 * <p>
1859 * Output: Nothing.
1860 * </p>
1861 *
1862 * @see #EXTRA_PERMISSION_NAME
1863 *
1864 * @hide
1865 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001866 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001867 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1868 public static final String ACTION_MANAGE_PERMISSION_APPS =
1869 "android.intent.action.MANAGE_PERMISSION_APPS";
1870
1871 /**
1872 * Intent extra: The name of a permission.
1873 * <p>
1874 * Type: String
1875 * </p>
1876 *
1877 * @hide
1878 */
1879 @SystemApi
1880 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1881
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001882 // ---------------------------------------------------------------------
1883 // ---------------------------------------------------------------------
1884 // Standard intent broadcast actions (see action variable).
1885
1886 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001887 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1888 * <p>
1889 * For historical reasons, the name of this broadcast action refers to the power
1890 * state of the screen but it is actually sent in response to changes in the
1891 * overall interactive state of the device.
1892 * </p><p>
1893 * This broadcast is sent when the device becomes non-interactive which may have
1894 * nothing to do with the screen turning off. To determine the
1895 * actual state of the screen, use {@link android.view.Display#getState}.
1896 * </p><p>
1897 * See {@link android.os.PowerManager#isInteractive} for details.
1898 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001899 * You <em>cannot</em> receive this through components declared in
1900 * manifests, only by explicitly registering for it with
1901 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1902 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001903 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001904 * <p class="note">This is a protected intent that can only be sent
1905 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001906 */
1907 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1908 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001909
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001910 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001911 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1912 * <p>
1913 * For historical reasons, the name of this broadcast action refers to the power
1914 * state of the screen but it is actually sent in response to changes in the
1915 * overall interactive state of the device.
1916 * </p><p>
1917 * This broadcast is sent when the device becomes interactive which may have
1918 * nothing to do with the screen turning on. To determine the
1919 * actual state of the screen, use {@link android.view.Display#getState}.
1920 * </p><p>
1921 * See {@link android.os.PowerManager#isInteractive} for details.
1922 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001923 * You <em>cannot</em> receive this through components declared in
1924 * manifests, only by explicitly registering for it with
1925 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1926 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001927 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001928 * <p class="note">This is a protected intent that can only be sent
1929 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001930 */
1931 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1932 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001933
1934 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001935 * Broadcast Action: Sent after the system stops dreaming.
1936 *
1937 * <p class="note">This is a protected intent that can only be sent by the system.
1938 * It is only sent to registered receivers.</p>
1939 */
1940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1941 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1942
1943 /**
1944 * Broadcast Action: Sent after the system starts 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_STARTED = "android.intent.action.DREAMING_STARTED";
1951
1952 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001953 * 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 -07001954 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001955 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001956 * <p class="note">This is a protected intent that can only be sent
1957 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001958 */
1959 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001960 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001961
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001962 /**
1963 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001964 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001965 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001966 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1967 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001968 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001969 * <p class="note">This is a protected intent that can only be sent
1970 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001971 */
1972 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1973 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1974 /**
1975 * Broadcast Action: The time was set.
1976 */
1977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1978 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1979 /**
1980 * Broadcast Action: The date has changed.
1981 */
1982 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1983 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1984 /**
1985 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1986 * <ul>
1987 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1988 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001989 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001990 * <p class="note">This is a protected intent that can only be sent
1991 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001992 */
1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1995 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001996 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1997 * DNS entries should be tossed.
1998 * @hide
1999 */
2000 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2001 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2002 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002003 * Alarm Changed Action: This is broadcast when the AlarmClock
2004 * application's alarm is set or unset. It is used by the
2005 * AlarmClock application and the StatusBar service.
2006 * @hide
2007 */
2008 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2009 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002010
2011 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002012 * Broadcast Action: This is broadcast once, after the user has finished
2013 * booting, but while still in the "locked" state. It can be used to perform
2014 * application-specific initialization, such as installing alarms. You must
2015 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2016 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002017 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002018 * This broadcast is sent immediately at boot by all devices (regardless of
2019 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2020 * higher. Upon receipt of this broadcast, the user is still locked and only
2021 * device-protected storage can be accessed safely. If you want to access
2022 * credential-protected storage, you need to wait for the user to be
2023 * unlocked (typically by entering their lock pattern or PIN for the first
2024 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2025 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2026 * <p>
2027 * To receive this broadcast, your receiver component must be marked as
2028 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002029 * <p class="note">
2030 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002031 *
2032 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002033 */
2034 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2035 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2036
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002037 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002038 * Broadcast Action: This is broadcast once, after the user has finished
2039 * booting. It can be used to perform application-specific initialization,
2040 * such as installing alarms. You must hold the
2041 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2042 * order to receive this broadcast.
2043 * <p>
2044 * This broadcast is sent at boot by all devices (both with and without
2045 * direct boot support). Upon receipt of this broadcast, the user is
2046 * unlocked and both device-protected and credential-protected storage can
2047 * accessed safely.
2048 * <p>
2049 * If you need to run while the user is still locked (before they've entered
2050 * their lock pattern or PIN for the first time), you can listen for the
2051 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2052 * <p class="note">
2053 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002054 */
2055 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002056 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002057 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002058
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002059 /**
2060 * Broadcast Action: This is broadcast when a user action should request a
2061 * temporary system dialog to dismiss. Some examples of temporary system
2062 * dialogs are the notification window-shade and the recent tasks dialog.
2063 */
2064 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2065 /**
2066 * Broadcast Action: Trigger the download and eventual installation
2067 * of a package.
2068 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002069 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002070 * <p class="note">This is a protected intent that can only be sent
2071 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002072 *
2073 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002074 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002075 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2077 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2078 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002079 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002080 * device. The data contains the name of the package. Note that the
2081 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002082 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002083 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002084 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2085 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002086 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2087 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002088 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002089 * <p class="note">This is a protected intent that can only be sent
2090 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002091 */
2092 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2093 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2094 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002095 * Broadcast Action: A new version of an application package has been
2096 * installed, replacing an existing version that was previously installed.
2097 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002098 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002099 * <ul>
2100 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2101 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002102 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002103 * <p class="note">This is a protected intent that can only be sent
2104 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002105 */
2106 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2107 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2108 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002109 * Broadcast Action: A new version of your application has been installed
2110 * over an existing one. This is only sent to the application that was
2111 * replaced. It does not contain any additional data; to receive it, just
2112 * use an intent filter for this action.
2113 *
2114 * <p class="note">This is a protected intent that can only be sent
2115 * by the system.
2116 */
2117 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2118 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2119 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002120 * Broadcast Action: An existing application package has been removed from
2121 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002122 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002123 * <ul>
2124 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2125 * to the package.
2126 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2127 * application -- data and code -- is being removed.
2128 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2129 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2130 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002131 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002132 * <p class="note">This is a protected intent that can only be sent
2133 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002134 */
2135 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2136 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2137 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002138 * Broadcast Action: An existing application package has been completely
2139 * removed from the device. The data contains the name of the package.
2140 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2141 * {@link #EXTRA_DATA_REMOVED} is true and
2142 * {@link #EXTRA_REPLACING} is false of that broadcast.
2143 *
2144 * <ul>
2145 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2146 * to the package.
2147 * </ul>
2148 *
2149 * <p class="note">This is a protected intent that can only be sent
2150 * by the system.
2151 */
2152 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2153 public static final String ACTION_PACKAGE_FULLY_REMOVED
2154 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2155 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002156 * Broadcast Action: An existing application package has been changed (for
2157 * example, a component has been enabled or disabled). The data contains
2158 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002159 * <ul>
2160 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002161 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002162 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002163 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2164 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002165 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002166 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002167 * <p class="note">This is a protected intent that can only be sent
2168 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002169 */
2170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2171 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2172 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002173 * @hide
2174 * Broadcast Action: Ask system services if there is any reason to
2175 * restart the given package. The data contains the name of the
2176 * package.
2177 * <ul>
2178 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2179 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2180 * </ul>
2181 *
2182 * <p class="note">This is a protected intent that can only be sent
2183 * by the system.
2184 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002185 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002186 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2187 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2188 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002189 * Broadcast Action: The user has restarted a package, and all of its
2190 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002191 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002192 * be removed. Note that the restarted package does <em>not</em>
2193 * receive this broadcast.
2194 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002195 * <ul>
2196 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2197 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002198 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002199 * <p class="note">This is a protected intent that can only be sent
2200 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002201 */
2202 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2203 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2204 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002205 * Broadcast Action: The user has cleared the data of a package. This should
2206 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002207 * its persistent data is erased and this broadcast sent.
2208 * Note that the cleared package does <em>not</em>
2209 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002210 * <ul>
2211 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2212 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002213 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002214 * <p class="note">This is a protected intent that can only be sent
2215 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002216 */
2217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2218 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2219 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002220 * Broadcast Action: Packages have been suspended.
2221 * <p>Includes the following extras:
2222 * <ul>
2223 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2224 * </ul>
2225 *
2226 * <p class="note">This is a protected intent that can only be sent
2227 * by the system. It is only sent to registered receivers.
2228 */
2229 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2230 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2231 /**
2232 * Broadcast Action: Packages have been unsuspended.
2233 * <p>Includes the following extras:
2234 * <ul>
2235 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2236 * </ul>
2237 *
2238 * <p class="note">This is a protected intent that can only be sent
2239 * by the system. It is only sent to registered receivers.
2240 */
2241 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2242 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2243 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002244 * Broadcast Action: A user ID has been removed from the system. The user
2245 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002246 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002247 * <p class="note">This is a protected intent that can only be sent
2248 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002249 */
2250 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2251 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002252
2253 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002254 * Broadcast Action: Sent to the installer package of an application when
2255 * that application is first launched (that is the first time it is moved
2256 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002257 *
2258 * <p class="note">This is a protected intent that can only be sent
2259 * by the system.
2260 */
2261 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2262 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2263
2264 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002265 * Broadcast Action: Sent to the system package verifier when a package
2266 * needs to be verified. The data contains the package URI.
2267 * <p class="note">
2268 * This is a protected intent that can only be sent by the system.
2269 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002270 */
2271 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2272 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2273
2274 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002275 * Broadcast Action: Sent to the system package verifier when a package is
2276 * 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 */
2280 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2281 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2282
2283 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002284 * Broadcast Action: Sent to the system intent filter verifier when an
2285 * intent filter needs to be verified. The data contains the filter data
2286 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002287 * <p class="note">
2288 * This is a protected intent that can only be sent by the system.
2289 * </p>
2290 *
2291 * @hide
2292 */
2293 @SystemApi
2294 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2295 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2296
2297 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002298 * Broadcast Action: Resources for a set of packages (which were
2299 * previously unavailable) are currently
2300 * available since the media on which they exist is available.
2301 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2302 * list of packages whose availability changed.
2303 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2304 * list of uids of packages whose availability changed.
2305 * Note that the
2306 * packages in this list do <em>not</em> receive this broadcast.
2307 * The specified set of packages are now available on the system.
2308 * <p>Includes the following extras:
2309 * <ul>
2310 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2311 * whose resources(were previously unavailable) are currently available.
2312 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2313 * packages whose resources(were previously unavailable)
2314 * are currently available.
2315 * </ul>
2316 *
2317 * <p class="note">This is a protected intent that can only be sent
2318 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002319 */
2320 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002321 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2322 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002323
2324 /**
2325 * Broadcast Action: Resources for a set of packages are currently
2326 * unavailable since the media on which they exist is unavailable.
2327 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2328 * list of packages whose availability changed.
2329 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2330 * list of uids of packages whose availability changed.
2331 * The specified set of packages can no longer be
2332 * launched and are practically unavailable on the system.
2333 * <p>Inclues the following extras:
2334 * <ul>
2335 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2336 * whose resources are no longer available.
2337 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2338 * whose resources are no longer available.
2339 * </ul>
2340 *
2341 * <p class="note">This is a protected intent that can only be sent
2342 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002343 */
2344 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002345 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002346 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002347
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002348 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002349 * Broadcast Action: preferred activities have changed *explicitly*.
2350 *
2351 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2352 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2353 * be sent.
2354 *
2355 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2356 *
2357 * @hide
2358 */
2359 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2360 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2361 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2362
2363
2364 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002365 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002366 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002367 * This should <em>only</em> be used to determine when the wallpaper
2368 * has changed to show the new wallpaper to the user. You should certainly
2369 * never, in response to this, change the wallpaper or other attributes of
2370 * it such as the suggested size. That would be crazy, right? You'd cause
2371 * all kinds of loops, especially if other apps are doing similar things,
2372 * right? Of course. So please don't do this.
2373 *
2374 * @deprecated Modern applications should use
2375 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2376 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2377 * shown behind their UI, rather than watching for this broadcast and
2378 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002379 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002380 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002381 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2382 /**
2383 * Broadcast Action: The current device {@link android.content.res.Configuration}
2384 * (orientation, locale, etc) has changed. When such a change happens, the
2385 * UIs (view hierarchy) will need to be rebuilt based on this new
2386 * information; for the most part, applications don't need to worry about
2387 * this, because the system will take care of stopping and restarting the
2388 * application to make sure it sees the new changes. Some system code that
2389 * can not be restarted will need to watch for this action and handle it
2390 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002391 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002392 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002393 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002394 * in manifests, only by explicitly registering for it with
2395 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2396 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002397 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002398 * <p class="note">This is a protected intent that can only be sent
2399 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002400 *
2401 * @see android.content.res.Configuration
2402 */
2403 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2404 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2405 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002406 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002407 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002408 * <p class="note">This is a protected intent that can only be sent
2409 * by the system.
2410 */
2411 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2412 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2413 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002414 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2415 * charging state, level, and other information about the battery.
2416 * See {@link android.os.BatteryManager} for documentation on the
2417 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002418 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002419 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002420 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002421 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002422 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002423 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2424 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2425 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2426 * broadcasts that are sent and can be received through manifest
2427 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002428 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002429 * <p class="note">This is a protected intent that can only be sent
2430 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002431 */
2432 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2433 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2434 /**
2435 * Broadcast Action: Indicates low battery condition on the device.
2436 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002437 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002438 * <p class="note">This is a protected intent that can only be sent
2439 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002440 */
2441 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2442 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2443 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002444 * Broadcast Action: Indicates the battery is now okay after being low.
2445 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2446 * gone back up to an okay state.
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.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002450 */
2451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2452 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2453 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002454 * Broadcast Action: External power has been connected to the device.
2455 * This is intended for applications that wish to register specifically to this notification.
2456 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2457 * stay active to receive this notification. This action can be used to implement actions
2458 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002459 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002460 * <p class="note">This is a protected intent that can only be sent
2461 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002462 */
2463 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002464 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002465 /**
2466 * Broadcast Action: External power has been removed from the device.
2467 * This is intended for applications that wish to register specifically to this notification.
2468 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2469 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002470 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002471 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002472 * <p class="note">This is a protected intent that can only be sent
2473 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002474 */
2475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002476 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002477 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002478 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002479 * Broadcast Action: Device is shutting down.
2480 * This is broadcast when the device is being shut down (completely turned
2481 * off, not sleeping). Once the broadcast is complete, the final shutdown
2482 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002483 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002484 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002485 * <p class="note">This is a protected intent that can only be sent
2486 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002487 * <p>May include the following extras:
2488 * <ul>
2489 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2490 * shutdown is only for userspace processes. If not set, assumed to be false.
2491 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002492 */
2493 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002494 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002495 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002496 * Activity Action: Start this activity to request system shutdown.
2497 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002498 * to request confirmation from the user before shutting down. The optional boolean
2499 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2500 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002501 *
2502 * <p class="note">This is a protected intent that can only be sent
2503 * by the system.
2504 *
2505 * {@hide}
2506 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002507 public static final String ACTION_REQUEST_SHUTDOWN
2508 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002509 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002510 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002511 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002512 * <p class="note">
2513 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002514 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002515 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2516 * or above, this broadcast will no longer be delivered to any
2517 * {@link BroadcastReceiver} defined in your manifest. Instead,
2518 * apps are strongly encouraged to use the improved
2519 * {@link Context#getCacheDir()} behavior so the system can
2520 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002521 */
2522 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002523 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002524 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2525 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002526 * Broadcast Action: Indicates low storage space condition on the device no
2527 * longer exists
2528 * <p class="note">
2529 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002530 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002531 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2532 * or above, this broadcast will no longer be delivered to any
2533 * {@link BroadcastReceiver} defined in your manifest. Instead,
2534 * apps are strongly encouraged to use the improved
2535 * {@link Context#getCacheDir()} behavior so the system can
2536 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002537 */
2538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002539 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002540 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2541 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002542 * Broadcast Action: A sticky broadcast that indicates a storage space full
2543 * condition on the device. This is intended for activities that want to be
2544 * able to fill the data partition completely, leaving only enough free
2545 * space to prevent system-wide SQLite failures.
2546 * <p class="note">
2547 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002548 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002549 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2550 * or above, this broadcast will no longer be delivered to any
2551 * {@link BroadcastReceiver} defined in your manifest. Instead,
2552 * apps are strongly encouraged to use the improved
2553 * {@link Context#getCacheDir()} behavior so the system can
2554 * automatically free up storage when needed.
2555 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002556 */
2557 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002558 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002559 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2560 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002561 * Broadcast Action: Indicates storage space full condition on the device no
2562 * longer exists.
2563 * <p class="note">
2564 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002565 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002566 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2567 * or above, this broadcast will no longer be delivered to any
2568 * {@link BroadcastReceiver} defined in your manifest. Instead,
2569 * apps are strongly encouraged to use the improved
2570 * {@link Context#getCacheDir()} behavior so the system can
2571 * automatically free up storage when needed.
2572 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002573 */
2574 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002575 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002576 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2577 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002578 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2579 * and package management should be started.
2580 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2581 * notification.
2582 */
2583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2584 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2585 /**
2586 * Broadcast Action: The device has entered USB Mass Storage mode.
2587 * This is used mainly for the USB Settings panel.
2588 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2589 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002590 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002591 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002592 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002593 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2594
2595 /**
2596 * Broadcast Action: The device has exited 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
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002603 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2604
2605 /**
2606 * Broadcast Action: External media has been removed.
2607 * The path to the mount point for the removed media is contained in the Intent.mData field.
2608 */
2609 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2610 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2611
2612 /**
2613 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002614 * 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 -07002615 */
2616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2617 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2618
2619 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002620 * Broadcast Action: External media is present, and being disk-checked
2621 * 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 -08002622 */
2623 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2624 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2625
2626 /**
2627 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2628 * 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 -08002629 */
2630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2631 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2632
2633 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002634 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002635 * 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 -07002636 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2637 * media was mounted read only.
2638 */
2639 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2640 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2641
2642 /**
2643 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002644 * 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 -07002645 */
2646 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2647 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2648
2649 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002650 * Broadcast Action: External media is no longer being shared via USB mass storage.
2651 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2652 *
2653 * @hide
2654 */
2655 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2656
2657 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002658 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2659 * The path to the mount point for the removed media is contained in the Intent.mData field.
2660 */
2661 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2662 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2663
2664 /**
2665 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002666 * 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 -07002667 */
2668 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2669 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2670
2671 /**
2672 * Broadcast Action: User has expressed the desire to remove the external storage media.
2673 * Applications should close all files they have open within the mount point when they receive this intent.
2674 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2675 */
2676 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2677 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2678
2679 /**
2680 * Broadcast Action: The media scanner has started scanning a directory.
2681 * The path to the directory being scanned is contained in the Intent.mData field.
2682 */
2683 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2684 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2685
2686 /**
2687 * Broadcast Action: The media scanner has finished scanning a directory.
2688 * The path to the scanned directory is contained in the Intent.mData field.
2689 */
2690 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2691 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2692
2693 /**
2694 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2695 * The path to the file is contained in the Intent.mData field.
2696 */
2697 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2698 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2699
2700 /**
2701 * Broadcast Action: The "Media Button" was pressed. Includes a single
2702 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2703 * caused the broadcast.
2704 */
2705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2706 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2707
2708 /**
2709 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2710 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2711 * caused the broadcast.
2712 */
2713 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2714 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2715
2716 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2717 // location; they are not general-purpose actions.
2718
2719 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002720 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002721 */
2722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2723 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2724 "android.intent.action.GTALK_CONNECTED";
2725
2726 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002727 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002728 */
2729 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2730 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2731 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002732
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002733 /**
2734 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002735 */
2736 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2737 public static final String ACTION_INPUT_METHOD_CHANGED =
2738 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002739
2740 /**
2741 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2742 * more radios have been turned off or on. The intent will have the following extra value:</p>
2743 * <ul>
2744 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2745 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2746 * turned off</li>
2747 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002748 *
Peng Xua35b5532016-01-20 00:05:45 -08002749 * <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 -07002750 */
2751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2752 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2753
2754 /**
2755 * Broadcast Action: Some content providers have parts of their namespace
2756 * where they publish new events or items that the user may be especially
2757 * interested in. For these things, they may broadcast this action when the
2758 * set of interesting items change.
2759 *
2760 * For example, GmailProvider sends this notification when the set of unread
2761 * mail in the inbox changes.
2762 *
2763 * <p>The data of the intent identifies which part of which provider
2764 * changed. When queried through the content resolver, the data URI will
2765 * return the data set in question.
2766 *
2767 * <p>The intent will have the following extra values:
2768 * <ul>
2769 * <li><em>count</em> - The number of items in the data set. This is the
2770 * same as the number of items in the cursor returned by querying the
2771 * data URI. </li>
2772 * </ul>
2773 *
2774 * This intent will be sent at boot (if the count is non-zero) and when the
2775 * data set changes. It is possible for the data set to change without the
2776 * count changing (for example, if a new unread message arrives in the same
2777 * sync operation in which a message is archived). The phone should still
2778 * ring/vibrate/etc as normal in this case.
2779 */
2780 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2781 public static final String ACTION_PROVIDER_CHANGED =
2782 "android.intent.action.PROVIDER_CHANGED";
2783
2784 /**
2785 * Broadcast Action: Wired Headset plugged in or unplugged.
2786 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002787 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2788 * and documentation.
2789 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002790 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002791 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002792 */
2793 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002794 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002795
2796 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002797 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2798 * <ul>
2799 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2800 * </ul>
2801 *
2802 * <p class="note">This is a protected intent that can only be sent
2803 * by the system.
2804 *
2805 * @hide
2806 */
2807 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2808 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2809 = "android.intent.action.ADVANCED_SETTINGS";
2810
2811 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002812 * Broadcast Action: Sent after application restrictions are changed.
2813 *
2814 * <p class="note">This is a protected intent that can only be sent
2815 * by the system.</p>
2816 */
2817 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2818 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2819 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2820
2821 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002822 * Broadcast Action: An outgoing call is about to be placed.
2823 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002824 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002825 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002826 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002827 * the phone number originally intended to be dialed.</li>
2828 * </ul>
2829 * <p>Once the broadcast is finished, the resultData is used as the actual
2830 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002831 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002832 * outgoing call in turn: for example, a parental control application
2833 * might verify that the user is authorized to place the call at that
2834 * time, then a number-rewriting application might add an area code if
2835 * one was not specified.</p>
2836 * <p>For consistency, any receiver whose purpose is to prohibit phone
2837 * calls should have a priority of 0, to ensure it will see the final
2838 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002839 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002840 * should have a positive priority.
2841 * Negative priorities are reserved for the system for this broadcast;
2842 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002843 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2844 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002845 * <p>Emergency calls cannot be intercepted using this mechanism, and
2846 * other calls cannot be modified to call emergency numbers using this
2847 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002848 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2849 * call to use their own service instead. Those apps should first prevent
2850 * the call from being placed by setting resultData to <code>null</code>
2851 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002852 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002853 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2854 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002855 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002856 * <p class="note">This is a protected intent that can only be sent
2857 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002858 */
2859 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2860 public static final String ACTION_NEW_OUTGOING_CALL =
2861 "android.intent.action.NEW_OUTGOING_CALL";
2862
2863 /**
2864 * Broadcast Action: Have the device reboot. This is only for use by
2865 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002866 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002867 * <p class="note">This is a protected intent that can only be sent
2868 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002869 */
2870 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2871 public static final String ACTION_REBOOT =
2872 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002873
Wei Huang97ecc9c2009-05-11 17:44:20 -07002874 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002875 * Broadcast Action: A sticky broadcast for changes in the physical
2876 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002877 *
2878 * <p>The intent will have the following extra values:
2879 * <ul>
2880 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002881 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002882 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002883 * <p>This is intended for monitoring the current physical dock state.
2884 * See {@link android.app.UiModeManager} for the normal API dealing with
2885 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002886 */
2887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2888 public static final String ACTION_DOCK_EVENT =
2889 "android.intent.action.DOCK_EVENT";
2890
2891 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002892 * Broadcast Action: A broadcast when idle maintenance can be started.
2893 * This means that the user is not interacting with the device and is
2894 * not expected to do so soon. Typical use of the idle maintenance is
2895 * to perform somehow expensive tasks that can be postponed at a moment
2896 * when they will not degrade user experience.
2897 * <p>
2898 * <p class="note">In order to keep the device responsive in case of an
2899 * unexpected user interaction, implementations of a maintenance task
2900 * should be interruptible. In such a scenario a broadcast with action
2901 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2902 * should not do the maintenance work in
2903 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2904 * maintenance service by {@link Context#startService(Intent)}. Also
2905 * you should hold a wake lock while your maintenance service is running
2906 * to prevent the device going to sleep.
2907 * </p>
2908 * <p>
2909 * <p class="note">This is a protected intent that can only be sent by
2910 * the system.
2911 * </p>
2912 *
2913 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002914 *
2915 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002916 */
2917 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2918 public static final String ACTION_IDLE_MAINTENANCE_START =
2919 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2920
2921 /**
2922 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2923 * This means that the user was not interacting with the device as a result
2924 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2925 * was sent and now the user started interacting with the device. Typical
2926 * use of the idle maintenance is to perform somehow expensive tasks that
2927 * can be postponed at a moment when they will not degrade user experience.
2928 * <p>
2929 * <p class="note">In order to keep the device responsive in case of an
2930 * unexpected user interaction, implementations of a maintenance task
2931 * should be interruptible. Hence, on receiving a broadcast with this
2932 * action, the maintenance task should be interrupted as soon as possible.
2933 * In other words, you should not do the maintenance work in
2934 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2935 * maintenance service that was started on receiving of
2936 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2937 * lock you acquired when your maintenance service started.
2938 * </p>
2939 * <p class="note">This is a protected intent that can only be sent
2940 * by the system.
2941 *
2942 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002943 *
2944 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002945 */
2946 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2947 public static final String ACTION_IDLE_MAINTENANCE_END =
2948 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2949
2950 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002951 * Broadcast Action: a remote intent is to be broadcasted.
2952 *
2953 * A remote intent is used for remote RPC between devices. The remote intent
2954 * is serialized and sent from one device to another device. The receiving
2955 * device parses the remote intent and broadcasts it. Note that anyone can
2956 * broadcast a remote intent. However, if the intent receiver of the remote intent
2957 * does not trust intent broadcasts from arbitrary intent senders, it should require
2958 * the sender to hold certain permissions so only trusted sender's broadcast will be
2959 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002960 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002961 */
2962 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002963 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002964
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002965 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002966 * Broadcast Action: This is broadcast once when the user is booting after a
2967 * system update. It can be used to perform cleanup or upgrades after a
2968 * system update.
2969 * <p>
2970 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2971 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2972 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2973 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002974 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002975 * @hide
2976 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002977 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002978 public static final String ACTION_PRE_BOOT_COMPLETED =
2979 "android.intent.action.PRE_BOOT_COMPLETED";
2980
Amith Yamasani13593602012-03-22 16:16:17 -07002981 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002982 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002983 * on restricted users. The broadcast intent contains an extra
2984 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2985 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2986 * String[] depending on the restriction type.<p/>
2987 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002988 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2989 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2990 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002991 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2992 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002993 * @see RestrictionEntry
2994 */
2995 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2996 "android.intent.action.GET_RESTRICTION_ENTRIES";
2997
2998 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002999 * Sent the first time a user is starting, to allow system apps to
3000 * perform one time initialization. (This will not be seen by third
3001 * party applications because a newly initialized user does not have any
3002 * third party applications installed for it.) This is sent early in
3003 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003004 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3005 * broadcast, since it is part of a visible user interaction; be as quick
3006 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003007 */
3008 public static final String ACTION_USER_INITIALIZE =
3009 "android.intent.action.USER_INITIALIZE";
3010
3011 /**
3012 * Sent when a user switch is happening, causing the process's user to be
3013 * brought to the foreground. This is only sent to receivers registered
3014 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3015 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003016 * foreground. 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_FOREGROUND =
3021 "android.intent.action.USER_FOREGROUND";
3022
3023 /**
3024 * Sent when a user switch is happening, causing the process's user to be
3025 * sent to the background. 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 * background. 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_BACKGROUND =
3033 "android.intent.action.USER_BACKGROUND";
3034
3035 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003036 * Broadcast sent to the system when a user is added. Carries an extra
3037 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3038 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003039 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003040 * @hide
3041 */
3042 public static final String ACTION_USER_ADDED =
3043 "android.intent.action.USER_ADDED";
3044
3045 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003046 * Broadcast sent by the system when a user is started. Carries an extra
3047 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003048 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003049 * that has been started. This is sent as a foreground
3050 * broadcast, since it is part of a visible user interaction; be as quick
3051 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003052 * @hide
3053 */
3054 public static final String ACTION_USER_STARTED =
3055 "android.intent.action.USER_STARTED";
3056
3057 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003058 * Broadcast sent when a user is in the process of starting. Carries an extra
3059 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3060 * sent to registered receivers, not manifest receivers. It is sent to all
3061 * users (including the one that is being started). You must hold
3062 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3063 * this broadcast. This is sent as a background broadcast, since
3064 * its result is not part of the primary UX flow; to safely keep track of
3065 * started/stopped state of a user you can use this in conjunction with
3066 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3067 * other user state broadcasts since those are foreground broadcasts so can
3068 * execute in a different order.
3069 * @hide
3070 */
3071 public static final String ACTION_USER_STARTING =
3072 "android.intent.action.USER_STARTING";
3073
3074 /**
3075 * Broadcast sent when a user is going to be stopped. Carries an extra
3076 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3077 * sent to registered receivers, not manifest receivers. It is sent to all
3078 * users (including the one that is being stopped). You must hold
3079 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3080 * this broadcast. The user will not stop until all receivers have
3081 * handled the broadcast. This is sent as a background broadcast, since
3082 * its result is not part of the primary UX flow; to safely keep track of
3083 * started/stopped state of a user you can use this in conjunction with
3084 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3085 * other user state broadcasts since those are foreground broadcasts so can
3086 * execute in a different order.
3087 * @hide
3088 */
3089 public static final String ACTION_USER_STOPPING =
3090 "android.intent.action.USER_STOPPING";
3091
3092 /**
3093 * Broadcast sent to the system when a user is stopped. Carries an extra
3094 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3095 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3096 * specific package. This is only sent to registered receivers, not manifest
3097 * receivers. It is sent to all running users <em>except</em> the one that
3098 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003099 * @hide
3100 */
3101 public static final String ACTION_USER_STOPPED =
3102 "android.intent.action.USER_STOPPED";
3103
3104 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003105 * 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 -07003106 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003107 * one that has been removed. The user will not be completely removed until all receivers have
3108 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003109 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003110 * @hide
3111 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003112 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003113 public static final String ACTION_USER_REMOVED =
3114 "android.intent.action.USER_REMOVED";
3115
3116 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003117 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003118 * the userHandle of the user to become the current one. This is only sent to
3119 * registered receivers, not manifest receivers. It is sent to all running users.
3120 * You must hold
3121 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003122 * @hide
3123 */
3124 public static final String ACTION_USER_SWITCHED =
3125 "android.intent.action.USER_SWITCHED";
3126
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003127 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003128 * Broadcast Action: Sent when the credential-encrypted private storage has
3129 * become unlocked for the target user. This is only sent to registered
3130 * receivers, not manifest receivers.
3131 */
3132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3133 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3134
3135 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003136 * Broadcast sent to the system when a user's information changes. Carries an extra
3137 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003138 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003139 * @hide
3140 */
3141 public static final String ACTION_USER_INFO_CHANGED =
3142 "android.intent.action.USER_INFO_CHANGED";
3143
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003144 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003145 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3146 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003147 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3148 * that need to display merged content across both primary and managed profiles need to
3149 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003150 * not manifest receivers.
3151 */
3152 public static final String ACTION_MANAGED_PROFILE_ADDED =
3153 "android.intent.action.MANAGED_PROFILE_ADDED";
3154
3155 /**
3156 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003157 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3158 * Only applications (for example Launchers) that need to display merged content across both
3159 * primary and managed profiles need to worry about this broadcast. This is only sent to
3160 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003161 */
3162 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3163 "android.intent.action.MANAGED_PROFILE_REMOVED";
3164
3165 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003166 * Broadcast sent to the primary user when the credential-encrypted private storage for
3167 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3168 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3169 * Launchers) that need to display merged content across both primary and managed profiles
3170 * need to worry about this broadcast. This is only sent to registered receivers,
3171 * not manifest receivers.
3172 */
3173 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3174 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3175
3176 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003177 * Broadcast sent to the primary user when an associated managed profile has become available.
3178 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003179 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3180 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3181 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003182 */
Rubin Xue95057a2016-04-01 16:49:25 +01003183 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3184 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3185
3186 /**
3187 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3188 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3189 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3190 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3191 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3192 */
3193 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3194 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003195
3196 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003197 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3198 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3199 * the device was locked or unlocked.
3200 *
3201 * This is only sent to registered receivers.
3202 *
3203 * @hide
3204 */
3205 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3206 "android.intent.action.DEVICE_LOCKED_CHANGED";
3207
3208 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003209 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3210 */
3211 public static final String ACTION_QUICK_CLOCK =
3212 "android.intent.action.QUICK_CLOCK";
3213
Michael Wright0087a142013-02-05 16:29:39 -08003214 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003215 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003216 * @hide
3217 */
3218 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003219 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003220
Justin Kohd378ad72013-04-01 12:18:26 -07003221 /**
3222 * Broadcast Action: A global button was pressed. Includes a single
3223 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3224 * caused the broadcast.
3225 * @hide
3226 */
3227 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3228
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003229 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003230 * Broadcast Action: Sent when media resource is granted.
3231 * <p>
3232 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3233 * granted.
3234 * </p>
3235 * <p class="note">
3236 * This is a protected intent that can only be sent by the system.
3237 * </p>
3238 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003239 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003240 * </p>
3241 *
3242 * @hide
3243 */
3244 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3245 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3246
3247 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003248 * Broadcast Action: An overlay package has changed. The data contains the
3249 * name of the overlay package which has changed. This is broadcast on all
3250 * changes to the OverlayInfo returned by {@link
3251 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3252 * most common change is a state change that will change whether the
3253 * overlay is enabled or not.
3254 * @hide
3255 */
3256 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3257
3258 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003259 * Activity Action: Allow the user to select and return one or more existing
3260 * documents. When invoked, the system will display the various
3261 * {@link DocumentsProvider} instances installed on the device, letting the
3262 * user interactively navigate through them. These documents include local
3263 * media, such as photos and video, and documents provided by installed
3264 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003265 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003266 * Each document is represented as a {@code content://} URI backed by a
3267 * {@link DocumentsProvider}, which can be opened as a stream with
3268 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3269 * {@link android.provider.DocumentsContract.Document} metadata.
3270 * <p>
3271 * All selected documents are returned to the calling application with
3272 * persistable read and write permission grants. If you want to maintain
3273 * access to the documents across device reboots, you need to explicitly
3274 * take the persistable permissions using
3275 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3276 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003277 * Callers must indicate the acceptable document MIME types through
3278 * {@link #setType(String)}. For example, to select photos, use
3279 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3280 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3281 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003282 * <p>
3283 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003284 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3285 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003286 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003287 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3288 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003289 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003290 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003291 * Callers can set a document URI through
3292 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3293 * location of documents navigator. System will do its best to launch the
3294 * navigator in the specified document if it's a folder, or the folder that
3295 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003296 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003297 * Output: The URI of the item that was picked, returned in
3298 * {@link #getData()}. This must be a {@code content://} URI so that any
3299 * receiver can access it. If multiple documents were selected, they are
3300 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003301 *
3302 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003303 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003304 * @see #ACTION_CREATE_DOCUMENT
3305 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003306 */
3307 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3308 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3309
3310 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003311 * Activity Action: Allow the user to create a new document. When invoked,
3312 * the system will display the various {@link DocumentsProvider} instances
3313 * installed on the device, letting the user navigate through them. The
3314 * returned document may be a newly created document with no content, or it
3315 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003316 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003317 * Each document is represented as a {@code content://} URI backed by a
3318 * {@link DocumentsProvider}, which can be opened as a stream with
3319 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3320 * {@link android.provider.DocumentsContract.Document} metadata.
3321 * <p>
3322 * Callers must indicate the concrete MIME type of the document being
3323 * created by setting {@link #setType(String)}. This MIME type cannot be
3324 * changed after the document is created.
3325 * <p>
3326 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3327 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003328 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003329 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3330 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003331 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003332 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003333 * Callers can set a document URI through
3334 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3335 * location of documents navigator. System will do its best to launch the
3336 * navigator in the specified document if it's a folder, or the folder that
3337 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003338 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003339 * Output: The URI of the item that was created. This must be a
3340 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003341 *
3342 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003343 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003344 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003345 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003346 */
3347 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3348 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3349
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003350 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003351 * Activity Action: Allow the user to pick a directory subtree. When
3352 * invoked, the system will display the various {@link DocumentsProvider}
3353 * instances installed on the device, letting the user navigate through
3354 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003355 * <p>
3356 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003357 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3358 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3359 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003360 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003361 * Callers can set a document URI through
3362 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3363 * location of documents navigator. System will do its best to launch the
3364 * navigator in the specified document if it's a folder, or the folder that
3365 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003366 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003367 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003368 *
3369 * @see DocumentsContract
3370 */
3371 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003372 public static final String
3373 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003374
Felipe Lemec7b1f892016-01-15 15:02:31 -08003375 /**
Peng Xua35b5532016-01-20 00:05:45 -08003376 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3377 * exisiting sensor being disconnected.
3378 *
3379 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3380 *
3381 * {@hide}
3382 */
3383 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3384 public static final String
3385 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3386
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003387 /**
Sanket Padawe2c1a49f2017-03-31 12:39:50 -07003388 * Broadcast Action: The default subscription has changed. This has the following
3389 * extra values:</p>
3390 * The {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default subscription index
3391 */
3392 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3393 public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED
3394 = "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED";
3395
3396 /**
3397 * Broadcast Action: The default sms subscription has changed. This has the following
3398 * extra values:</p>
3399 * {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default sms
3400 * subscription index
3401 */
3402 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3403 public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
3404 = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
3405
3406 /**
3407 * Integer extra used with {@link #ACTION_DEFAULT_SUBSCRIPTION_CHANGED} and
3408 * {@link #ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED} to indicate the subscription
3409 * which has changed.
3410 */
3411 public static final String EXTRA_SUBSCRIPTION_INDEX = "android.intent.extra.SUBSCRIPTION_INDEX";
3412
3413 /**
Sam Line707f832017-04-13 17:00:55 -07003414 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003415 * @hide
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003416 */
3417 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003418 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003419 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3420
Christopher Tate6597e342015-02-17 12:15:25 -08003421 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003422 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3423 * is about to be performed.
3424 * @hide
3425 */
3426 @SystemApi
3427 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3428 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3429 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3430
3431 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003432 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3433 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3434 *
3435 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3436 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003437 * @hide
3438 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003439 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003440 public static final String EXTRA_FORCE_MASTER_CLEAR =
3441 "android.intent.extra.FORCE_MASTER_CLEAR";
3442
3443 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003444 * A broadcast action to trigger a factory reset.
3445 *
3446 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3447 *
3448 * <p>Not for use by third-party applications.
3449 *
3450 * @see #EXTRA_FORCE_MASTER_CLEAR
3451 *
3452 * {@hide}
3453 */
3454 @SystemApi
3455 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3456 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3457
3458 /**
3459 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3460 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3461 *
3462 * <p>Not for use by third-party applications.
3463 *
3464 * @hide
3465 */
3466 @SystemApi
3467 public static final String EXTRA_FORCE_FACTORY_RESET =
3468 "android.intent.extra.FORCE_FACTORY_RESET";
3469
3470 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003471 * Broadcast action: report that a settings element is being restored from backup. The intent
3472 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3473 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3474 * is the value of that settings entry prior to the restore operation. All of these values are
3475 * represented as strings.
3476 *
3477 * <p>This broadcast is sent only for settings provider entries known to require special handling
3478 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3479 * the provider's backup agent implementation.
3480 *
3481 * @see #EXTRA_SETTING_NAME
3482 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3483 * @see #EXTRA_SETTING_NEW_VALUE
3484 * {@hide}
3485 */
3486 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3487
3488 /** {@hide} */
3489 public static final String EXTRA_SETTING_NAME = "setting_name";
3490 /** {@hide} */
3491 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3492 /** {@hide} */
3493 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3494
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003495 /**
3496 * Activity Action: Process a piece of text.
3497 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3498 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3499 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3500 */
3501 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3502 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003503
3504 /**
3505 * Broadcast Action: The sim card state has changed.
3506 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3507 * because TelephonyIntents is an internal class.
3508 * @hide
3509 */
3510 @SystemApi
3511 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3512 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3513
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003514 /**
fionaxu90fee272017-03-31 12:45:12 -07003515 * Broadcast Action: indicate that the phone service state has changed.
3516 * The intent will have the following extra values:</p>
3517 * <p>
3518 * @see #EXTRA_VOICE_REG_STATE
3519 * @see #EXTRA_DATA_REG_STATE
3520 * @see #EXTRA_VOICE_ROAMING_TYPE
3521 * @see #EXTRA_DATA_ROAMING_TYPE
3522 * @see #EXTRA_OPERATOR_ALPHA_LONG
3523 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3524 * @see #EXTRA_OPERATOR_NUMERIC
3525 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3526 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3527 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3528 * @see #EXTRA_MANUAL
3529 * @see #EXTRA_VOICE_RADIO_TECH
3530 * @see #EXTRA_DATA_RADIO_TECH
3531 * @see #EXTRA_CSS_INDICATOR
3532 * @see #EXTRA_NETWORK_ID
3533 * @see #EXTRA_SYSTEM_ID
3534 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3535 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3536 * @see #EXTRA_EMERGENCY_ONLY
3537 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3538 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3539 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3540 *
3541 * <p class="note">
3542 * Requires the READ_PHONE_STATE permission.
3543 *
3544 * <p class="note">This is a protected intent that can only be sent by the system.
3545 * @hide
3546 */
3547 @Deprecated
3548 @SystemApi
3549 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3550 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3551
3552 /**
3553 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3554 * state.
3555 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3556 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3557 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3558 * @see android.telephony.ServiceState#STATE_POWER_OFF
3559 * @hide
3560 */
3561 @Deprecated
3562 @SystemApi
3563 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3564
3565 /**
3566 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3567 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3568 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3569 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3570 * @see android.telephony.ServiceState#STATE_POWER_OFF
3571 * @hide
3572 */
3573 @Deprecated
3574 @SystemApi
3575 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3576
3577 /**
3578 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3579 * type.
3580 * @hide
3581 */
3582 @Deprecated
3583 @SystemApi
3584 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3585
3586 /**
3587 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3588 * type.
3589 * @hide
3590 */
3591 @Deprecated
3592 @SystemApi
3593 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3594
3595 /**
3596 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3597 * registered voice operator name in long alphanumeric format.
3598 * {@code null} if the operator name is not known or unregistered.
3599 * @hide
3600 */
3601 @Deprecated
3602 @SystemApi
3603 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3604
3605 /**
3606 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3607 * registered voice operator name in short alphanumeric format.
3608 * {@code null} if the operator name is not known or unregistered.
3609 * @hide
3610 */
3611 @Deprecated
3612 @SystemApi
3613 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3614
3615 /**
3616 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3617 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3618 * network.
3619 * @hide
3620 */
3621 @Deprecated
3622 @SystemApi
3623 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3624
3625 /**
3626 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3627 * registered data operator name in long alphanumeric format.
3628 * {@code null} if the operator name is not known or unregistered.
3629 * @hide
3630 */
3631 @Deprecated
3632 @SystemApi
3633 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3634
3635 /**
3636 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3637 * registered data operator name in short alphanumeric format.
3638 * {@code null} if the operator name is not known or unregistered.
3639 * @hide
3640 */
3641 @Deprecated
3642 @SystemApi
3643 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3644
3645 /**
3646 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3647 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3648 * data operator.
3649 * @hide
3650 */
3651 @Deprecated
3652 @SystemApi
3653 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3654
3655 /**
3656 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3657 * network selection mode is manual.
3658 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3659 * @hide
3660 */
3661 @Deprecated
3662 @SystemApi
3663 public static final String EXTRA_MANUAL = "manual";
3664
3665 /**
3666 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3667 * radio technology.
3668 * @hide
3669 */
3670 @Deprecated
3671 @SystemApi
3672 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3673
3674 /**
3675 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3676 * radio technology.
3677 * @hide
3678 */
3679 @Deprecated
3680 @SystemApi
3681 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3682
3683 /**
3684 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3685 * support on CDMA network.
3686 * Will be {@code true} if support, {@code false} otherwise.
3687 * @hide
3688 */
3689 @Deprecated
3690 @SystemApi
3691 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3692
3693 /**
3694 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3695 * id. {@code Integer.MAX_VALUE} if unknown.
3696 * @hide
3697 */
3698 @Deprecated
3699 @SystemApi
3700 public static final String EXTRA_NETWORK_ID = "networkId";
3701
3702 /**
3703 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3704 * {@code Integer.MAX_VALUE} if unknown.
3705 * @hide
3706 */
3707 @Deprecated
3708 @SystemApi
3709 public static final String EXTRA_SYSTEM_ID = "systemId";
3710
3711 /**
3712 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3713 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3714 * @hide
3715 */
3716 @Deprecated
3717 @SystemApi
3718 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3719
3720 /**
3721 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3722 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3723 * @hide
3724 */
3725 @Deprecated
3726 @SystemApi
3727 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3728
3729 /**
3730 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3731 * only mode.
3732 * {@code true} if in emergency only mode, {@code false} otherwise.
3733 * @hide
3734 */
3735 @Deprecated
3736 @SystemApi
3737 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3738
3739 /**
3740 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3741 * registration state is roaming.
3742 * {@code true} if registration indicates roaming, {@code false} otherwise
3743 * @hide
3744 */
3745 @Deprecated
3746 @SystemApi
3747 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3748 "isDataRoamingFromRegistration";
3749
3750 /**
3751 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3752 * aggregation is in use.
3753 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3754 * @hide
3755 */
3756 @Deprecated
3757 @SystemApi
3758 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3759
3760 /**
3761 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3762 * is reduced from the rsrp threshold while calculating signal strength level.
3763 * @hide
3764 */
3765 @Deprecated
3766 @SystemApi
3767 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3768
3769 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003770 * The name of the extra used to define the text to be processed, as a
3771 * CharSequence. Note that this may be a styled CharSequence, so you must use
3772 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003773 */
3774 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3775 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003776 * 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 +00003777 */
3778 public static final String EXTRA_PROCESS_TEXT_READONLY =
3779 "android.intent.extra.PROCESS_TEXT_READONLY";
3780
Bryce Leebc58f592015-09-25 16:43:01 -07003781 /**
3782 * Broadcast action: reports when a new thermal event has been reached. When the device
3783 * is reaching its maximum temperatue, the thermal level reported
3784 * {@hide}
3785 */
3786 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3787 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3788
3789 /** {@hide} */
3790 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3791
3792 /**
3793 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003794 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003795 * {@hide}
3796 */
3797 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3798
3799 /**
3800 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003801 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003802 * {@hide}
3803 */
3804 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3805
3806 /**
3807 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003808 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003809 * {@hide}
3810 */
3811 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3812
3813
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003814 // ---------------------------------------------------------------------
3815 // ---------------------------------------------------------------------
3816 // Standard intent categories (see addCategory()).
3817
3818 /**
3819 * Set if the activity should be an option for the default action
3820 * (center press) to perform on a piece of data. Setting this will
3821 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003822 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003823 * Intent when initiating an action -- it is for use in intent filters
3824 * specified in packages.
3825 */
3826 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3827 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3828 /**
3829 * Activities that can be safely invoked from a browser must support this
3830 * category. For example, if the user is viewing a web page or an e-mail
3831 * and clicks on a link in the text, the Intent generated execute that
3832 * link will require the BROWSABLE category, so that only activities
3833 * supporting this category will be considered as possible actions. By
3834 * supporting this category, you are promising that there is nothing
3835 * damaging (without user intervention) that can happen by invoking any
3836 * matching Intent.
3837 */
3838 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3839 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3840 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003841 * Categories for activities that can participate in voice interaction.
3842 * An activity that supports this category must be prepared to run with
3843 * no UI shown at all (though in some case it may have a UI shown), and
3844 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3845 */
3846 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3847 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3848 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003849 * Set if the activity should be considered as an alternative action to
3850 * the data the user is currently viewing. See also
3851 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3852 * applies to the selection in a list of items.
3853 *
3854 * <p>Supporting this category means that you would like your activity to be
3855 * displayed in the set of alternative things the user can do, usually as
3856 * part of the current activity's options menu. You will usually want to
3857 * include a specific label in the &lt;intent-filter&gt; of this action
3858 * describing to the user what it does.
3859 *
3860 * <p>The action of IntentFilter with this category is important in that it
3861 * describes the specific action the target will perform. This generally
3862 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3863 * a specific name such as "com.android.camera.action.CROP. Only one
3864 * alternative of any particular action will be shown to the user, so using
3865 * a specific action like this makes sure that your alternative will be
3866 * displayed while also allowing other applications to provide their own
3867 * overrides of that particular action.
3868 */
3869 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3870 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3871 /**
3872 * Set if the activity should be considered as an alternative selection
3873 * action to the data the user has currently selected. This is like
3874 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3875 * of items from which the user can select, giving them alternatives to the
3876 * default action that will be performed on it.
3877 */
3878 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3879 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3880 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003881 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003882 */
3883 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3884 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3885 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003886 * Should be displayed in the top-level launcher.
3887 */
3888 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3889 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3890 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003891 * Indicates an activity optimized for Leanback mode, and that should
3892 * be displayed in the Leanback launcher.
3893 */
3894 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3895 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3896 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003897 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3898 * @hide
3899 */
3900 @SystemApi
3901 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3902 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003903 * Provides information about the package it is in; typically used if
3904 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3905 * a front-door to the user without having to be shown in the all apps list.
3906 */
3907 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3908 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3909 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003910 * This is the home activity, that is the first activity that is displayed
3911 * when the device boots.
3912 */
3913 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3914 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3915 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003916 * This is the home activity that is displayed when the device is finished setting up and ready
3917 * for use.
3918 * @hide
3919 */
3920 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3921 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3922 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003923 * This is the setup wizard activity, that is the first activity that is displayed
3924 * when the user sets up the device for the first time.
3925 * @hide
3926 */
3927 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3928 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3929 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003930 * This activity is a preference panel.
3931 */
3932 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3933 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3934 /**
3935 * This activity is a development preference panel.
3936 */
3937 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3938 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3939 /**
3940 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003941 */
3942 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3943 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3944 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003945 * This activity allows the user to browse and download new applications.
3946 */
3947 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3948 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3949 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003950 * This activity may be exercised by the monkey or other automated test tools.
3951 */
3952 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3953 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3954 /**
3955 * To be used as a test (not part of the normal user experience).
3956 */
3957 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3958 /**
3959 * To be used as a unit test (run through the Test Harness).
3960 */
3961 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3962 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003963 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003964 * experience).
3965 */
3966 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003967
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003968 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003969 * Used to indicate that an intent only wants URIs that can be opened with
3970 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3971 * must support at least the columns defined in {@link OpenableColumns} when
3972 * queried.
3973 *
3974 * @see #ACTION_GET_CONTENT
3975 * @see #ACTION_OPEN_DOCUMENT
3976 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003977 */
3978 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3979 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3980
3981 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003982 * Used to indicate that an intent filter can accept files which are not necessarily
3983 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3984 * at least streamable via
3985 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3986 * using one of the stream types exposed via
3987 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3988 *
3989 * @see #ACTION_SEND
3990 * @see #ACTION_SEND_MULTIPLE
3991 */
3992 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3993 public static final String CATEGORY_TYPED_OPENABLE =
3994 "android.intent.category.TYPED_OPENABLE";
3995
3996 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003997 * To be used as code under test for framework instrumentation tests.
3998 */
3999 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4000 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004001 /**
4002 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004003 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4004 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004005 */
4006 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4007 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4008 /**
4009 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004010 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4011 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004012 */
4013 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4014 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004015 /**
4016 * An activity to run when device is inserted into a analog (low end) dock.
4017 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4018 * information, see {@link android.app.UiModeManager}.
4019 */
4020 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4021 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4022
4023 /**
4024 * An activity to run when device is inserted into a digital (high end) dock.
4025 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4026 * information, see {@link android.app.UiModeManager}.
4027 */
4028 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4029 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004030
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004031 /**
4032 * Used to indicate that the activity can be used in a car environment.
4033 */
4034 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4035 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4036
Zak Cohendb6ca492017-01-26 14:09:00 -08004037 /**
4038 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4039 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4040 * information, see {@link android.app.UiModeManager}.
4041 */
4042 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4043 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004044 // ---------------------------------------------------------------------
4045 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004046 // Application launch intent categories (see addCategory()).
4047
4048 /**
4049 * Used with {@link #ACTION_MAIN} to launch the browser application.
4050 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004051 * <p>NOTE: This should not be used as the primary key of an Intent,
4052 * since it will not result in the app launching with the correct
4053 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004054 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004055 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004056 */
4057 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4058 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4059
4060 /**
4061 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4062 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004063 * <p>NOTE: This should not be used as the primary key of an Intent,
4064 * since it will not result in the app launching with the correct
4065 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004066 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004067 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004068 */
4069 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4070 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4071
4072 /**
4073 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4074 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004075 * <p>NOTE: This should not be used as the primary key of an Intent,
4076 * since it will not result in the app launching with the correct
4077 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004078 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004079 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004080 */
4081 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4082 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4083
4084 /**
4085 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4086 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004087 * <p>NOTE: This should not be used as the primary key of an Intent,
4088 * since it will not result in the app launching with the correct
4089 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004090 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004091 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004092 */
4093 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4094 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4095
4096 /**
4097 * Used with {@link #ACTION_MAIN} to launch the email application.
4098 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004099 * <p>NOTE: This should not be used as the primary key of an Intent,
4100 * since it will not result in the app launching with the correct
4101 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004102 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004103 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004104 */
4105 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4106 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4107
4108 /**
4109 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4110 * The activity should be able to view and manipulate image and video files
4111 * stored on the device.
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_GALLERY = "android.intent.category.APP_GALLERY";
4120
4121 /**
4122 * Used with {@link #ACTION_MAIN} to launch the maps application.
4123 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004124 * <p>NOTE: This should not be used as the primary key of an Intent,
4125 * since it will not result in the app launching with the correct
4126 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004127 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004128 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004129 */
4130 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4131 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4132
4133 /**
4134 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4135 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004136 * <p>NOTE: This should not be used as the primary key of an Intent,
4137 * since it will not result in the app launching with the correct
4138 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004139 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004140 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004141 */
4142 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4143 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4144
4145 /**
4146 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004147 * The activity should be able to play, browse, or manipulate music files
4148 * stored on the device.
4149 * <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_MUSIC = "android.intent.category.APP_MUSIC";
4157
4158 // ---------------------------------------------------------------------
4159 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004160 // Standard extra data keys.
4161
4162 /**
4163 * The initial data to place in a newly created record. Use with
4164 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4165 * fields as would be given to the underlying ContentProvider.insert()
4166 * call.
4167 */
4168 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4169
4170 /**
4171 * A constant CharSequence that is associated with the Intent, used with
4172 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4173 * this may be a styled CharSequence, so you must use
4174 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4175 * retrieve it.
4176 */
4177 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4178
4179 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004180 * A constant String that is associated with the Intent, used with
4181 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4182 * as HTML formatted text. Note that you <em>must</em> also supply
4183 * {@link #EXTRA_TEXT}.
4184 */
4185 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4186
4187 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004188 * A content: URI holding a stream of data associated with the Intent,
4189 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004190 */
4191 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4192
4193 /**
4194 * A String[] holding e-mail addresses that should be delivered to.
4195 */
4196 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4197
4198 /**
4199 * A String[] holding e-mail addresses that should be carbon copied.
4200 */
4201 public static final String EXTRA_CC = "android.intent.extra.CC";
4202
4203 /**
4204 * A String[] holding e-mail addresses that should be blind carbon copied.
4205 */
4206 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4207
4208 /**
4209 * A constant string holding the desired subject line of a message.
4210 */
4211 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4212
4213 /**
4214 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004215 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004216 */
4217 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4218
4219 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004220 * An int representing the user id to be used.
4221 *
4222 * @hide
4223 */
4224 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4225
4226 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004227 * An int representing the task id to be retrieved. This is used when a launch from recents is
4228 * intercepted by another action such as credentials confirmation to remember which task should
4229 * be resumed when complete.
4230 *
4231 * @hide
4232 */
4233 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4234
4235 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004236 * An Intent[] describing additional, alternate choices you would like shown with
4237 * {@link #ACTION_CHOOSER}.
4238 *
4239 * <p>An app may be capable of providing several different payload types to complete a
4240 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4241 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4242 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4243 * photo data or a hosted link where the photos can be viewed.</p>
4244 *
4245 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4246 * first/primary/preferred intent in the set. Additional intents specified in
4247 * this extra are ordered; by default intents that appear earlier in the array will be
4248 * preferred over intents that appear later in the array as matches for the same
4249 * target component. To alter this preference, a calling app may also supply
4250 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4251 */
4252 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4253
4254 /**
Adam Powell52c39212016-04-07 15:14:18 -07004255 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4256 * and omitted from a list of components presented to the user.
4257 *
4258 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4259 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4260 * from your own package or other apps from your organization if the idea of sending to those
4261 * targets would be redundant with other app functionality. Filtered components will not
4262 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4263 */
4264 public static final String EXTRA_EXCLUDE_COMPONENTS
4265 = "android.intent.extra.EXCLUDE_COMPONENTS";
4266
4267 /**
4268 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4269 * describing additional high-priority deep-link targets for the chooser to present to the user.
4270 *
4271 * <p>Targets provided in this way will be presented inline with all other targets provided
4272 * by services from other apps. They will be prioritized before other service targets, but
4273 * after those targets provided by sources that the user has manually pinned to the front.</p>
4274 *
4275 * @see #ACTION_CHOOSER
4276 */
4277 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4278
4279 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004280 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4281 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4282 *
4283 * <p>An app preparing an action for another app to complete may wish to allow the user to
4284 * disambiguate between several options for completing the action based on the chosen target
4285 * or otherwise refine the action before it is invoked.
4286 * </p>
4287 *
4288 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4289 * <ul>
4290 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4291 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4292 * chosen target beyond the first</li>
4293 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4294 * should fill in and send once the disambiguation is complete</li>
4295 * </ul>
4296 */
4297 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4298 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4299
4300 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004301 * An {@code ArrayList} of {@code String} annotations describing content for
4302 * {@link #ACTION_CHOOSER}.
4303 *
4304 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4305 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4306 *
4307 * <p>Annotations should describe the major components or topics of the content. It is up to
4308 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4309 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4310 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4311 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
Kang Lifadc0162017-04-19 11:56:05 -07004312 * use the following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004313 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004314 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004315 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004316 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004317 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004318 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004319 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004320 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004321 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004322 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4323 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4324 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4325 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4326 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004327 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004328 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4329 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004330 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004331 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004332 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004333 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004334 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004335 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004336 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004337 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004338 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004339 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004340 * Christmas and Thanksgiving.</li>
4341 * </ul>
4342 */
4343 public static final String EXTRA_CONTENT_ANNOTATIONS
4344 = "android.intent.extra.CONTENT_ANNOTATIONS";
4345
4346 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004347 * A {@link ResultReceiver} used to return data back to the sender.
4348 *
4349 * <p>Used to complete an app-specific
4350 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4351 *
4352 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4353 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4354 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4355 * when the user selects a target component from the chooser. It is up to the recipient
4356 * to send a result to this ResultReceiver to signal that disambiguation is complete
4357 * and that the chooser should invoke the user's choice.</p>
4358 *
4359 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4360 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4361 * to match and fill in the final Intent or ChooserTarget before starting it.
4362 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4363 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4364 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4365 *
4366 * <p>The result code passed to the ResultReceiver should be
4367 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4368 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4369 * the chooser should finish without starting a target.</p>
4370 */
4371 public static final String EXTRA_RESULT_RECEIVER
4372 = "android.intent.extra.RESULT_RECEIVER";
4373
4374 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004375 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004376 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004377 */
4378 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4379
4380 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004381 * A Parcelable[] of {@link Intent} or
4382 * {@link android.content.pm.LabeledIntent} objects as set with
4383 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4384 * a the front of the list of choices, when shown to the user with a
4385 * {@link #ACTION_CHOOSER}.
4386 */
4387 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4388
4389 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004390 * A {@link IntentSender} to start after ephemeral installation success.
4391 * @hide
4392 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004393 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4394
4395 /**
4396 * A {@link IntentSender} to start after ephemeral installation failure.
4397 * @hide
4398 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004399 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4400
4401 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004402 * The host name that triggered an ephemeral resolution.
4403 * @hide
4404 */
4405 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4406
4407 /**
4408 * An opaque token to track ephemeral resolution.
4409 * @hide
4410 */
4411 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4412
4413 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004414 * The version code of the app to install components from.
4415 * @hide
4416 */
4417 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4418
4419 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004420 * A Bundle forming a mapping of potential target package names to different extras Bundles
4421 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4422 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4423 * be currently installed on the device.
4424 *
4425 * <p>An application may choose to provide alternate extras for the case where a user
4426 * selects an activity from a predetermined set of target packages. If the activity
4427 * the user selects from the chooser belongs to a package with its package name as
4428 * a key in this bundle, the corresponding extras for that package will be merged with
4429 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4430 * extra has the same key as an extra already present in the intent it will overwrite
4431 * the extra from the intent.</p>
4432 *
4433 * <p><em>Examples:</em>
4434 * <ul>
4435 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4436 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4437 * parameters for that target.</li>
4438 * <li>An application may offer additional metadata for known targets of a given intent
4439 * to pass along information only relevant to that target such as account or content
4440 * identifiers already known to that application.</li>
4441 * </ul></p>
4442 */
4443 public static final String EXTRA_REPLACEMENT_EXTRAS =
4444 "android.intent.extra.REPLACEMENT_EXTRAS";
4445
4446 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004447 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4448 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4449 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4450 * {@link ComponentName} of the chosen component.
4451 *
4452 * <p>In some situations this callback may never come, for example if the user abandons
4453 * the chooser, switches to another task or any number of other reasons. Apps should not
4454 * be written assuming that this callback will always occur.</p>
4455 */
4456 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4457 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4458
4459 /**
4460 * The {@link ComponentName} chosen by the user to complete an action.
4461 *
4462 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4463 */
4464 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4465
4466 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004467 * A {@link android.view.KeyEvent} object containing the event that
4468 * triggered the creation of the Intent it is in.
4469 */
4470 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4471
4472 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004473 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4474 * before shutting down.
4475 *
4476 * {@hide}
4477 */
4478 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4479
4480 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004481 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4482 * requested by the user.
4483 *
4484 * {@hide}
4485 */
4486 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4487 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4488
4489 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004490 * 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 -07004491 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4492 * of restarting the application.
4493 */
4494 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4495
4496 /**
4497 * A String holding the phone number originally entered in
4498 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4499 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4500 */
4501 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004502
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004503 /**
4504 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4505 * intents to supply the uid the package had been assigned. Also an optional
4506 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4507 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4508 * purpose.
4509 */
4510 public static final String EXTRA_UID = "android.intent.extra.UID";
4511
4512 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004513 * @hide String array of package names.
4514 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004515 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004516 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4517
4518 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004519 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4520 * intents to indicate whether this represents a full uninstall (removing
4521 * both the code and its data) or a partial uninstall (leaving its data,
4522 * implying that this is an update).
4523 */
4524 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004525
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004526 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004527 * @hide
4528 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4529 * intents to indicate that at this point the package has been removed for
4530 * all users on the device.
4531 */
4532 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4533 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4534
4535 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004536 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4537 * intents to indicate that this is a replacement of the package, so this
4538 * broadcast will immediately be followed by an add broadcast for a
4539 * different version of the same package.
4540 */
4541 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004542
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004543 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004544 * Used as an int extra field in {@link android.app.AlarmManager} intents
4545 * to tell the application being invoked how many pending alarms are being
4546 * delievered with the intent. For one-shot alarms this will always be 1.
4547 * For recurring alarms, this might be greater than 1 if the device was
4548 * asleep or powered off at the time an earlier alarm would have been
4549 * delivered.
4550 */
4551 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004552
Jacek Surazski86b6c532009-05-13 14:38:28 +02004553 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004554 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4555 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004556 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4557 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004558 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4559 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4560 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004561 */
4562 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4563
4564 /**
4565 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4566 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004567 */
4568 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4569
4570 /**
4571 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4572 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004573 */
4574 public static final int EXTRA_DOCK_STATE_DESK = 1;
4575
4576 /**
4577 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4578 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004579 */
4580 public static final int EXTRA_DOCK_STATE_CAR = 2;
4581
4582 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004583 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4584 * to represent that the phone is in a analog (low end) dock.
4585 */
4586 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4587
4588 /**
4589 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4590 * to represent that the phone is in a digital (high end) dock.
4591 */
4592 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4593
4594 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004595 * Boolean that can be supplied as meta-data with a dock activity, to
4596 * indicate that the dock should take over the home key when it is active.
4597 */
4598 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004599
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004600 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004601 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4602 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004603 */
4604 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4605
4606 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004607 * Used in the extra field in the remote intent. It's astring token passed with the
4608 * remote intent.
4609 */
4610 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4611 "android.intent.extra.remote_intent_token";
4612
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004613 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004614 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004615 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004616 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004617 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004618 "android.intent.extra.changed_component_name";
4619
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004620 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004621 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004622 * and contains a string array of all of the components that have changed. If
4623 * the state of the overall package has changed, then it will contain an entry
4624 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004625 */
4626 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4627 "android.intent.extra.changed_component_name_list";
4628
4629 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004630 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004631 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004632 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4633 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4634 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004635 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004636 */
4637 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4638 "android.intent.extra.changed_package_list";
4639
4640 /**
4641 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004642 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4643 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004644 * and contains an integer array of uids of all of the components
4645 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004646 */
4647 public static final String EXTRA_CHANGED_UID_LIST =
4648 "android.intent.extra.changed_uid_list";
4649
4650 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004651 * @hide
4652 * Magic extra system code can use when binding, to give a label for
4653 * who it is that has bound to a service. This is an integer giving
4654 * a framework string resource that can be displayed to the user.
4655 */
4656 public static final String EXTRA_CLIENT_LABEL =
4657 "android.intent.extra.client_label";
4658
4659 /**
4660 * @hide
4661 * Magic extra system code can use when binding, to give a PendingIntent object
4662 * that can be launched for the user to disable the system's use of this
4663 * service.
4664 */
4665 public static final String EXTRA_CLIENT_INTENT =
4666 "android.intent.extra.client_intent";
4667
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004668 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004669 * Extra used to indicate that an intent should only return data that is on
4670 * the local device. This is a boolean extra; the default is false. If true,
4671 * an implementation should only allow the user to select data that is
4672 * already on the device, not requiring it be downloaded from a remote
4673 * service when opened.
4674 *
4675 * @see #ACTION_GET_CONTENT
4676 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004677 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004678 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004679 */
4680 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004681 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004682
Amith Yamasani13593602012-03-22 16:16:17 -07004683 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004684 * Extra used to indicate that an intent can allow the user to select and
4685 * return multiple items. This is a boolean extra; the default is false. If
4686 * true, an implementation is allowed to present the user with a UI where
4687 * they can pick multiple items that are all returned to the caller. When
4688 * this happens, they should be returned as the {@link #getClipData()} part
4689 * of the result Intent.
4690 *
4691 * @see #ACTION_GET_CONTENT
4692 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004693 */
4694 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004695 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004696
4697 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004698 * The integer userHandle carried with broadcast intents related to addition, removal and
4699 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4700 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4701 *
Amith Yamasani13593602012-03-22 16:16:17 -07004702 * @hide
4703 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004704 public static final String EXTRA_USER_HANDLE =
4705 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004706
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004707 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004708 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4709 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4710 */
4711 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004712 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004713
4714 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004715 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004716 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4717 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004718 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004719 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4720
4721 /**
4722 * Extra sent in the intent to the BroadcastReceiver that handles
4723 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4724 * the restrictions as key/value pairs.
4725 */
4726 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4727 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004728
Amith Yamasani86118ba2013-03-28 14:33:16 -07004729 /**
4730 * Extra used in the response from a BroadcastReceiver that handles
4731 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4732 */
4733 public static final String EXTRA_RESTRICTIONS_INTENT =
4734 "android.intent.extra.restrictions_intent";
4735
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004736 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004737 * Extra used to communicate a set of acceptable MIME types. The type of the
4738 * extra is {@code String[]}. Values may be a combination of concrete MIME
4739 * types (such as "image/png") and/or partial MIME types (such as
4740 * "audio/*").
4741 *
4742 * @see #ACTION_GET_CONTENT
4743 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004744 */
4745 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4746
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004747 /**
4748 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4749 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004750 * When this is true, hardware devices can use this information to determine that
4751 * they shouldn't do a complete shutdown of their device since this is not a
4752 * complete shutdown down to the kernel, but only user space restarting.
4753 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004754 */
4755 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4756 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4757
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004758 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004759 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4760 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4761 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4762 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004763 *
4764 * @hide for internal use only.
4765 */
4766 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4767 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004768 /** @hide */
4769 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4770 /** @hide */
4771 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4772 /** @hide */
4773 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004774
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004775 /** {@hide} */
4776 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4777
Rubin Xue8490f12015-06-25 12:17:48 +01004778 /** {@hide} */
4779 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4780
Santos Cordon15a13782015-03-31 18:32:31 -07004781 /**
4782 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4783 * activation request.
4784 * TODO: Add information about the structure and response data used with the pending intent.
4785 * @hide
4786 */
4787 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4788 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4789
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004790 /**
4791 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004792 *
4793 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07004794 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004795 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004796 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4797
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004798 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004799 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4800 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4801 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004802 *
4803 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07004804 * @see #ACTION_QUICK_VIEW
4805 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004806 */
Garfield Tance1d0e92017-03-23 10:52:48 -07004807 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004808 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4809 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004810
4811 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07004812 * An optional extra of {@code String[]} indicating which quick view features should be made
4813 * available to the user in the quick view UI while handing a
4814 * {@link Intent#ACTION_QUICK_VIEW} intent.
4815 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4816 * Quick viewer can implement features not listed below.
4817 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4818 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4819 * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4820 * <p>
4821 * Requirements:
4822 * <li>Quick viewer shouldn't show a feature if the feature is absent in
4823 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4824 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4825 * internal policies.
4826 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4827 * requirement that the feature be shown. Quick viewer may, according to its own policies,
4828 * disable or hide features.
4829 *
4830 * @see #ACTION_QUICK_VIEW
4831 */
4832 public static final String EXTRA_QUICK_VIEW_FEATURES =
4833 "android.intent.extra.QUICK_VIEW_FEATURES";
4834
4835 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004836 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004837 * When a profile goes into quiet mode, all apps in the profile are killed and the
4838 * profile user is stopped. Widgets originating from the profile are masked, and app
4839 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004840 */
4841 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004842
4843 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004844 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004845 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004846 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4847 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004848 *
4849 * @hide
4850 */
4851 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4852 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4853
4854 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004855 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4856 * whether to show the chooser or not when there is only one application available
4857 * to choose from.
4858 *
4859 * @hide
4860 */
4861 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4862 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4863
4864 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004865 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004866 * to represent that a video codec is allowed to use.
4867 *
4868 * @hide
4869 */
4870 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4871
4872 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004873 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004874 * to represent that a audio codec is allowed to use.
4875 *
4876 * @hide
4877 */
4878 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4879
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004880 // ---------------------------------------------------------------------
4881 // ---------------------------------------------------------------------
4882 // Intent flags (see mFlags variable).
4883
Tor Norbyed9273d62013-05-30 15:59:53 -07004884 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004885 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004886 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4887 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004888 @Retention(RetentionPolicy.SOURCE)
4889 public @interface GrantUriMode {}
4890
Jeff Sharkey846318a2014-04-04 12:12:41 -07004891 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06004892 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07004893 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4894 @Retention(RetentionPolicy.SOURCE)
4895 public @interface AccessUriMode {}
4896
4897 /**
4898 * Test if given mode flags specify an access mode, which must be at least
4899 * read and/or write.
4900 *
4901 * @hide
4902 */
4903 public static boolean isAccessUriMode(int modeFlags) {
4904 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4905 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4906 }
4907
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06004908 /** @hide */
4909 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4910 FLAG_GRANT_READ_URI_PERMISSION,
4911 FLAG_GRANT_WRITE_URI_PERMISSION,
4912 FLAG_FROM_BACKGROUND,
4913 FLAG_DEBUG_LOG_RESOLUTION,
4914 FLAG_EXCLUDE_STOPPED_PACKAGES,
4915 FLAG_INCLUDE_STOPPED_PACKAGES,
4916 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
4917 FLAG_GRANT_PREFIX_URI_PERMISSION,
4918 FLAG_DEBUG_TRIAGED_MISSING,
4919 FLAG_IGNORE_EPHEMERAL,
4920 FLAG_ACTIVITY_NO_HISTORY,
4921 FLAG_ACTIVITY_SINGLE_TOP,
4922 FLAG_ACTIVITY_NEW_TASK,
4923 FLAG_ACTIVITY_MULTIPLE_TASK,
4924 FLAG_ACTIVITY_CLEAR_TOP,
4925 FLAG_ACTIVITY_FORWARD_RESULT,
4926 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4927 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
4928 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
4929 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
4930 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
4931 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4932 FLAG_ACTIVITY_NEW_DOCUMENT,
4933 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4934 FLAG_ACTIVITY_NO_USER_ACTION,
4935 FLAG_ACTIVITY_REORDER_TO_FRONT,
4936 FLAG_ACTIVITY_NO_ANIMATION,
4937 FLAG_ACTIVITY_CLEAR_TASK,
4938 FLAG_ACTIVITY_TASK_ON_HOME,
4939 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
4940 FLAG_ACTIVITY_LAUNCH_ADJACENT,
4941 FLAG_RECEIVER_REGISTERED_ONLY,
4942 FLAG_RECEIVER_REPLACE_PENDING,
4943 FLAG_RECEIVER_FOREGROUND,
4944 FLAG_RECEIVER_NO_ABORT,
4945 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
4946 FLAG_RECEIVER_BOOT_UPGRADE,
4947 FLAG_RECEIVER_INCLUDE_BACKGROUND,
4948 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
4949 FLAG_RECEIVER_FROM_SHELL,
4950 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
4951 })
4952 @Retention(RetentionPolicy.SOURCE)
4953 public @interface Flags {}
4954
4955 /** @hide */
4956 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
4957 FLAG_FROM_BACKGROUND,
4958 FLAG_DEBUG_LOG_RESOLUTION,
4959 FLAG_EXCLUDE_STOPPED_PACKAGES,
4960 FLAG_INCLUDE_STOPPED_PACKAGES,
4961 FLAG_DEBUG_TRIAGED_MISSING,
4962 FLAG_IGNORE_EPHEMERAL,
4963 FLAG_ACTIVITY_NO_HISTORY,
4964 FLAG_ACTIVITY_SINGLE_TOP,
4965 FLAG_ACTIVITY_NEW_TASK,
4966 FLAG_ACTIVITY_MULTIPLE_TASK,
4967 FLAG_ACTIVITY_CLEAR_TOP,
4968 FLAG_ACTIVITY_FORWARD_RESULT,
4969 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
4970 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
4971 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
4972 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
4973 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
4974 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4975 FLAG_ACTIVITY_NEW_DOCUMENT,
4976 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
4977 FLAG_ACTIVITY_NO_USER_ACTION,
4978 FLAG_ACTIVITY_REORDER_TO_FRONT,
4979 FLAG_ACTIVITY_NO_ANIMATION,
4980 FLAG_ACTIVITY_CLEAR_TASK,
4981 FLAG_ACTIVITY_TASK_ON_HOME,
4982 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
4983 FLAG_ACTIVITY_LAUNCH_ADJACENT,
4984 FLAG_RECEIVER_REGISTERED_ONLY,
4985 FLAG_RECEIVER_REPLACE_PENDING,
4986 FLAG_RECEIVER_FOREGROUND,
4987 FLAG_RECEIVER_NO_ABORT,
4988 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
4989 FLAG_RECEIVER_BOOT_UPGRADE,
4990 FLAG_RECEIVER_INCLUDE_BACKGROUND,
4991 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
4992 FLAG_RECEIVER_FROM_SHELL,
4993 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
4994 })
4995 @Retention(RetentionPolicy.SOURCE)
4996 public @interface MutableFlags {}
4997
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004998 /**
4999 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005000 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005001 * specified in its ClipData. When applying to an Intent's ClipData,
5002 * all URIs as well as recursive traversals through data or other ClipData
5003 * in Intent items will be granted; only the grant flags of the top-level
5004 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005005 */
5006 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5007 /**
5008 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005009 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005010 * specified in its ClipData. When applying to an Intent's ClipData,
5011 * all URIs as well as recursive traversals through data or other ClipData
5012 * in Intent items will be granted; only the grant flags of the top-level
5013 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 */
5015 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5016 /**
5017 * Can be set by the caller to indicate that this Intent is coming from
5018 * a background operation, not from direct user interaction.
5019 */
5020 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5021 /**
5022 * A flag you can enable for debugging: when set, log messages will be
5023 * printed during the resolution of this intent to show you what has
5024 * been found to create the final resolved list.
5025 */
5026 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005027 /**
5028 * If set, this intent will not match any components in packages that
5029 * are currently stopped. If this is not set, then the default behavior
5030 * is to include such applications in the result.
5031 */
5032 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5033 /**
5034 * If set, this intent will always match any components in packages that
5035 * are currently stopped. This is the default behavior when
5036 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5037 * flags are set, this one wins (it allows overriding of exclude for
5038 * places where the framework may automatically set the exclude flag).
5039 */
5040 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005041
5042 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005043 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005044 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005045 * persisted across device reboots until explicitly revoked with
5046 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5047 * grant for possible persisting; the receiving application must call
5048 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5049 * actually persist.
5050 *
5051 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5052 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5053 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005054 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005055 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005056 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005057
5058 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005059 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5060 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5061 * applies to any URI that is a prefix match against the original granted
5062 * URI. (Without this flag, the URI must match exactly for access to be
5063 * granted.) Another URI is considered a prefix match only when scheme,
5064 * authority, and all path segments defined by the prefix are an exact
5065 * match.
5066 */
5067 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5068
5069 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005070 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005071 * homework and verified that they correctly handle packages and components
5072 * that come and go over time. In particular:
5073 * <ul>
5074 * <li>Apps installed on external storage, which will appear to be
5075 * uninstalled while the the device is ejected.
5076 * <li>Apps with encryption unaware components, which will appear to not
5077 * exist while the device is locked.
5078 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005079 *
5080 * @hide
5081 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005082 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005083
5084 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005085 * Internal flag used to indicate ephemeral applications should not be
5086 * considered when resolving the intent.
5087 *
5088 * @hide
5089 */
5090 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5091
5092 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005093 * If set, the new activity is not kept in the history stack. As soon as
5094 * the user navigates away from it, the activity is finished. This may also
5095 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5096 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005097 *
5098 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5099 * is never invoked when the current activity starts a new activity which
5100 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005101 */
5102 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5103 /**
5104 * If set, the activity will not be launched if it is already running
5105 * at the top of the history stack.
5106 */
5107 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5108 /**
5109 * If set, this activity will become the start of a new task on this
5110 * history stack. A task (from the activity that started it to the
5111 * next task activity) defines an atomic group of activities that the
5112 * user can move to. Tasks can be moved to the foreground and background;
5113 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005114 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005115 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5116 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005117 *
5118 * <p>This flag is generally used by activities that want
5119 * to present a "launcher" style behavior: they give the user a list of
5120 * separate things that can be done, which otherwise run completely
5121 * independently of the activity launching them.
5122 *
5123 * <p>When using this flag, if a task is already running for the activity
5124 * you are now starting, then a new activity will not be started; instead,
5125 * the current task will simply be brought to the front of the screen with
5126 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5127 * to disable this behavior.
5128 *
5129 * <p>This flag can not be used when the caller is requesting a result from
5130 * the activity being launched.
5131 */
5132 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5133 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005134 * This flag is used to create a new task and launch an activity into it.
5135 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5136 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5137 * search through existing tasks for ones matching this Intent. Only if no such
5138 * task is found would a new task be created. When paired with
5139 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5140 * the search for a matching task and unconditionally start a new task.
5141 *
5142 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5143 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005144 * top-level application launcher.</strong> Used in conjunction with
5145 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5146 * behavior of bringing an existing task to the foreground. When set,
5147 * a new task is <em>always</em> started to host the Activity for the
5148 * Intent, regardless of whether there is already an existing task running
5149 * the same thing.
5150 *
5151 * <p><strong>Because the default system does not include graphical task management,
5152 * you should not use this flag unless you provide some way for a user to
5153 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005154 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005155 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5156 * creating new document tasks.
5157 *
5158 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005159 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005160 *
Scott Main7aee61f2011-02-08 11:25:01 -08005161 * <p>See
5162 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5163 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005164 *
5165 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5166 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005167 */
5168 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5169 /**
5170 * If set, and the activity being launched is already running in the
5171 * current task, then instead of launching a new instance of that activity,
5172 * all of the other activities on top of it will be closed and this Intent
5173 * will be delivered to the (now on top) old activity as a new Intent.
5174 *
5175 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5176 * If D calls startActivity() with an Intent that resolves to the component
5177 * of activity B, then C and D will be finished and B receive the given
5178 * Intent, resulting in the stack now being: A, B.
5179 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005180 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005181 * either receive the new intent you are starting here in its
5182 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005183 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005184 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5185 * the same intent, then it will be finished and re-created; for all other
5186 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5187 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005188 *
5189 * <p>This launch mode can also be used to good effect in conjunction with
5190 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5191 * of a task, it will bring any currently running instance of that task
5192 * to the foreground, and then clear it to its root state. This is
5193 * especially useful, for example, when launching an activity from the
5194 * notification manager.
5195 *
Scott Main7aee61f2011-02-08 11:25:01 -08005196 * <p>See
5197 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5198 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005199 */
5200 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5201 /**
5202 * If set and this intent is being used to launch a new activity from an
5203 * existing one, then the reply target of the existing activity will be
5204 * transfered to the new activity. This way the new activity can call
5205 * {@link android.app.Activity#setResult} and have that result sent back to
5206 * the reply target of the original activity.
5207 */
5208 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5209 /**
5210 * If set and this intent is being used to launch a new activity from an
5211 * existing one, the current activity will not be counted as the top
5212 * activity for deciding whether the new intent should be delivered to
5213 * the top instead of starting a new one. The previous activity will
5214 * be used as the top, with the assumption being that the current activity
5215 * will finish itself immediately.
5216 */
5217 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5218 /**
5219 * If set, the new activity is not kept in the list of recently launched
5220 * activities.
5221 */
5222 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5223 /**
5224 * This flag is not normally set by application code, but set for you by
5225 * the system as described in the
5226 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5227 * launchMode} documentation for the singleTask mode.
5228 */
5229 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5230 /**
5231 * If set, and this activity is either being started in a new task or
5232 * bringing to the top an existing task, then it will be launched as
5233 * the front door of the task. This will result in the application of
5234 * any affinities needed to have that task in the proper state (either
5235 * moving activities to or from it), or simply resetting that task to
5236 * its initial state if needed.
5237 */
5238 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5239 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005240 * This flag is not normally set by application code, but set for you by
5241 * the system if this activity is being launched from history
5242 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005243 */
5244 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005245 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005246 * @deprecated As of API 21 this performs identically to
5247 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005248 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005249 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005250 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005251 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005252 * This flag is used to open a document into a new task rooted at the activity launched
5253 * by this Intent. Through the use of this flag, or its equivalent attribute,
5254 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005255 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005256 *
Craig Mautner026596b2014-05-21 15:35:44 -07005257 * <p>The use of the activity attribute form of this,
5258 * {@link android.R.attr#documentLaunchMode}, is
5259 * preferred over the Intent flag described here. The attribute form allows the
5260 * Activity to specify multiple document behavior for all launchers of the Activity
5261 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005262 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005263 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5264 * it is kept after the activity is finished is different than the use of
5265 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5266 * this flag is being used to create a new recents entry, then by default that entry
5267 * will be removed once the activity is finished. You can modify this behavior with
5268 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5269 *
Craig Mautner026596b2014-05-21 15:35:44 -07005270 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5271 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5272 * equivalent of the Activity manifest specifying {@link
5273 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5274 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5275 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005276 *
Craig Mautner026596b2014-05-21 15:35:44 -07005277 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005278 *
Craig Mautner026596b2014-05-21 15:35:44 -07005279 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005280 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5281 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005282 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005283 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005284 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005285 * callback from occurring on the current frontmost activity before it is
5286 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005287 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005288 * <p>Typically, an activity can rely on that callback to indicate that an
5289 * explicit user action has caused their activity to be moved out of the
5290 * foreground. The callback marks an appropriate point in the activity's
5291 * lifecycle for it to dismiss any notifications that it intends to display
5292 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005293 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005294 * <p>If an activity is ever started via any non-user-driven events such as
5295 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5296 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005297 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005298 */
5299 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005300 /**
5301 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5302 * this flag will cause the launched activity to be brought to the front of its
5303 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005304 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005305 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5306 * If D calls startActivity() with an Intent that resolves to the component
5307 * of activity B, then B will be brought to the front of the history stack,
5308 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005309 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005310 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005311 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005312 */
5313 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005314 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005315 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5316 * this flag will prevent the system from applying an activity transition
5317 * animation to go to the next activity state. This doesn't mean an
5318 * animation will never run -- if another activity change happens that doesn't
5319 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005320 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005321 * when you are going to do a series of activity operations but the
5322 * animation seen by the user shouldn't be driven by the first activity
5323 * change but rather a later one.
5324 */
5325 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5326 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005327 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5328 * this flag will cause any existing task that would be associated with the
5329 * activity to be cleared before the activity is started. That is, the activity
5330 * becomes the new root of an otherwise empty task, and any old activities
5331 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5332 */
5333 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5334 /**
5335 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5336 * this flag will cause a newly launching task to be placed on top of the current
5337 * home activity task (if there is one). That is, pressing back from the task
5338 * will always return the user to home even if that was not the last activity they
5339 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5340 */
5341 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5342 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005343 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5344 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005345 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005346 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005347 * this flag. When set and the task's activity is finished, the recents
5348 * entry will remain in the interface for the user to re-launch it, like a
5349 * recents entry for a top-level application.
5350 * <p>
5351 * The receiving activity can override this request with
5352 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5353 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005354 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005355 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005356 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005357
5358 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005359 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5360 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005361 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5362 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005363 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005364 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005365
5366 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005367 * If set, when sending a broadcast only registered receivers will be
5368 * called -- no BroadcastReceiver components will be launched.
5369 */
5370 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005371 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005372 * If set, when sending a broadcast the new broadcast will replace
5373 * any existing pending broadcast that matches it. Matching is defined
5374 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5375 * true for the intents of the two broadcasts. When a match is found,
5376 * the new broadcast (and receivers associated with it) will replace the
5377 * existing one in the pending broadcast list, remaining at the same
5378 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005379 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005380 * <p>This flag is most typically used with sticky broadcasts, which
5381 * only care about delivering the most recent values of the broadcast
5382 * to their receivers.
5383 */
5384 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5385 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005386 * If set, when sending a broadcast the recipient is allowed to run at
5387 * foreground priority, with a shorter timeout interval. During normal
5388 * broadcasts the receivers are not automatically hoisted out of the
5389 * background priority class.
5390 */
5391 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5392 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005393 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5394 * They can still propagate results through to later receivers, but they can not prevent
5395 * later receivers from seeing the broadcast.
5396 */
5397 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5398 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005399 * If set, when sending a broadcast <i>before boot has completed</i> only
5400 * registered receivers will be called -- no BroadcastReceiver components
5401 * will be launched. Sticky intent state will be recorded properly even
5402 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5403 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005404 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005405 * <p>This flag is only for use by system sevices as a convenience to
5406 * avoid having to implement a more complex mechanism around detection
5407 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005408 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005409 * @hide
5410 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005411 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005412 /**
5413 * Set when this broadcast is for a boot upgrade, a special mode that
5414 * allows the broadcast to be sent before the system is ready and launches
5415 * the app process with no providers running in it.
5416 * @hide
5417 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005418 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005419 /**
5420 * If set, the broadcast will always go to manifest receivers in background (cached
5421 * or not running) apps, regardless of whether that would be done by default. By
5422 * default they will only receive broadcasts if the broadcast has specified an
5423 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005424 *
5425 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5426 * the broadcast code there must also be changed to match.
5427 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005428 * @hide
5429 */
5430 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5431 /**
5432 * If set, the broadcast will never go to manifest receivers in background (cached
5433 * or not running) apps, regardless of whether that would be done by default. By
5434 * default they will receive broadcasts if the broadcast has specified an
5435 * explicit component or package name.
5436 * @hide
5437 */
5438 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005439 /**
5440 * If set, this broadcast is being sent from the shell.
5441 * @hide
5442 */
5443 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005444
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005445 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005446 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5447 * will not receive broadcasts.
5448 *
5449 * <em>This flag has no effect when used by an Instant App.</em>
5450 */
5451 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5452
5453 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005454 * @hide Flags that can't be changed with PendingIntent.
5455 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005456 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5457 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5458 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005459
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005460 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005461 // ---------------------------------------------------------------------
5462 // toUri() and parseUri() options.
5463
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005464 /** @hide */
5465 @IntDef(flag = true, prefix = { "URI_" }, value = {
5466 URI_ALLOW_UNSAFE,
5467 URI_ANDROID_APP_SCHEME,
5468 URI_INTENT_SCHEME,
5469 })
5470 @Retention(RetentionPolicy.SOURCE)
5471 public @interface UriFlags {}
5472
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005473 /**
5474 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5475 * always has the "intent:" scheme. This syntax can be used when you want
5476 * to later disambiguate between URIs that are intended to describe an
5477 * Intent vs. all others that should be treated as raw URIs. When used
5478 * with {@link #parseUri}, any other scheme will result in a generic
5479 * VIEW action for that raw URI.
5480 */
5481 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005482
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005483 /**
5484 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5485 * always has the "android-app:" scheme. This is a variation of
5486 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5487 * http/https URI being delivered to a specific package name. The format
5488 * is:
5489 *
5490 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005491 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005492 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005493 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5494 * you must also include a scheme; including a path also requires both a host and a scheme.
5495 * The final #Intent; fragment can be used without a scheme, host, or path.
5496 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005497 * used with intents that have a {@link #setSelector}, since the base intent
5498 * will always have an explicit package name.</p>
5499 *
5500 * <p>Some examples of how this scheme maps to Intent objects:</p>
5501 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5502 * <colgroup align="left" />
5503 * <colgroup align="left" />
5504 * <thead>
5505 * <tr><th>URI</th> <th>Intent</th></tr>
5506 * </thead>
5507 *
5508 * <tbody>
5509 * <tr><td><code>android-app://com.example.app</code></td>
5510 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5511 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5512 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5513 * </table></td>
5514 * </tr>
5515 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5516 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5517 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5518 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5519 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5520 * </table></td>
5521 * </tr>
5522 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5523 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5524 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5525 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5526 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5527 * </table></td>
5528 * </tr>
5529 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5530 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5531 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5532 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5533 * </table></td>
5534 * </tr>
5535 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5536 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5537 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5538 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5539 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5540 * </table></td>
5541 * </tr>
5542 * <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>
5543 * <td><table border="" style="margin:0" >
5544 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5545 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5546 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5547 * </table></td>
5548 * </tr>
5549 * </tbody>
5550 * </table>
5551 */
5552 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5553
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005554 /**
5555 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5556 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5557 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5558 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5559 * generated Intent can not cause unexpected data access to happen.
5560 *
5561 * <p>If you do not trust the source of the URI being parsed, you should still do further
5562 * processing to protect yourself from it. In particular, when using it to start an
5563 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5564 * that can handle it.</p>
5565 */
5566 public static final int URI_ALLOW_UNSAFE = 1<<2;
5567
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005568 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005569
5570 private String mAction;
5571 private Uri mData;
5572 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005573 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005574 private ComponentName mComponent;
5575 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005576 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005577 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005578 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005579 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005580 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005581 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005582 /** Token to track instant app launches. Local only; do not copy cross-process. */
5583 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005584
5585 // ---------------------------------------------------------------------
5586
5587 /**
5588 * Create an empty intent.
5589 */
5590 public Intent() {
5591 }
5592
5593 /**
5594 * Copy constructor.
5595 */
5596 public Intent(Intent o) {
5597 this.mAction = o.mAction;
5598 this.mData = o.mData;
5599 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005600 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005601 this.mComponent = o.mComponent;
5602 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005603 this.mContentUserHint = o.mContentUserHint;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005604 this.mLaunchToken = o.mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005605 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005606 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005607 }
5608 if (o.mExtras != null) {
5609 this.mExtras = new Bundle(o.mExtras);
5610 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005611 if (o.mSourceBounds != null) {
5612 this.mSourceBounds = new Rect(o.mSourceBounds);
5613 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005614 if (o.mSelector != null) {
5615 this.mSelector = new Intent(o.mSelector);
5616 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005617 if (o.mClipData != null) {
5618 this.mClipData = new ClipData(o.mClipData);
5619 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005620 }
5621
5622 @Override
5623 public Object clone() {
5624 return new Intent(this);
5625 }
5626
5627 private Intent(Intent o, boolean all) {
5628 this.mAction = o.mAction;
5629 this.mData = o.mData;
5630 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005631 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005632 this.mComponent = o.mComponent;
5633 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005634 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005635 }
5636 }
5637
5638 /**
5639 * Make a clone of only the parts of the Intent that are relevant for
5640 * filter matching: the action, data, type, component, and categories.
5641 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005642 public @NonNull Intent cloneFilter() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005643 return new Intent(this, false);
5644 }
5645
5646 /**
5647 * Create an intent with a given action. All other fields (data, type,
5648 * class) are null. Note that the action <em>must</em> be in a
5649 * namespace because Intents are used globally in the system -- for
5650 * example the system VIEW action is android.intent.action.VIEW; an
5651 * application's custom action would be something like
5652 * com.google.app.myapp.CUSTOM_ACTION.
5653 *
5654 * @param action The Intent action, such as ACTION_VIEW.
5655 */
5656 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005657 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005658 }
5659
5660 /**
5661 * Create an intent with a given action and for a given data url. Note
5662 * that the action <em>must</em> be in a namespace because Intents are
5663 * used globally in the system -- for example the system VIEW action is
5664 * android.intent.action.VIEW; an application's custom action would be
5665 * something like com.google.app.myapp.CUSTOM_ACTION.
5666 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005667 * <p><em>Note: scheme and host name matching in the Android framework is
5668 * case-sensitive, unlike the formal RFC. As a result,
5669 * you should always ensure that you write your Uri with these elements
5670 * using lower case letters, and normalize any Uris you receive from
5671 * outside of Android to ensure the scheme and host is lower case.</em></p>
5672 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005673 * @param action The Intent action, such as ACTION_VIEW.
5674 * @param uri The Intent data URI.
5675 */
5676 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005677 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005678 mData = uri;
5679 }
5680
5681 /**
5682 * Create an intent for a specific component. All other fields (action, data,
5683 * type, class) are null, though they can be modified later with explicit
5684 * calls. This provides a convenient way to create an intent that is
5685 * intended to execute a hard-coded class name, rather than relying on the
5686 * system to find an appropriate class for you; see {@link #setComponent}
5687 * for more information on the repercussions of this.
5688 *
5689 * @param packageContext A Context of the application package implementing
5690 * this class.
5691 * @param cls The component class that is to be used for the intent.
5692 *
5693 * @see #setClass
5694 * @see #setComponent
5695 * @see #Intent(String, android.net.Uri , Context, Class)
5696 */
5697 public Intent(Context packageContext, Class<?> cls) {
5698 mComponent = new ComponentName(packageContext, cls);
5699 }
5700
5701 /**
5702 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005703 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005704 * construct the Intent and then calling {@link #setClass} to set its
5705 * class.
5706 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005707 * <p><em>Note: scheme and host name matching in the Android framework is
5708 * case-sensitive, unlike the formal RFC. As a result,
5709 * you should always ensure that you write your Uri with these elements
5710 * using lower case letters, and normalize any Uris you receive from
5711 * outside of Android to ensure the scheme and host is lower case.</em></p>
5712 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005713 * @param action The Intent action, such as ACTION_VIEW.
5714 * @param uri The Intent data URI.
5715 * @param packageContext A Context of the application package implementing
5716 * this class.
5717 * @param cls The component class that is to be used for the intent.
5718 *
5719 * @see #Intent(String, android.net.Uri)
5720 * @see #Intent(Context, Class)
5721 * @see #setClass
5722 * @see #setComponent
5723 */
5724 public Intent(String action, Uri uri,
5725 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005726 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005727 mData = uri;
5728 mComponent = new ComponentName(packageContext, cls);
5729 }
5730
5731 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005732 * Create an intent to launch the main (root) activity of a task. This
5733 * is the Intent that is started when the application's is launched from
5734 * Home. For anything else that wants to launch an application in the
5735 * same way, it is important that they use an Intent structured the same
5736 * way, and can use this function to ensure this is the case.
5737 *
5738 * <p>The returned Intent has the given Activity component as its explicit
5739 * component, {@link #ACTION_MAIN} as its action, and includes the
5740 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5741 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5742 * to do that through {@link #addFlags(int)} on the returned Intent.
5743 *
5744 * @param mainActivity The main activity component that this Intent will
5745 * launch.
5746 * @return Returns a newly created Intent that can be used to launch the
5747 * activity as a main application entry.
5748 *
5749 * @see #setClass
5750 * @see #setComponent
5751 */
5752 public static Intent makeMainActivity(ComponentName mainActivity) {
5753 Intent intent = new Intent(ACTION_MAIN);
5754 intent.setComponent(mainActivity);
5755 intent.addCategory(CATEGORY_LAUNCHER);
5756 return intent;
5757 }
5758
5759 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005760 * Make an Intent for the main activity of an application, without
5761 * specifying a specific activity to run but giving a selector to find
5762 * the activity. This results in a final Intent that is structured
5763 * the same as when the application is launched from
5764 * Home. For anything else that wants to launch an application in the
5765 * same way, it is important that they use an Intent structured the same
5766 * way, and can use this function to ensure this is the case.
5767 *
5768 * <p>The returned Intent has {@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 selectorAction The action name of the Intent's selector.
5774 * @param selectorCategory The name of a category to add to the Intent's
5775 * selector.
5776 * @return Returns a newly created Intent that can be used to launch the
5777 * activity as a main application entry.
5778 *
5779 * @see #setSelector(Intent)
5780 */
5781 public static Intent makeMainSelectorActivity(String selectorAction,
5782 String selectorCategory) {
5783 Intent intent = new Intent(ACTION_MAIN);
5784 intent.addCategory(CATEGORY_LAUNCHER);
5785 Intent selector = new Intent();
5786 selector.setAction(selectorAction);
5787 selector.addCategory(selectorCategory);
5788 intent.setSelector(selector);
5789 return intent;
5790 }
5791
5792 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005793 * Make an Intent that can be used to re-launch an application's task
5794 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5795 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5796 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5797 *
5798 * @param mainActivity The activity component that is the root of the
5799 * task; this is the activity that has been published in the application's
5800 * manifest as the main launcher icon.
5801 *
5802 * @return Returns a newly created Intent that can be used to relaunch the
5803 * activity's task in its root state.
5804 */
5805 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5806 Intent intent = makeMainActivity(mainActivity);
5807 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5808 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5809 return intent;
5810 }
5811
5812 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005813 * Call {@link #parseUri} with 0 flags.
5814 * @deprecated Use {@link #parseUri} instead.
5815 */
5816 @Deprecated
5817 public static Intent getIntent(String uri) throws URISyntaxException {
5818 return parseUri(uri, 0);
5819 }
Tom Taylord4a47292009-12-21 13:59:18 -08005820
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005821 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005822 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005823 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005824 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005825 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005826 *
5827 * <p>The URI given here must not be relative -- that is, it must include
5828 * the scheme and full path.
5829 *
5830 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005831 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005832 *
5833 * @return Intent The newly created Intent object.
5834 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005835 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5836 * it bad (as parsed by the Uri class) or the Intent data within the
5837 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005838 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005839 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005840 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005841 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005842 int i = 0;
5843 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005844 final boolean androidApp = uri.startsWith("android-app:");
5845
5846 // Validate intent scheme if requested.
5847 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5848 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005849 Intent intent = new Intent(ACTION_VIEW);
5850 try {
5851 intent.setData(Uri.parse(uri));
5852 } catch (IllegalArgumentException e) {
5853 throw new URISyntaxException(uri, e.getMessage());
5854 }
5855 return intent;
5856 }
5857 }
Tom Taylord4a47292009-12-21 13:59:18 -08005858
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005859 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005860 // simple case
5861 if (i == -1) {
5862 if (!androidApp) {
5863 return new Intent(ACTION_VIEW, Uri.parse(uri));
5864 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005865
5866 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005867 } else if (!uri.startsWith("#Intent;", i)) {
5868 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005869 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005870 } else {
5871 i = -1;
5872 }
5873 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005874
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005875 // new format
5876 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005877 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005878 boolean explicitAction = false;
5879 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005880
5881 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005882 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005883 String data;
5884 if (i >= 0) {
5885 data = uri.substring(0, i);
5886 i += 8; // length of "#Intent;"
5887 } else {
5888 data = uri;
5889 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005890
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005891 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005892 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005893 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005894 if (eq < 0) eq = i-1;
5895 int semi = uri.indexOf(';', i);
5896 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005897
5898 // action
5899 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005900 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005901 if (!inSelector) {
5902 explicitAction = true;
5903 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005904 }
5905
5906 // categories
5907 else if (uri.startsWith("category=", i)) {
5908 intent.addCategory(value);
5909 }
5910
5911 // type
5912 else if (uri.startsWith("type=", i)) {
5913 intent.mType = value;
5914 }
5915
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005916 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005917 else if (uri.startsWith("launchFlags=", i)) {
5918 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005919 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5920 intent.mFlags &= ~IMMUTABLE_FLAGS;
5921 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005922 }
5923
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005924 // package
5925 else if (uri.startsWith("package=", i)) {
5926 intent.mPackage = value;
5927 }
5928
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005929 // component
5930 else if (uri.startsWith("component=", i)) {
5931 intent.mComponent = ComponentName.unflattenFromString(value);
5932 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005933
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005934 // scheme
5935 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005936 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005937 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005938 } else {
5939 scheme = value;
5940 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005941 }
5942
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005943 // source bounds
5944 else if (uri.startsWith("sourceBounds=", i)) {
5945 intent.mSourceBounds = Rect.unflattenFromString(value);
5946 }
5947
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005948 // selector
5949 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5950 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005951 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005952 }
5953
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005954 // extra
5955 else {
5956 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005957 // create Bundle if it doesn't already exist
5958 if (intent.mExtras == null) intent.mExtras = new Bundle();
5959 Bundle b = intent.mExtras;
5960 // add EXTRA
5961 if (uri.startsWith("S.", i)) b.putString(key, value);
5962 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5963 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5964 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5965 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5966 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5967 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5968 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5969 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5970 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5971 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005972
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005973 // move to the next item
5974 i = semi + 1;
5975 }
5976
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005977 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005978 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005979 if (baseIntent.mPackage == null) {
5980 baseIntent.setSelector(intent);
5981 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005982 intent = baseIntent;
5983 }
5984
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005985 if (data != null) {
5986 if (data.startsWith("intent:")) {
5987 data = data.substring(7);
5988 if (scheme != null) {
5989 data = scheme + ':' + data;
5990 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005991 } else if (data.startsWith("android-app:")) {
5992 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5993 // Correctly formed android-app, first part is package name.
5994 int end = data.indexOf('/', 14);
5995 if (end < 0) {
5996 // All we have is a package name.
5997 intent.mPackage = data.substring(14);
5998 if (!explicitAction) {
5999 intent.setAction(ACTION_MAIN);
6000 }
6001 data = "";
6002 } else {
6003 // Target the Intent at the given package name always.
6004 String authority = null;
6005 intent.mPackage = data.substring(14, end);
6006 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006007 if ((end+1) < data.length()) {
6008 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6009 // Found a scheme, remember it.
6010 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006011 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006012 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6013 // Found a authority, remember it.
6014 authority = data.substring(end+1, newEnd);
6015 end = newEnd;
6016 }
6017 } else {
6018 // All we have is a scheme.
6019 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006020 }
6021 }
6022 if (scheme == null) {
6023 // If there was no scheme, then this just targets the package.
6024 if (!explicitAction) {
6025 intent.setAction(ACTION_MAIN);
6026 }
6027 data = "";
6028 } else if (authority == null) {
6029 data = scheme + ":";
6030 } else {
6031 data = scheme + "://" + authority + data.substring(end);
6032 }
6033 }
6034 } else {
6035 data = "";
6036 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006037 }
Tom Taylord4a47292009-12-21 13:59:18 -08006038
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006039 if (data.length() > 0) {
6040 try {
6041 intent.mData = Uri.parse(data);
6042 } catch (IllegalArgumentException e) {
6043 throw new URISyntaxException(uri, e.getMessage());
6044 }
6045 }
6046 }
Tom Taylord4a47292009-12-21 13:59:18 -08006047
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006048 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006049
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006050 } catch (IndexOutOfBoundsException e) {
6051 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6052 }
6053 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006054
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006055 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006056 return getIntentOld(uri, 0);
6057 }
6058
6059 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006060 Intent intent;
6061
6062 int i = uri.lastIndexOf('#');
6063 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006064 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006065 final int intentFragmentStart = i;
6066 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006067
6068 i++;
6069
6070 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006071 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006072 i += 7;
6073 int j = uri.indexOf(')', i);
6074 action = uri.substring(i, j);
6075 i = j + 1;
6076 }
6077
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006078 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006079
6080 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006081 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006082 i += 11;
6083 int j = uri.indexOf(')', i);
6084 while (i < j) {
6085 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006086 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006087 if (i < sep) {
6088 intent.addCategory(uri.substring(i, sep));
6089 }
6090 i = sep + 1;
6091 }
6092 i = j + 1;
6093 }
6094
6095 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006096 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006097 i += 5;
6098 int j = uri.indexOf(')', i);
6099 intent.mType = uri.substring(i, j);
6100 i = j + 1;
6101 }
6102
6103 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006104 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006105 i += 12;
6106 int j = uri.indexOf(')', i);
6107 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006108 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6109 intent.mFlags &= ~IMMUTABLE_FLAGS;
6110 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006111 i = j + 1;
6112 }
6113
6114 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006115 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006116 i += 10;
6117 int j = uri.indexOf(')', i);
6118 int sep = uri.indexOf('!', i);
6119 if (sep >= 0 && sep < j) {
6120 String pkg = uri.substring(i, sep);
6121 String cls = uri.substring(sep + 1, j);
6122 intent.mComponent = new ComponentName(pkg, cls);
6123 }
6124 i = j + 1;
6125 }
6126
6127 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006128 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006129 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006130
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006131 final int closeParen = uri.indexOf(')', i);
6132 if (closeParen == -1) throw new URISyntaxException(uri,
6133 "EXTRA missing trailing ')'", i);
6134
6135 while (i < closeParen) {
6136 // fetch the key value
6137 int j = uri.indexOf('=', i);
6138 if (j <= i + 1 || i >= closeParen) {
6139 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6140 }
6141 char type = uri.charAt(i);
6142 i++;
6143 String key = uri.substring(i, j);
6144 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006145
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006146 // get type-value
6147 j = uri.indexOf('!', i);
6148 if (j == -1 || j >= closeParen) j = closeParen;
6149 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6150 String value = uri.substring(i, j);
6151 i = j;
6152
6153 // create Bundle if it doesn't already exist
6154 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006155
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006156 // add item to bundle
6157 try {
6158 switch (type) {
6159 case 'S':
6160 intent.mExtras.putString(key, Uri.decode(value));
6161 break;
6162 case 'B':
6163 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6164 break;
6165 case 'b':
6166 intent.mExtras.putByte(key, Byte.parseByte(value));
6167 break;
6168 case 'c':
6169 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6170 break;
6171 case 'd':
6172 intent.mExtras.putDouble(key, Double.parseDouble(value));
6173 break;
6174 case 'f':
6175 intent.mExtras.putFloat(key, Float.parseFloat(value));
6176 break;
6177 case 'i':
6178 intent.mExtras.putInt(key, Integer.parseInt(value));
6179 break;
6180 case 'l':
6181 intent.mExtras.putLong(key, Long.parseLong(value));
6182 break;
6183 case 's':
6184 intent.mExtras.putShort(key, Short.parseShort(value));
6185 break;
6186 default:
6187 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6188 }
6189 } catch (NumberFormatException e) {
6190 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6191 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006192
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006193 char ch = uri.charAt(i);
6194 if (ch == ')') break;
6195 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6196 i++;
6197 }
6198 }
6199
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006200 if (isIntentFragment) {
6201 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6202 } else {
6203 intent.mData = Uri.parse(uri);
6204 }
Tom Taylord4a47292009-12-21 13:59:18 -08006205
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006206 if (intent.mAction == null) {
6207 // By default, if no action is specified, then use VIEW.
6208 intent.mAction = ACTION_VIEW;
6209 }
6210
6211 } else {
6212 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6213 }
6214
6215 return intent;
6216 }
6217
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006218 /** @hide */
6219 public interface CommandOptionHandler {
6220 boolean handleOption(String opt, ShellCommand cmd);
6221 }
6222
6223 /** @hide */
6224 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6225 throws URISyntaxException {
6226 Intent intent = new Intent();
6227 Intent baseIntent = intent;
6228 boolean hasIntentInfo = false;
6229
6230 Uri data = null;
6231 String type = null;
6232
6233 String opt;
6234 while ((opt=cmd.getNextOption()) != null) {
6235 switch (opt) {
6236 case "-a":
6237 intent.setAction(cmd.getNextArgRequired());
6238 if (intent == baseIntent) {
6239 hasIntentInfo = true;
6240 }
6241 break;
6242 case "-d":
6243 data = Uri.parse(cmd.getNextArgRequired());
6244 if (intent == baseIntent) {
6245 hasIntentInfo = true;
6246 }
6247 break;
6248 case "-t":
6249 type = cmd.getNextArgRequired();
6250 if (intent == baseIntent) {
6251 hasIntentInfo = true;
6252 }
6253 break;
6254 case "-c":
6255 intent.addCategory(cmd.getNextArgRequired());
6256 if (intent == baseIntent) {
6257 hasIntentInfo = true;
6258 }
6259 break;
6260 case "-e":
6261 case "--es": {
6262 String key = cmd.getNextArgRequired();
6263 String value = cmd.getNextArgRequired();
6264 intent.putExtra(key, value);
6265 }
6266 break;
6267 case "--esn": {
6268 String key = cmd.getNextArgRequired();
6269 intent.putExtra(key, (String) null);
6270 }
6271 break;
6272 case "--ei": {
6273 String key = cmd.getNextArgRequired();
6274 String value = cmd.getNextArgRequired();
6275 intent.putExtra(key, Integer.decode(value));
6276 }
6277 break;
6278 case "--eu": {
6279 String key = cmd.getNextArgRequired();
6280 String value = cmd.getNextArgRequired();
6281 intent.putExtra(key, Uri.parse(value));
6282 }
6283 break;
6284 case "--ecn": {
6285 String key = cmd.getNextArgRequired();
6286 String value = cmd.getNextArgRequired();
6287 ComponentName cn = ComponentName.unflattenFromString(value);
6288 if (cn == null)
6289 throw new IllegalArgumentException("Bad component name: " + value);
6290 intent.putExtra(key, cn);
6291 }
6292 break;
6293 case "--eia": {
6294 String key = cmd.getNextArgRequired();
6295 String value = cmd.getNextArgRequired();
6296 String[] strings = value.split(",");
6297 int[] list = new int[strings.length];
6298 for (int i = 0; i < strings.length; i++) {
6299 list[i] = Integer.decode(strings[i]);
6300 }
6301 intent.putExtra(key, list);
6302 }
6303 break;
6304 case "--eial": {
6305 String key = cmd.getNextArgRequired();
6306 String value = cmd.getNextArgRequired();
6307 String[] strings = value.split(",");
6308 ArrayList<Integer> list = new ArrayList<>(strings.length);
6309 for (int i = 0; i < strings.length; i++) {
6310 list.add(Integer.decode(strings[i]));
6311 }
6312 intent.putExtra(key, list);
6313 }
6314 break;
6315 case "--el": {
6316 String key = cmd.getNextArgRequired();
6317 String value = cmd.getNextArgRequired();
6318 intent.putExtra(key, Long.valueOf(value));
6319 }
6320 break;
6321 case "--ela": {
6322 String key = cmd.getNextArgRequired();
6323 String value = cmd.getNextArgRequired();
6324 String[] strings = value.split(",");
6325 long[] list = new long[strings.length];
6326 for (int i = 0; i < strings.length; i++) {
6327 list[i] = Long.valueOf(strings[i]);
6328 }
6329 intent.putExtra(key, list);
6330 hasIntentInfo = true;
6331 }
6332 break;
6333 case "--elal": {
6334 String key = cmd.getNextArgRequired();
6335 String value = cmd.getNextArgRequired();
6336 String[] strings = value.split(",");
6337 ArrayList<Long> list = new ArrayList<>(strings.length);
6338 for (int i = 0; i < strings.length; i++) {
6339 list.add(Long.valueOf(strings[i]));
6340 }
6341 intent.putExtra(key, list);
6342 hasIntentInfo = true;
6343 }
6344 break;
6345 case "--ef": {
6346 String key = cmd.getNextArgRequired();
6347 String value = cmd.getNextArgRequired();
6348 intent.putExtra(key, Float.valueOf(value));
6349 hasIntentInfo = true;
6350 }
6351 break;
6352 case "--efa": {
6353 String key = cmd.getNextArgRequired();
6354 String value = cmd.getNextArgRequired();
6355 String[] strings = value.split(",");
6356 float[] list = new float[strings.length];
6357 for (int i = 0; i < strings.length; i++) {
6358 list[i] = Float.valueOf(strings[i]);
6359 }
6360 intent.putExtra(key, list);
6361 hasIntentInfo = true;
6362 }
6363 break;
6364 case "--efal": {
6365 String key = cmd.getNextArgRequired();
6366 String value = cmd.getNextArgRequired();
6367 String[] strings = value.split(",");
6368 ArrayList<Float> list = new ArrayList<>(strings.length);
6369 for (int i = 0; i < strings.length; i++) {
6370 list.add(Float.valueOf(strings[i]));
6371 }
6372 intent.putExtra(key, list);
6373 hasIntentInfo = true;
6374 }
6375 break;
6376 case "--esa": {
6377 String key = cmd.getNextArgRequired();
6378 String value = cmd.getNextArgRequired();
6379 // Split on commas unless they are preceeded by an escape.
6380 // The escape character must be escaped for the string and
6381 // again for the regex, thus four escape characters become one.
6382 String[] strings = value.split("(?<!\\\\),");
6383 intent.putExtra(key, strings);
6384 hasIntentInfo = true;
6385 }
6386 break;
6387 case "--esal": {
6388 String key = cmd.getNextArgRequired();
6389 String value = cmd.getNextArgRequired();
6390 // Split on commas unless they are preceeded by an escape.
6391 // The escape character must be escaped for the string and
6392 // again for the regex, thus four escape characters become one.
6393 String[] strings = value.split("(?<!\\\\),");
6394 ArrayList<String> list = new ArrayList<>(strings.length);
6395 for (int i = 0; i < strings.length; i++) {
6396 list.add(strings[i]);
6397 }
6398 intent.putExtra(key, list);
6399 hasIntentInfo = true;
6400 }
6401 break;
6402 case "--ez": {
6403 String key = cmd.getNextArgRequired();
6404 String value = cmd.getNextArgRequired().toLowerCase();
6405 // Boolean.valueOf() results in false for anything that is not "true", which is
6406 // error-prone in shell commands
6407 boolean arg;
6408 if ("true".equals(value) || "t".equals(value)) {
6409 arg = true;
6410 } else if ("false".equals(value) || "f".equals(value)) {
6411 arg = false;
6412 } else {
6413 try {
6414 arg = Integer.decode(value) != 0;
6415 } catch (NumberFormatException ex) {
6416 throw new IllegalArgumentException("Invalid boolean value: " + value);
6417 }
6418 }
6419
6420 intent.putExtra(key, arg);
6421 }
6422 break;
6423 case "-n": {
6424 String str = cmd.getNextArgRequired();
6425 ComponentName cn = ComponentName.unflattenFromString(str);
6426 if (cn == null)
6427 throw new IllegalArgumentException("Bad component name: " + str);
6428 intent.setComponent(cn);
6429 if (intent == baseIntent) {
6430 hasIntentInfo = true;
6431 }
6432 }
6433 break;
6434 case "-p": {
6435 String str = cmd.getNextArgRequired();
6436 intent.setPackage(str);
6437 if (intent == baseIntent) {
6438 hasIntentInfo = true;
6439 }
6440 }
6441 break;
6442 case "-f":
6443 String str = cmd.getNextArgRequired();
6444 intent.setFlags(Integer.decode(str).intValue());
6445 break;
6446 case "--grant-read-uri-permission":
6447 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6448 break;
6449 case "--grant-write-uri-permission":
6450 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6451 break;
6452 case "--grant-persistable-uri-permission":
6453 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6454 break;
6455 case "--grant-prefix-uri-permission":
6456 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6457 break;
6458 case "--exclude-stopped-packages":
6459 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6460 break;
6461 case "--include-stopped-packages":
6462 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6463 break;
6464 case "--debug-log-resolution":
6465 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6466 break;
6467 case "--activity-brought-to-front":
6468 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6469 break;
6470 case "--activity-clear-top":
6471 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6472 break;
6473 case "--activity-clear-when-task-reset":
6474 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6475 break;
6476 case "--activity-exclude-from-recents":
6477 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6478 break;
6479 case "--activity-launched-from-history":
6480 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6481 break;
6482 case "--activity-multiple-task":
6483 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6484 break;
6485 case "--activity-no-animation":
6486 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6487 break;
6488 case "--activity-no-history":
6489 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6490 break;
6491 case "--activity-no-user-action":
6492 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6493 break;
6494 case "--activity-previous-is-top":
6495 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6496 break;
6497 case "--activity-reorder-to-front":
6498 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6499 break;
6500 case "--activity-reset-task-if-needed":
6501 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6502 break;
6503 case "--activity-single-top":
6504 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6505 break;
6506 case "--activity-clear-task":
6507 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6508 break;
6509 case "--activity-task-on-home":
6510 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6511 break;
6512 case "--receiver-registered-only":
6513 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6514 break;
6515 case "--receiver-replace-pending":
6516 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6517 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006518 case "--receiver-foreground":
6519 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6520 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006521 case "--receiver-no-abort":
6522 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6523 break;
6524 case "--receiver-include-background":
6525 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6526 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006527 case "--selector":
6528 intent.setDataAndType(data, type);
6529 intent = new Intent();
6530 break;
6531 default:
6532 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6533 // Okay, caller handled this option.
6534 } else {
6535 throw new IllegalArgumentException("Unknown option: " + opt);
6536 }
6537 break;
6538 }
6539 }
6540 intent.setDataAndType(data, type);
6541
6542 final boolean hasSelector = intent != baseIntent;
6543 if (hasSelector) {
6544 // A selector was specified; fix up.
6545 baseIntent.setSelector(intent);
6546 intent = baseIntent;
6547 }
6548
6549 String arg = cmd.getNextArg();
6550 baseIntent = null;
6551 if (arg == null) {
6552 if (hasSelector) {
6553 // If a selector has been specified, and no arguments
6554 // have been supplied for the main Intent, then we can
6555 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6556 // need to have a component name specified yet, the
6557 // selector will take care of that.
6558 baseIntent = new Intent(Intent.ACTION_MAIN);
6559 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6560 }
6561 } else if (arg.indexOf(':') >= 0) {
6562 // The argument is a URI. Fully parse it, and use that result
6563 // to fill in any data not specified so far.
6564 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6565 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6566 } else if (arg.indexOf('/') >= 0) {
6567 // The argument is a component name. Build an Intent to launch
6568 // it.
6569 baseIntent = new Intent(Intent.ACTION_MAIN);
6570 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6571 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6572 } else {
6573 // Assume the argument is a package name.
6574 baseIntent = new Intent(Intent.ACTION_MAIN);
6575 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6576 baseIntent.setPackage(arg);
6577 }
6578 if (baseIntent != null) {
6579 Bundle extras = intent.getExtras();
6580 intent.replaceExtras((Bundle)null);
6581 Bundle uriExtras = baseIntent.getExtras();
6582 baseIntent.replaceExtras((Bundle)null);
6583 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6584 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6585 for (String c : cats) {
6586 baseIntent.removeCategory(c);
6587 }
6588 }
6589 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6590 if (extras == null) {
6591 extras = uriExtras;
6592 } else if (uriExtras != null) {
6593 uriExtras.putAll(extras);
6594 extras = uriExtras;
6595 }
6596 intent.replaceExtras(extras);
6597 hasIntentInfo = true;
6598 }
6599
6600 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6601 return intent;
6602 }
6603
6604 /** @hide */
6605 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6606 final String[] lines = new String[] {
6607 "<INTENT> specifications include these flags and arguments:",
6608 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6609 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6610 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6611 " [--esn <EXTRA_KEY> ...]",
6612 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6613 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6614 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6615 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6616 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6617 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6618 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6619 " (mutiple extras passed as Integer[])",
6620 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6621 " (mutiple extras passed as List<Integer>)",
6622 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6623 " (mutiple extras passed as Long[])",
6624 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6625 " (mutiple extras passed as List<Long>)",
6626 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6627 " (mutiple extras passed as Float[])",
6628 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6629 " (mutiple extras passed as List<Float>)",
6630 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6631 " (mutiple extras passed as String[]; to embed a comma into a string,",
6632 " escape it using \"\\,\")",
6633 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6634 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6635 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006636 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006637 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6638 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6639 " [--debug-log-resolution] [--exclude-stopped-packages]",
6640 " [--include-stopped-packages]",
6641 " [--activity-brought-to-front] [--activity-clear-top]",
6642 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6643 " [--activity-launched-from-history] [--activity-multiple-task]",
6644 " [--activity-no-animation] [--activity-no-history]",
6645 " [--activity-no-user-action] [--activity-previous-is-top]",
6646 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6647 " [--activity-single-top] [--activity-clear-task]",
6648 " [--activity-task-on-home]",
6649 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006650 " [--receiver-foreground] [--receiver-no-abort]",
6651 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006652 " [--selector]",
6653 " [<URI> | <PACKAGE> | <COMPONENT>]"
6654 };
6655 for (String line : lines) {
6656 pw.print(prefix);
6657 pw.println(line);
6658 }
6659 }
6660
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006661 /**
6662 * Retrieve the general action to be performed, such as
6663 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6664 * the information in the intent should be interpreted -- most importantly,
6665 * what to do with the data returned by {@link #getData}.
6666 *
6667 * @return The action of this intent or null if none is specified.
6668 *
6669 * @see #setAction
6670 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006671 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006672 return mAction;
6673 }
6674
6675 /**
6676 * Retrieve data this intent is operating on. This URI specifies the name
6677 * of the data; often it uses the content: scheme, specifying data in a
6678 * content provider. Other schemes may be handled by specific activities,
6679 * such as http: by the web browser.
6680 *
6681 * @return The URI of the data this intent is targeting or null.
6682 *
6683 * @see #getScheme
6684 * @see #setData
6685 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006686 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006687 return mData;
6688 }
6689
6690 /**
6691 * The same as {@link #getData()}, but returns the URI as an encoded
6692 * String.
6693 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006694 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006695 return mData != null ? mData.toString() : null;
6696 }
6697
6698 /**
6699 * Return the scheme portion of the intent's data. If the data is null or
6700 * does not include a scheme, null is returned. Otherwise, the scheme
6701 * prefix without the final ':' is returned, i.e. "http".
6702 *
6703 * <p>This is the same as calling getData().getScheme() (and checking for
6704 * null data).
6705 *
6706 * @return The scheme of this intent.
6707 *
6708 * @see #getData
6709 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006710 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006711 return mData != null ? mData.getScheme() : null;
6712 }
6713
6714 /**
6715 * Retrieve any explicit MIME type included in the intent. This is usually
6716 * null, as the type is determined by the intent data.
6717 *
6718 * @return If a type was manually set, it is returned; else null is
6719 * returned.
6720 *
6721 * @see #resolveType(ContentResolver)
6722 * @see #setType
6723 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006724 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006725 return mType;
6726 }
6727
6728 /**
6729 * Return the MIME data type of this intent. If the type field is
6730 * explicitly set, that is simply returned. Otherwise, if the data is set,
6731 * the type of that data is returned. If neither fields are set, a null is
6732 * returned.
6733 *
6734 * @return The MIME type of this intent.
6735 *
6736 * @see #getType
6737 * @see #resolveType(ContentResolver)
6738 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006739 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006740 return resolveType(context.getContentResolver());
6741 }
6742
6743 /**
6744 * Return the MIME data type of this intent. If the type field is
6745 * explicitly set, that is simply returned. Otherwise, if the data is set,
6746 * the type of that data is returned. If neither fields are set, a null is
6747 * returned.
6748 *
6749 * @param resolver A ContentResolver that can be used to determine the MIME
6750 * type of the intent's data.
6751 *
6752 * @return The MIME type of this intent.
6753 *
6754 * @see #getType
6755 * @see #resolveType(Context)
6756 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006757 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006758 if (mType != null) {
6759 return mType;
6760 }
6761 if (mData != null) {
6762 if ("content".equals(mData.getScheme())) {
6763 return resolver.getType(mData);
6764 }
6765 }
6766 return null;
6767 }
6768
6769 /**
6770 * Return the MIME data type of this intent, only if it will be needed for
6771 * intent resolution. This is not generally useful for application code;
6772 * it is used by the frameworks for communicating with back-end system
6773 * services.
6774 *
6775 * @param resolver A ContentResolver that can be used to determine the MIME
6776 * type of the intent's data.
6777 *
6778 * @return The MIME type of this intent, or null if it is unknown or not
6779 * needed.
6780 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006781 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006782 if (mComponent != null) {
6783 return mType;
6784 }
6785 return resolveType(resolver);
6786 }
6787
6788 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006789 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006790 *
6791 * @param category The category to check.
6792 *
6793 * @return boolean True if the intent contains the category, else false.
6794 *
6795 * @see #getCategories
6796 * @see #addCategory
6797 */
6798 public boolean hasCategory(String category) {
6799 return mCategories != null && mCategories.contains(category);
6800 }
6801
6802 /**
6803 * Return the set of all categories in the intent. If there are no categories,
6804 * returns NULL.
6805 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006806 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006807 *
6808 * @see #hasCategory
6809 * @see #addCategory
6810 */
6811 public Set<String> getCategories() {
6812 return mCategories;
6813 }
6814
6815 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006816 * Return the specific selector associated with this Intent. If there is
6817 * none, returns null. See {@link #setSelector} for more information.
6818 *
6819 * @see #setSelector
6820 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006821 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006822 return mSelector;
6823 }
6824
6825 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006826 * Return the {@link ClipData} associated with this Intent. If there is
6827 * none, returns null. See {@link #setClipData} for more information.
6828 *
John Spurlock125d1332013-11-25 11:58:37 -05006829 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006830 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006831 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006832 return mClipData;
6833 }
6834
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006835 /** @hide */
6836 public int getContentUserHint() {
6837 return mContentUserHint;
6838 }
6839
Todd Kennedyb3b431302017-03-20 16:05:48 -07006840 /** @hide */
6841 public String getLaunchToken() {
6842 return mLaunchToken;
6843 }
6844
6845 /** @hide */
6846 public void setLaunchToken(String launchToken) {
6847 mLaunchToken = launchToken;
6848 }
6849
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006850 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006851 * Sets the ClassLoader that will be used when unmarshalling
6852 * any Parcelable values from the extras of this Intent.
6853 *
6854 * @param loader a ClassLoader, or null to use the default loader
6855 * at the time of unmarshalling.
6856 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006857 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006858 if (mExtras != null) {
6859 mExtras.setClassLoader(loader);
6860 }
6861 }
6862
6863 /**
6864 * Returns true if an extra value is associated with the given name.
6865 * @param name the extra's name
6866 * @return true if the given extra is present.
6867 */
6868 public boolean hasExtra(String name) {
6869 return mExtras != null && mExtras.containsKey(name);
6870 }
6871
6872 /**
6873 * Returns true if the Intent's extras contain a parcelled file descriptor.
6874 * @return true if the Intent contains a parcelled file descriptor.
6875 */
6876 public boolean hasFileDescriptors() {
6877 return mExtras != null && mExtras.hasFileDescriptors();
6878 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006879
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006880 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006881 public void setAllowFds(boolean allowFds) {
6882 if (mExtras != null) {
6883 mExtras.setAllowFds(allowFds);
6884 }
6885 }
6886
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006887 /** {@hide} */
6888 public void setDefusable(boolean defusable) {
6889 if (mExtras != null) {
6890 mExtras.setDefusable(defusable);
6891 }
6892 }
6893
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006894 /**
6895 * Retrieve extended data from the intent.
6896 *
6897 * @param name The name of the desired item.
6898 *
6899 * @return the value of an item that previously added with putExtra()
6900 * or null if none was found.
6901 *
6902 * @deprecated
6903 * @hide
6904 */
6905 @Deprecated
6906 public Object getExtra(String name) {
6907 return getExtra(name, null);
6908 }
6909
6910 /**
6911 * Retrieve extended data from the intent.
6912 *
6913 * @param name The name of the desired item.
6914 * @param defaultValue the value to be returned if no value of the desired
6915 * type is stored with the given name.
6916 *
6917 * @return the value of an item that previously added with putExtra()
6918 * or the default value if none was found.
6919 *
6920 * @see #putExtra(String, boolean)
6921 */
6922 public boolean getBooleanExtra(String name, boolean defaultValue) {
6923 return mExtras == null ? defaultValue :
6924 mExtras.getBoolean(name, defaultValue);
6925 }
6926
6927 /**
6928 * Retrieve extended data from the intent.
6929 *
6930 * @param name The name of the desired item.
6931 * @param defaultValue the value to be returned if no value of the desired
6932 * type is stored with the given name.
6933 *
6934 * @return the value of an item that previously added with putExtra()
6935 * or the default value if none was found.
6936 *
6937 * @see #putExtra(String, byte)
6938 */
6939 public byte getByteExtra(String name, byte defaultValue) {
6940 return mExtras == null ? defaultValue :
6941 mExtras.getByte(name, defaultValue);
6942 }
6943
6944 /**
6945 * Retrieve extended data from the intent.
6946 *
6947 * @param name The name of the desired item.
6948 * @param defaultValue the value to be returned if no value of the desired
6949 * type is stored with the given name.
6950 *
6951 * @return the value of an item that previously added with putExtra()
6952 * or the default value if none was found.
6953 *
6954 * @see #putExtra(String, short)
6955 */
6956 public short getShortExtra(String name, short defaultValue) {
6957 return mExtras == null ? defaultValue :
6958 mExtras.getShort(name, defaultValue);
6959 }
6960
6961 /**
6962 * Retrieve extended data from the intent.
6963 *
6964 * @param name The name of the desired item.
6965 * @param defaultValue the value to be returned if no value of the desired
6966 * type is stored with the given name.
6967 *
6968 * @return the value of an item that previously added with putExtra()
6969 * or the default value if none was found.
6970 *
6971 * @see #putExtra(String, char)
6972 */
6973 public char getCharExtra(String name, char defaultValue) {
6974 return mExtras == null ? defaultValue :
6975 mExtras.getChar(name, defaultValue);
6976 }
6977
6978 /**
6979 * Retrieve extended data from the intent.
6980 *
6981 * @param name The name of the desired item.
6982 * @param defaultValue the value to be returned if no value of the desired
6983 * type is stored with the given name.
6984 *
6985 * @return the value of an item that previously added with putExtra()
6986 * or the default value if none was found.
6987 *
6988 * @see #putExtra(String, int)
6989 */
6990 public int getIntExtra(String name, int defaultValue) {
6991 return mExtras == null ? defaultValue :
6992 mExtras.getInt(name, defaultValue);
6993 }
6994
6995 /**
6996 * Retrieve extended data from the intent.
6997 *
6998 * @param name The name of the desired item.
6999 * @param defaultValue the value to be returned if no value of the desired
7000 * type is stored with the given name.
7001 *
7002 * @return the value of an item that previously added with putExtra()
7003 * or the default value if none was found.
7004 *
7005 * @see #putExtra(String, long)
7006 */
7007 public long getLongExtra(String name, long defaultValue) {
7008 return mExtras == null ? defaultValue :
7009 mExtras.getLong(name, defaultValue);
7010 }
7011
7012 /**
7013 * Retrieve extended data from the intent.
7014 *
7015 * @param name The name of the desired item.
7016 * @param defaultValue the value to be returned if no value of the desired
7017 * type is stored with the given name.
7018 *
7019 * @return the value of an item that previously added with putExtra(),
7020 * or the default value if no such item is present
7021 *
7022 * @see #putExtra(String, float)
7023 */
7024 public float getFloatExtra(String name, float defaultValue) {
7025 return mExtras == null ? defaultValue :
7026 mExtras.getFloat(name, defaultValue);
7027 }
7028
7029 /**
7030 * Retrieve extended data from the intent.
7031 *
7032 * @param name The name of the desired item.
7033 * @param defaultValue the value to be returned if no value of the desired
7034 * type is stored with the given name.
7035 *
7036 * @return the value of an item that previously added with putExtra()
7037 * or the default value if none was found.
7038 *
7039 * @see #putExtra(String, double)
7040 */
7041 public double getDoubleExtra(String name, double defaultValue) {
7042 return mExtras == null ? defaultValue :
7043 mExtras.getDouble(name, defaultValue);
7044 }
7045
7046 /**
7047 * Retrieve extended data from the intent.
7048 *
7049 * @param name The name of the desired item.
7050 *
7051 * @return the value of an item that previously added with putExtra()
7052 * or null if no String value was found.
7053 *
7054 * @see #putExtra(String, String)
7055 */
7056 public String getStringExtra(String name) {
7057 return mExtras == null ? null : mExtras.getString(name);
7058 }
7059
7060 /**
7061 * Retrieve extended data from the intent.
7062 *
7063 * @param name The name of the desired item.
7064 *
7065 * @return the value of an item that previously added with putExtra()
7066 * or null if no CharSequence value was found.
7067 *
7068 * @see #putExtra(String, CharSequence)
7069 */
7070 public CharSequence getCharSequenceExtra(String name) {
7071 return mExtras == null ? null : mExtras.getCharSequence(name);
7072 }
7073
7074 /**
7075 * Retrieve extended data from the intent.
7076 *
7077 * @param name The name of the desired item.
7078 *
7079 * @return the value of an item that previously added with putExtra()
7080 * or null if no Parcelable value was found.
7081 *
7082 * @see #putExtra(String, Parcelable)
7083 */
7084 public <T extends Parcelable> T getParcelableExtra(String name) {
7085 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7086 }
7087
7088 /**
7089 * Retrieve extended data from the intent.
7090 *
7091 * @param name The name of the desired item.
7092 *
7093 * @return the value of an item that previously added with putExtra()
7094 * or null if no Parcelable[] value was found.
7095 *
7096 * @see #putExtra(String, Parcelable[])
7097 */
7098 public Parcelable[] getParcelableArrayExtra(String name) {
7099 return mExtras == null ? null : mExtras.getParcelableArray(name);
7100 }
7101
7102 /**
7103 * Retrieve extended data from the intent.
7104 *
7105 * @param name The name of the desired item.
7106 *
7107 * @return the value of an item that previously added with putExtra()
7108 * or null if no ArrayList<Parcelable> value was found.
7109 *
7110 * @see #putParcelableArrayListExtra(String, ArrayList)
7111 */
7112 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7113 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7114 }
7115
7116 /**
7117 * Retrieve extended data from the intent.
7118 *
7119 * @param name The name of the desired item.
7120 *
7121 * @return the value of an item that previously added with putExtra()
7122 * or null if no Serializable value was found.
7123 *
7124 * @see #putExtra(String, Serializable)
7125 */
7126 public Serializable getSerializableExtra(String name) {
7127 return mExtras == null ? null : mExtras.getSerializable(name);
7128 }
7129
7130 /**
7131 * Retrieve extended data from the intent.
7132 *
7133 * @param name The name of the desired item.
7134 *
7135 * @return the value of an item that previously added with putExtra()
7136 * or null if no ArrayList<Integer> value was found.
7137 *
7138 * @see #putIntegerArrayListExtra(String, ArrayList)
7139 */
7140 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7141 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7142 }
7143
7144 /**
7145 * Retrieve extended data from the intent.
7146 *
7147 * @param name The name of the desired item.
7148 *
7149 * @return the value of an item that previously added with putExtra()
7150 * or null if no ArrayList<String> value was found.
7151 *
7152 * @see #putStringArrayListExtra(String, ArrayList)
7153 */
7154 public ArrayList<String> getStringArrayListExtra(String name) {
7155 return mExtras == null ? null : mExtras.getStringArrayList(name);
7156 }
7157
7158 /**
7159 * Retrieve extended data from the intent.
7160 *
7161 * @param name The name of the desired item.
7162 *
7163 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007164 * or null if no ArrayList<CharSequence> value was found.
7165 *
7166 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7167 */
7168 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7169 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7170 }
7171
7172 /**
7173 * Retrieve extended data from the intent.
7174 *
7175 * @param name The name of the desired item.
7176 *
7177 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007178 * or null if no boolean array value was found.
7179 *
7180 * @see #putExtra(String, boolean[])
7181 */
7182 public boolean[] getBooleanArrayExtra(String name) {
7183 return mExtras == null ? null : mExtras.getBooleanArray(name);
7184 }
7185
7186 /**
7187 * Retrieve extended data from the intent.
7188 *
7189 * @param name The name of the desired item.
7190 *
7191 * @return the value of an item that previously added with putExtra()
7192 * or null if no byte array value was found.
7193 *
7194 * @see #putExtra(String, byte[])
7195 */
7196 public byte[] getByteArrayExtra(String name) {
7197 return mExtras == null ? null : mExtras.getByteArray(name);
7198 }
7199
7200 /**
7201 * Retrieve extended data from the intent.
7202 *
7203 * @param name The name of the desired item.
7204 *
7205 * @return the value of an item that previously added with putExtra()
7206 * or null if no short array value was found.
7207 *
7208 * @see #putExtra(String, short[])
7209 */
7210 public short[] getShortArrayExtra(String name) {
7211 return mExtras == null ? null : mExtras.getShortArray(name);
7212 }
7213
7214 /**
7215 * Retrieve extended data from the intent.
7216 *
7217 * @param name The name of the desired item.
7218 *
7219 * @return the value of an item that previously added with putExtra()
7220 * or null if no char array value was found.
7221 *
7222 * @see #putExtra(String, char[])
7223 */
7224 public char[] getCharArrayExtra(String name) {
7225 return mExtras == null ? null : mExtras.getCharArray(name);
7226 }
7227
7228 /**
7229 * Retrieve extended data from the intent.
7230 *
7231 * @param name The name of the desired item.
7232 *
7233 * @return the value of an item that previously added with putExtra()
7234 * or null if no int array value was found.
7235 *
7236 * @see #putExtra(String, int[])
7237 */
7238 public int[] getIntArrayExtra(String name) {
7239 return mExtras == null ? null : mExtras.getIntArray(name);
7240 }
7241
7242 /**
7243 * Retrieve extended data from the intent.
7244 *
7245 * @param name The name of the desired item.
7246 *
7247 * @return the value of an item that previously added with putExtra()
7248 * or null if no long array value was found.
7249 *
7250 * @see #putExtra(String, long[])
7251 */
7252 public long[] getLongArrayExtra(String name) {
7253 return mExtras == null ? null : mExtras.getLongArray(name);
7254 }
7255
7256 /**
7257 * Retrieve extended data from the intent.
7258 *
7259 * @param name The name of the desired item.
7260 *
7261 * @return the value of an item that previously added with putExtra()
7262 * or null if no float array value was found.
7263 *
7264 * @see #putExtra(String, float[])
7265 */
7266 public float[] getFloatArrayExtra(String name) {
7267 return mExtras == null ? null : mExtras.getFloatArray(name);
7268 }
7269
7270 /**
7271 * Retrieve extended data from the intent.
7272 *
7273 * @param name The name of the desired item.
7274 *
7275 * @return the value of an item that previously added with putExtra()
7276 * or null if no double array value was found.
7277 *
7278 * @see #putExtra(String, double[])
7279 */
7280 public double[] getDoubleArrayExtra(String name) {
7281 return mExtras == null ? null : mExtras.getDoubleArray(name);
7282 }
7283
7284 /**
7285 * Retrieve extended data from the intent.
7286 *
7287 * @param name The name of the desired item.
7288 *
7289 * @return the value of an item that previously added with putExtra()
7290 * or null if no String array value was found.
7291 *
7292 * @see #putExtra(String, String[])
7293 */
7294 public String[] getStringArrayExtra(String name) {
7295 return mExtras == null ? null : mExtras.getStringArray(name);
7296 }
7297
7298 /**
7299 * Retrieve extended data from the intent.
7300 *
7301 * @param name The name of the desired item.
7302 *
7303 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007304 * or null if no CharSequence array value was found.
7305 *
7306 * @see #putExtra(String, CharSequence[])
7307 */
7308 public CharSequence[] getCharSequenceArrayExtra(String name) {
7309 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7310 }
7311
7312 /**
7313 * Retrieve extended data from the intent.
7314 *
7315 * @param name The name of the desired item.
7316 *
7317 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007318 * or null if no Bundle value was found.
7319 *
7320 * @see #putExtra(String, Bundle)
7321 */
7322 public Bundle getBundleExtra(String name) {
7323 return mExtras == null ? null : mExtras.getBundle(name);
7324 }
7325
7326 /**
7327 * Retrieve extended data from the intent.
7328 *
7329 * @param name The name of the desired item.
7330 *
7331 * @return the value of an item that previously added with putExtra()
7332 * or null if no IBinder value was found.
7333 *
7334 * @see #putExtra(String, IBinder)
7335 *
7336 * @deprecated
7337 * @hide
7338 */
7339 @Deprecated
7340 public IBinder getIBinderExtra(String name) {
7341 return mExtras == null ? null : mExtras.getIBinder(name);
7342 }
7343
7344 /**
7345 * Retrieve extended data from the intent.
7346 *
7347 * @param name The name of the desired item.
7348 * @param defaultValue The default value to return in case no item is
7349 * associated with the key 'name'
7350 *
7351 * @return the value of an item that previously added with putExtra()
7352 * or defaultValue if none was found.
7353 *
7354 * @see #putExtra
7355 *
7356 * @deprecated
7357 * @hide
7358 */
7359 @Deprecated
7360 public Object getExtra(String name, Object defaultValue) {
7361 Object result = defaultValue;
7362 if (mExtras != null) {
7363 Object result2 = mExtras.get(name);
7364 if (result2 != null) {
7365 result = result2;
7366 }
7367 }
7368
7369 return result;
7370 }
7371
7372 /**
7373 * Retrieves a map of extended data from the intent.
7374 *
7375 * @return the map of all extras previously added with putExtra(),
7376 * or null if none have been added.
7377 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007378 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007379 return (mExtras != null)
7380 ? new Bundle(mExtras)
7381 : null;
7382 }
7383
7384 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007385 * Filter extras to only basic types.
7386 * @hide
7387 */
7388 public void removeUnsafeExtras() {
7389 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007390 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007391 }
7392 }
7393
7394 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007395 * Retrieve any special flags associated with this intent. You will
7396 * normally just set them with {@link #setFlags} and let the system
7397 * take the appropriate action with them.
7398 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007399 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007400 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007401 * @see #addFlags
7402 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007403 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007404 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007405 return mFlags;
7406 }
7407
Dianne Hackborne7f97212011-02-24 14:40:20 -08007408 /** @hide */
7409 public boolean isExcludingStopped() {
7410 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7411 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7412 }
7413
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007414 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007415 * Retrieve the application package name this Intent is limited to. When
7416 * resolving an Intent, if non-null this limits the resolution to only
7417 * components in the given application package.
7418 *
7419 * @return The name of the application package for the Intent.
7420 *
7421 * @see #resolveActivity
7422 * @see #setPackage
7423 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007424 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007425 return mPackage;
7426 }
7427
7428 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007429 * Retrieve the concrete component associated with the intent. When receiving
7430 * an intent, this is the component that was found to best handle it (that is,
7431 * yourself) and will always be non-null; in all other cases it will be
7432 * null unless explicitly set.
7433 *
7434 * @return The name of the application component to handle the intent.
7435 *
7436 * @see #resolveActivity
7437 * @see #setComponent
7438 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007439 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007440 return mComponent;
7441 }
7442
7443 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007444 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7445 * used as a hint to the receiver for animations and the like. Null means that there
7446 * is no source bounds.
7447 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007448 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007449 return mSourceBounds;
7450 }
7451
7452 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007453 * Return the Activity component that should be used to handle this intent.
7454 * The appropriate component is determined based on the information in the
7455 * intent, evaluated as follows:
7456 *
7457 * <p>If {@link #getComponent} returns an explicit class, that is returned
7458 * without any further consideration.
7459 *
7460 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7461 * category to be considered.
7462 *
7463 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7464 * action.
7465 *
7466 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7467 * this type.
7468 *
7469 * <p>If {@link #addCategory} has added any categories, the activity must
7470 * handle ALL of the categories specified.
7471 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007472 * <p>If {@link #getPackage} is non-NULL, only activity components in
7473 * that application package will be considered.
7474 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007475 * <p>If there are no activities that satisfy all of these conditions, a
7476 * null string is returned.
7477 *
7478 * <p>If multiple activities are found to satisfy the intent, the one with
7479 * the highest priority will be used. If there are multiple activities
7480 * with the same priority, the system will either pick the best activity
7481 * based on user preference, or resolve to a system class that will allow
7482 * the user to pick an activity and forward from there.
7483 *
7484 * <p>This method is implemented simply by calling
7485 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7486 * true.</p>
7487 * <p> This API is called for you as part of starting an activity from an
7488 * intent. You do not normally need to call it yourself.</p>
7489 *
7490 * @param pm The package manager with which to resolve the Intent.
7491 *
7492 * @return Name of the component implementing an activity that can
7493 * display the intent.
7494 *
7495 * @see #setComponent
7496 * @see #getComponent
7497 * @see #resolveActivityInfo
7498 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007499 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007500 if (mComponent != null) {
7501 return mComponent;
7502 }
7503
7504 ResolveInfo info = pm.resolveActivity(
7505 this, PackageManager.MATCH_DEFAULT_ONLY);
7506 if (info != null) {
7507 return new ComponentName(
7508 info.activityInfo.applicationInfo.packageName,
7509 info.activityInfo.name);
7510 }
7511
7512 return null;
7513 }
7514
7515 /**
7516 * Resolve the Intent into an {@link ActivityInfo}
7517 * describing the activity that should execute the intent. Resolution
7518 * follows the same rules as described for {@link #resolveActivity}, but
7519 * you get back the completely information about the resolved activity
7520 * instead of just its class name.
7521 *
7522 * @param pm The package manager with which to resolve the Intent.
7523 * @param flags Addition information to retrieve as per
7524 * {@link PackageManager#getActivityInfo(ComponentName, int)
7525 * PackageManager.getActivityInfo()}.
7526 *
7527 * @return PackageManager.ActivityInfo
7528 *
7529 * @see #resolveActivity
7530 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007531 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7532 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007533 ActivityInfo ai = null;
7534 if (mComponent != null) {
7535 try {
7536 ai = pm.getActivityInfo(mComponent, flags);
7537 } catch (PackageManager.NameNotFoundException e) {
7538 // ignore
7539 }
7540 } else {
7541 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007542 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007543 if (info != null) {
7544 ai = info.activityInfo;
7545 }
7546 }
7547
7548 return ai;
7549 }
7550
7551 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007552 * Special function for use by the system to resolve service
7553 * intents to system apps. Throws an exception if there are
7554 * multiple potential matches to the Intent. Returns null if
7555 * there are no matches.
7556 * @hide
7557 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007558 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7559 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007560 if (mComponent != null) {
7561 return mComponent;
7562 }
7563
7564 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7565 if (results == null) {
7566 return null;
7567 }
7568 ComponentName comp = null;
7569 for (int i=0; i<results.size(); i++) {
7570 ResolveInfo ri = results.get(i);
7571 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7572 continue;
7573 }
7574 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7575 ri.serviceInfo.name);
7576 if (comp != null) {
7577 throw new IllegalStateException("Multiple system services handle " + this
7578 + ": " + comp + ", " + foundComp);
7579 }
7580 comp = foundComp;
7581 }
7582 return comp;
7583 }
7584
7585 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007586 * Set the general action to be performed.
7587 *
7588 * @param action An action name, such as ACTION_VIEW. Application-specific
7589 * actions should be prefixed with the vendor's package name.
7590 *
7591 * @return Returns the same Intent object, for chaining multiple calls
7592 * into a single statement.
7593 *
7594 * @see #getAction
7595 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007596 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007597 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007598 return this;
7599 }
7600
7601 /**
7602 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007603 * clears any type that was previously set by {@link #setType} or
7604 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007605 *
Nick Pellyccae4122012-01-09 14:12:58 -08007606 * <p><em>Note: scheme matching in the Android framework is
7607 * case-sensitive, unlike the formal RFC. As a result,
7608 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007609 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007610 * {@link #setDataAndNormalize}
7611 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007612 *
Nick Pellyccae4122012-01-09 14:12:58 -08007613 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007614 *
7615 * @return Returns the same Intent object, for chaining multiple calls
7616 * into a single statement.
7617 *
7618 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007619 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007620 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007621 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007622 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007623 mData = data;
7624 mType = null;
7625 return this;
7626 }
7627
7628 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007629 * Normalize and set the data this intent is operating on.
7630 *
7631 * <p>This method automatically clears any type that was
7632 * previously set (for example, by {@link #setType}).
7633 *
7634 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007635 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007636 * so really this is just a convenience method for
7637 * <pre>
7638 * setData(data.normalize())
7639 * </pre>
7640 *
7641 * @param data The Uri of the data this intent is now targeting.
7642 *
7643 * @return Returns the same Intent object, for chaining multiple calls
7644 * into a single statement.
7645 *
7646 * @see #getData
7647 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007648 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007649 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007650 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007651 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007652 }
7653
7654 /**
7655 * Set an explicit MIME data type.
7656 *
7657 * <p>This is used to create intents that only specify a type and not data,
7658 * for example to indicate the type of data to return.
7659 *
7660 * <p>This method automatically clears any data that was
7661 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007662 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007663 * <p><em>Note: MIME type matching in the Android framework is
7664 * case-sensitive, unlike formal RFC MIME types. As a result,
7665 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007666 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7667 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007668 *
7669 * @param type The MIME type of the data being handled by this intent.
7670 *
7671 * @return Returns the same Intent object, for chaining multiple calls
7672 * into a single statement.
7673 *
7674 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007675 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007676 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007677 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007678 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007679 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007680 mData = null;
7681 mType = type;
7682 return this;
7683 }
7684
7685 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007686 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007687 *
Nick Pellyccae4122012-01-09 14:12:58 -08007688 * <p>This is used to create intents that only specify a type and not data,
7689 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007690 *
Nick Pellyccae4122012-01-09 14:12:58 -08007691 * <p>This method automatically clears any data that was
7692 * previously set (for example by {@link #setData}).
7693 *
7694 * <p>The MIME type is normalized using
7695 * {@link #normalizeMimeType} before it is set,
7696 * so really this is just a convenience method for
7697 * <pre>
7698 * setType(Intent.normalizeMimeType(type))
7699 * </pre>
7700 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007701 * @param type The MIME type of the data being handled by this intent.
7702 *
7703 * @return Returns the same Intent object, for chaining multiple calls
7704 * into a single statement.
7705 *
Nick Pellyccae4122012-01-09 14:12:58 -08007706 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007707 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007708 * @see #normalizeMimeType
7709 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007710 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08007711 return setType(normalizeMimeType(type));
7712 }
7713
7714 /**
7715 * (Usually optional) Set the data for the intent along with an explicit
7716 * MIME data type. This method should very rarely be used -- it allows you
7717 * to override the MIME type that would ordinarily be inferred from the
7718 * data with your own type given here.
7719 *
7720 * <p><em>Note: MIME type and Uri scheme matching in the
7721 * Android framework is case-sensitive, unlike the formal RFC definitions.
7722 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007723 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007724 * {@link #setDataAndTypeAndNormalize}
7725 * to ensure that they are converted to lower case.</em>
7726 *
7727 * @param data The Uri of the data this intent is now targeting.
7728 * @param type The MIME type of the data being handled by this intent.
7729 *
7730 * @return Returns the same Intent object, for chaining multiple calls
7731 * into a single statement.
7732 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007733 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007734 * @see #setData
7735 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007736 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007737 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007738 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007739 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007740 mData = data;
7741 mType = type;
7742 return this;
7743 }
7744
7745 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007746 * (Usually optional) Normalize and set both the data Uri and an explicit
7747 * MIME data type. This method should very rarely be used -- it allows you
7748 * to override the MIME type that would ordinarily be inferred from the
7749 * data with your own type given here.
7750 *
7751 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007752 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007753 * before they are set, so really this is just a convenience method for
7754 * <pre>
7755 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7756 * </pre>
7757 *
7758 * @param data The Uri of the data this intent is now targeting.
7759 * @param type The MIME type of the data being handled by this intent.
7760 *
7761 * @return Returns the same Intent object, for chaining multiple calls
7762 * into a single statement.
7763 *
7764 * @see #setType
7765 * @see #setData
7766 * @see #setDataAndType
7767 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007768 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007769 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007770 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007771 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007772 }
7773
7774 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007775 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007776 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007777 * activities that provide <em>all</em> of the requested categories will be
7778 * used.
7779 *
7780 * @param category The desired category. This can be either one of the
7781 * predefined Intent categories, or a custom category in your own
7782 * namespace.
7783 *
7784 * @return Returns the same Intent object, for chaining multiple calls
7785 * into a single statement.
7786 *
7787 * @see #hasCategory
7788 * @see #removeCategory
7789 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007790 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007791 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007792 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007793 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007794 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 return this;
7796 }
7797
7798 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007799 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007800 *
7801 * @param category The category to remove.
7802 *
7803 * @see #addCategory
7804 */
7805 public void removeCategory(String category) {
7806 if (mCategories != null) {
7807 mCategories.remove(category);
7808 if (mCategories.size() == 0) {
7809 mCategories = null;
7810 }
7811 }
7812 }
7813
7814 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007815 * Set a selector for this Intent. This is a modification to the kinds of
7816 * things the Intent will match. If the selector is set, it will be used
7817 * when trying to find entities that can handle the Intent, instead of the
7818 * main contents of the Intent. This allows you build an Intent containing
7819 * a generic protocol while targeting it more specifically.
7820 *
7821 * <p>An example of where this may be used is with things like
7822 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7823 * Intent that will launch the Browser application. However, the correct
7824 * main entry point of an application is actually {@link #ACTION_MAIN}
7825 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7826 * used to specify the actual Activity to launch. If you launch the browser
7827 * with something different, undesired behavior may happen if the user has
7828 * previously or later launches it the normal way, since they do not match.
7829 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7830 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7831 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7832 *
7833 * <p>Setting a selector does not impact the behavior of
7834 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7835 * desired behavior of a selector -- it does not impact the base meaning
7836 * of the Intent, just what kinds of things will be matched against it
7837 * when determining who can handle it.</p>
7838 *
7839 * <p>You can not use both a selector and {@link #setPackage(String)} on
7840 * the same base Intent.</p>
7841 *
7842 * @param selector The desired selector Intent; set to null to not use
7843 * a special selector.
7844 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007845 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007846 if (selector == this) {
7847 throw new IllegalArgumentException(
7848 "Intent being set as a selector of itself");
7849 }
7850 if (selector != null && mPackage != null) {
7851 throw new IllegalArgumentException(
7852 "Can't set selector when package name is already set");
7853 }
7854 mSelector = selector;
7855 }
7856
7857 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007858 * Set a {@link ClipData} associated with this Intent. This replaces any
7859 * previously set ClipData.
7860 *
7861 * <p>The ClipData in an intent is not used for Intent matching or other
7862 * such operations. Semantically it is like extras, used to transmit
7863 * additional data with the Intent. The main feature of using this over
7864 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7865 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7866 * items included in the clip data. This is useful, in particular, if
7867 * you want to transmit an Intent containing multiple <code>content:</code>
7868 * URIs for which the recipient may not have global permission to access the
7869 * content provider.
7870 *
7871 * <p>If the ClipData contains items that are themselves Intents, any
7872 * grant flags in those Intents will be ignored. Only the top-level flags
7873 * of the main Intent are respected, and will be applied to all Uri or
7874 * Intent items in the clip (or sub-items of the clip).
7875 *
7876 * <p>The MIME type, label, and icon in the ClipData object are not
7877 * directly used by Intent. Applications should generally rely on the
7878 * MIME type of the Intent itself, not what it may find in the ClipData.
7879 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007880 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007881 *
7882 * @param clip The new clip to set. May be null to clear the current clip.
7883 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007884 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007885 mClipData = clip;
7886 }
7887
7888 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007889 * This is NOT a secure mechanism to identify the user who sent the intent.
7890 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7891 * who sent the intent.
7892 * @hide
7893 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007894 public void prepareToLeaveUser(int userId) {
7895 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7896 // We want mContentUserHint to refer to the original user, so don't do anything.
7897 if (mContentUserHint == UserHandle.USER_CURRENT) {
7898 mContentUserHint = userId;
7899 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007900 }
7901
7902 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007903 * Add extended data to the intent. The name must include a package
7904 * prefix, for example the app com.android.contacts would use names
7905 * like "com.android.contacts.ShowAll".
7906 *
7907 * @param name The name of the extra data, with package prefix.
7908 * @param value The boolean data value.
7909 *
7910 * @return Returns the same Intent object, for chaining multiple calls
7911 * into a single statement.
7912 *
7913 * @see #putExtras
7914 * @see #removeExtra
7915 * @see #getBooleanExtra(String, boolean)
7916 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007917 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007918 if (mExtras == null) {
7919 mExtras = new Bundle();
7920 }
7921 mExtras.putBoolean(name, value);
7922 return this;
7923 }
7924
7925 /**
7926 * Add extended data to the intent. The name must include a package
7927 * prefix, for example the app com.android.contacts would use names
7928 * like "com.android.contacts.ShowAll".
7929 *
7930 * @param name The name of the extra data, with package prefix.
7931 * @param value The byte data value.
7932 *
7933 * @return Returns the same Intent object, for chaining multiple calls
7934 * into a single statement.
7935 *
7936 * @see #putExtras
7937 * @see #removeExtra
7938 * @see #getByteExtra(String, byte)
7939 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007940 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007941 if (mExtras == null) {
7942 mExtras = new Bundle();
7943 }
7944 mExtras.putByte(name, value);
7945 return this;
7946 }
7947
7948 /**
7949 * Add extended data to the intent. The name must include a package
7950 * prefix, for example the app com.android.contacts would use names
7951 * like "com.android.contacts.ShowAll".
7952 *
7953 * @param name The name of the extra data, with package prefix.
7954 * @param value The char data value.
7955 *
7956 * @return Returns the same Intent object, for chaining multiple calls
7957 * into a single statement.
7958 *
7959 * @see #putExtras
7960 * @see #removeExtra
7961 * @see #getCharExtra(String, char)
7962 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007963 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007964 if (mExtras == null) {
7965 mExtras = new Bundle();
7966 }
7967 mExtras.putChar(name, value);
7968 return this;
7969 }
7970
7971 /**
7972 * Add extended data to the intent. The name must include a package
7973 * prefix, for example the app com.android.contacts would use names
7974 * like "com.android.contacts.ShowAll".
7975 *
7976 * @param name The name of the extra data, with package prefix.
7977 * @param value The short data value.
7978 *
7979 * @return Returns the same Intent object, for chaining multiple calls
7980 * into a single statement.
7981 *
7982 * @see #putExtras
7983 * @see #removeExtra
7984 * @see #getShortExtra(String, short)
7985 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007986 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007987 if (mExtras == null) {
7988 mExtras = new Bundle();
7989 }
7990 mExtras.putShort(name, value);
7991 return this;
7992 }
7993
7994 /**
7995 * Add extended data to the intent. The name must include a package
7996 * prefix, for example the app com.android.contacts would use names
7997 * like "com.android.contacts.ShowAll".
7998 *
7999 * @param name The name of the extra data, with package prefix.
8000 * @param value The integer data value.
8001 *
8002 * @return Returns the same Intent object, for chaining multiple calls
8003 * into a single statement.
8004 *
8005 * @see #putExtras
8006 * @see #removeExtra
8007 * @see #getIntExtra(String, int)
8008 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008009 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008010 if (mExtras == null) {
8011 mExtras = new Bundle();
8012 }
8013 mExtras.putInt(name, value);
8014 return this;
8015 }
8016
8017 /**
8018 * Add extended data to the intent. The name must include a package
8019 * prefix, for example the app com.android.contacts would use names
8020 * like "com.android.contacts.ShowAll".
8021 *
8022 * @param name The name of the extra data, with package prefix.
8023 * @param value The long data value.
8024 *
8025 * @return Returns the same Intent object, for chaining multiple calls
8026 * into a single statement.
8027 *
8028 * @see #putExtras
8029 * @see #removeExtra
8030 * @see #getLongExtra(String, long)
8031 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008032 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008033 if (mExtras == null) {
8034 mExtras = new Bundle();
8035 }
8036 mExtras.putLong(name, value);
8037 return this;
8038 }
8039
8040 /**
8041 * Add extended data to the intent. The name must include a package
8042 * prefix, for example the app com.android.contacts would use names
8043 * like "com.android.contacts.ShowAll".
8044 *
8045 * @param name The name of the extra data, with package prefix.
8046 * @param value The float data value.
8047 *
8048 * @return Returns the same Intent object, for chaining multiple calls
8049 * into a single statement.
8050 *
8051 * @see #putExtras
8052 * @see #removeExtra
8053 * @see #getFloatExtra(String, float)
8054 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008055 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008056 if (mExtras == null) {
8057 mExtras = new Bundle();
8058 }
8059 mExtras.putFloat(name, value);
8060 return this;
8061 }
8062
8063 /**
8064 * Add extended data to the intent. The name must include a package
8065 * prefix, for example the app com.android.contacts would use names
8066 * like "com.android.contacts.ShowAll".
8067 *
8068 * @param name The name of the extra data, with package prefix.
8069 * @param value The double data value.
8070 *
8071 * @return Returns the same Intent object, for chaining multiple calls
8072 * into a single statement.
8073 *
8074 * @see #putExtras
8075 * @see #removeExtra
8076 * @see #getDoubleExtra(String, double)
8077 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008078 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008079 if (mExtras == null) {
8080 mExtras = new Bundle();
8081 }
8082 mExtras.putDouble(name, value);
8083 return this;
8084 }
8085
8086 /**
8087 * Add extended data to the intent. The name must include a package
8088 * prefix, for example the app com.android.contacts would use names
8089 * like "com.android.contacts.ShowAll".
8090 *
8091 * @param name The name of the extra data, with package prefix.
8092 * @param value The String data value.
8093 *
8094 * @return Returns the same Intent object, for chaining multiple calls
8095 * into a single statement.
8096 *
8097 * @see #putExtras
8098 * @see #removeExtra
8099 * @see #getStringExtra(String)
8100 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008101 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008102 if (mExtras == null) {
8103 mExtras = new Bundle();
8104 }
8105 mExtras.putString(name, value);
8106 return this;
8107 }
8108
8109 /**
8110 * Add extended data to the intent. The name must include a package
8111 * prefix, for example the app com.android.contacts would use names
8112 * like "com.android.contacts.ShowAll".
8113 *
8114 * @param name The name of the extra data, with package prefix.
8115 * @param value The CharSequence data value.
8116 *
8117 * @return Returns the same Intent object, for chaining multiple calls
8118 * into a single statement.
8119 *
8120 * @see #putExtras
8121 * @see #removeExtra
8122 * @see #getCharSequenceExtra(String)
8123 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008124 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008125 if (mExtras == null) {
8126 mExtras = new Bundle();
8127 }
8128 mExtras.putCharSequence(name, value);
8129 return this;
8130 }
8131
8132 /**
8133 * Add extended data to the intent. The name must include a package
8134 * prefix, for example the app com.android.contacts would use names
8135 * like "com.android.contacts.ShowAll".
8136 *
8137 * @param name The name of the extra data, with package prefix.
8138 * @param value The Parcelable data value.
8139 *
8140 * @return Returns the same Intent object, for chaining multiple calls
8141 * into a single statement.
8142 *
8143 * @see #putExtras
8144 * @see #removeExtra
8145 * @see #getParcelableExtra(String)
8146 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008147 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008148 if (mExtras == null) {
8149 mExtras = new Bundle();
8150 }
8151 mExtras.putParcelable(name, value);
8152 return this;
8153 }
8154
8155 /**
8156 * Add extended data to the intent. The name must include a package
8157 * prefix, for example the app com.android.contacts would use names
8158 * like "com.android.contacts.ShowAll".
8159 *
8160 * @param name The name of the extra data, with package prefix.
8161 * @param value The Parcelable[] data value.
8162 *
8163 * @return Returns the same Intent object, for chaining multiple calls
8164 * into a single statement.
8165 *
8166 * @see #putExtras
8167 * @see #removeExtra
8168 * @see #getParcelableArrayExtra(String)
8169 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008170 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008171 if (mExtras == null) {
8172 mExtras = new Bundle();
8173 }
8174 mExtras.putParcelableArray(name, value);
8175 return this;
8176 }
8177
8178 /**
8179 * Add extended data to the intent. The name must include a package
8180 * prefix, for example the app com.android.contacts would use names
8181 * like "com.android.contacts.ShowAll".
8182 *
8183 * @param name The name of the extra data, with package prefix.
8184 * @param value The ArrayList<Parcelable> data value.
8185 *
8186 * @return Returns the same Intent object, for chaining multiple calls
8187 * into a single statement.
8188 *
8189 * @see #putExtras
8190 * @see #removeExtra
8191 * @see #getParcelableArrayListExtra(String)
8192 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008193 public @NonNull Intent putParcelableArrayListExtra(String name,
8194 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008195 if (mExtras == null) {
8196 mExtras = new Bundle();
8197 }
8198 mExtras.putParcelableArrayList(name, value);
8199 return this;
8200 }
8201
8202 /**
8203 * Add extended data to the intent. The name must include a package
8204 * prefix, for example the app com.android.contacts would use names
8205 * like "com.android.contacts.ShowAll".
8206 *
8207 * @param name The name of the extra data, with package prefix.
8208 * @param value The ArrayList<Integer> data value.
8209 *
8210 * @return Returns the same Intent object, for chaining multiple calls
8211 * into a single statement.
8212 *
8213 * @see #putExtras
8214 * @see #removeExtra
8215 * @see #getIntegerArrayListExtra(String)
8216 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008217 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008218 if (mExtras == null) {
8219 mExtras = new Bundle();
8220 }
8221 mExtras.putIntegerArrayList(name, value);
8222 return this;
8223 }
8224
8225 /**
8226 * Add extended data to the intent. The name must include a package
8227 * prefix, for example the app com.android.contacts would use names
8228 * like "com.android.contacts.ShowAll".
8229 *
8230 * @param name The name of the extra data, with package prefix.
8231 * @param value The ArrayList<String> data value.
8232 *
8233 * @return Returns the same Intent object, for chaining multiple calls
8234 * into a single statement.
8235 *
8236 * @see #putExtras
8237 * @see #removeExtra
8238 * @see #getStringArrayListExtra(String)
8239 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008240 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008241 if (mExtras == null) {
8242 mExtras = new Bundle();
8243 }
8244 mExtras.putStringArrayList(name, value);
8245 return this;
8246 }
8247
8248 /**
8249 * Add extended data to the intent. The name must include a package
8250 * prefix, for example the app com.android.contacts would use names
8251 * like "com.android.contacts.ShowAll".
8252 *
8253 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008254 * @param value The ArrayList<CharSequence> data value.
8255 *
8256 * @return Returns the same Intent object, for chaining multiple calls
8257 * into a single statement.
8258 *
8259 * @see #putExtras
8260 * @see #removeExtra
8261 * @see #getCharSequenceArrayListExtra(String)
8262 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008263 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8264 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008265 if (mExtras == null) {
8266 mExtras = new Bundle();
8267 }
8268 mExtras.putCharSequenceArrayList(name, value);
8269 return this;
8270 }
8271
8272 /**
8273 * Add extended data to the intent. The name must include a package
8274 * prefix, for example the app com.android.contacts would use names
8275 * like "com.android.contacts.ShowAll".
8276 *
8277 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008278 * @param value The Serializable data value.
8279 *
8280 * @return Returns the same Intent object, for chaining multiple calls
8281 * into a single statement.
8282 *
8283 * @see #putExtras
8284 * @see #removeExtra
8285 * @see #getSerializableExtra(String)
8286 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008287 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008288 if (mExtras == null) {
8289 mExtras = new Bundle();
8290 }
8291 mExtras.putSerializable(name, value);
8292 return this;
8293 }
8294
8295 /**
8296 * Add extended data to the intent. The name must include a package
8297 * prefix, for example the app com.android.contacts would use names
8298 * like "com.android.contacts.ShowAll".
8299 *
8300 * @param name The name of the extra data, with package prefix.
8301 * @param value The boolean array data value.
8302 *
8303 * @return Returns the same Intent object, for chaining multiple calls
8304 * into a single statement.
8305 *
8306 * @see #putExtras
8307 * @see #removeExtra
8308 * @see #getBooleanArrayExtra(String)
8309 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008310 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008311 if (mExtras == null) {
8312 mExtras = new Bundle();
8313 }
8314 mExtras.putBooleanArray(name, value);
8315 return this;
8316 }
8317
8318 /**
8319 * Add extended data to the intent. The name must include a package
8320 * prefix, for example the app com.android.contacts would use names
8321 * like "com.android.contacts.ShowAll".
8322 *
8323 * @param name The name of the extra data, with package prefix.
8324 * @param value The byte array data value.
8325 *
8326 * @return Returns the same Intent object, for chaining multiple calls
8327 * into a single statement.
8328 *
8329 * @see #putExtras
8330 * @see #removeExtra
8331 * @see #getByteArrayExtra(String)
8332 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008333 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008334 if (mExtras == null) {
8335 mExtras = new Bundle();
8336 }
8337 mExtras.putByteArray(name, value);
8338 return this;
8339 }
8340
8341 /**
8342 * Add extended data to the intent. The name must include a package
8343 * prefix, for example the app com.android.contacts would use names
8344 * like "com.android.contacts.ShowAll".
8345 *
8346 * @param name The name of the extra data, with package prefix.
8347 * @param value The short array data value.
8348 *
8349 * @return Returns the same Intent object, for chaining multiple calls
8350 * into a single statement.
8351 *
8352 * @see #putExtras
8353 * @see #removeExtra
8354 * @see #getShortArrayExtra(String)
8355 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008356 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008357 if (mExtras == null) {
8358 mExtras = new Bundle();
8359 }
8360 mExtras.putShortArray(name, value);
8361 return this;
8362 }
8363
8364 /**
8365 * Add extended data to the intent. The name must include a package
8366 * prefix, for example the app com.android.contacts would use names
8367 * like "com.android.contacts.ShowAll".
8368 *
8369 * @param name The name of the extra data, with package prefix.
8370 * @param value The char array data value.
8371 *
8372 * @return Returns the same Intent object, for chaining multiple calls
8373 * into a single statement.
8374 *
8375 * @see #putExtras
8376 * @see #removeExtra
8377 * @see #getCharArrayExtra(String)
8378 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008379 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008380 if (mExtras == null) {
8381 mExtras = new Bundle();
8382 }
8383 mExtras.putCharArray(name, value);
8384 return this;
8385 }
8386
8387 /**
8388 * Add extended data to the intent. The name must include a package
8389 * prefix, for example the app com.android.contacts would use names
8390 * like "com.android.contacts.ShowAll".
8391 *
8392 * @param name The name of the extra data, with package prefix.
8393 * @param value The int array data value.
8394 *
8395 * @return Returns the same Intent object, for chaining multiple calls
8396 * into a single statement.
8397 *
8398 * @see #putExtras
8399 * @see #removeExtra
8400 * @see #getIntArrayExtra(String)
8401 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008402 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008403 if (mExtras == null) {
8404 mExtras = new Bundle();
8405 }
8406 mExtras.putIntArray(name, value);
8407 return this;
8408 }
8409
8410 /**
8411 * Add extended data to the intent. The name must include a package
8412 * prefix, for example the app com.android.contacts would use names
8413 * like "com.android.contacts.ShowAll".
8414 *
8415 * @param name The name of the extra data, with package prefix.
8416 * @param value The byte array data value.
8417 *
8418 * @return Returns the same Intent object, for chaining multiple calls
8419 * into a single statement.
8420 *
8421 * @see #putExtras
8422 * @see #removeExtra
8423 * @see #getLongArrayExtra(String)
8424 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008425 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008426 if (mExtras == null) {
8427 mExtras = new Bundle();
8428 }
8429 mExtras.putLongArray(name, value);
8430 return this;
8431 }
8432
8433 /**
8434 * Add extended data to the intent. The name must include a package
8435 * prefix, for example the app com.android.contacts would use names
8436 * like "com.android.contacts.ShowAll".
8437 *
8438 * @param name The name of the extra data, with package prefix.
8439 * @param value The float array data value.
8440 *
8441 * @return Returns the same Intent object, for chaining multiple calls
8442 * into a single statement.
8443 *
8444 * @see #putExtras
8445 * @see #removeExtra
8446 * @see #getFloatArrayExtra(String)
8447 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008448 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008449 if (mExtras == null) {
8450 mExtras = new Bundle();
8451 }
8452 mExtras.putFloatArray(name, value);
8453 return this;
8454 }
8455
8456 /**
8457 * Add extended data to the intent. The name must include a package
8458 * prefix, for example the app com.android.contacts would use names
8459 * like "com.android.contacts.ShowAll".
8460 *
8461 * @param name The name of the extra data, with package prefix.
8462 * @param value The double array data value.
8463 *
8464 * @return Returns the same Intent object, for chaining multiple calls
8465 * into a single statement.
8466 *
8467 * @see #putExtras
8468 * @see #removeExtra
8469 * @see #getDoubleArrayExtra(String)
8470 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008471 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008472 if (mExtras == null) {
8473 mExtras = new Bundle();
8474 }
8475 mExtras.putDoubleArray(name, value);
8476 return this;
8477 }
8478
8479 /**
8480 * Add extended data to the intent. The name must include a package
8481 * prefix, for example the app com.android.contacts would use names
8482 * like "com.android.contacts.ShowAll".
8483 *
8484 * @param name The name of the extra data, with package prefix.
8485 * @param value The String array data value.
8486 *
8487 * @return Returns the same Intent object, for chaining multiple calls
8488 * into a single statement.
8489 *
8490 * @see #putExtras
8491 * @see #removeExtra
8492 * @see #getStringArrayExtra(String)
8493 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008494 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008495 if (mExtras == null) {
8496 mExtras = new Bundle();
8497 }
8498 mExtras.putStringArray(name, value);
8499 return this;
8500 }
8501
8502 /**
8503 * Add extended data to the intent. The name must include a package
8504 * prefix, for example the app com.android.contacts would use names
8505 * like "com.android.contacts.ShowAll".
8506 *
8507 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008508 * @param value The CharSequence array data value.
8509 *
8510 * @return Returns the same Intent object, for chaining multiple calls
8511 * into a single statement.
8512 *
8513 * @see #putExtras
8514 * @see #removeExtra
8515 * @see #getCharSequenceArrayExtra(String)
8516 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008517 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008518 if (mExtras == null) {
8519 mExtras = new Bundle();
8520 }
8521 mExtras.putCharSequenceArray(name, value);
8522 return this;
8523 }
8524
8525 /**
8526 * Add extended data to the intent. The name must include a package
8527 * prefix, for example the app com.android.contacts would use names
8528 * like "com.android.contacts.ShowAll".
8529 *
8530 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008531 * @param value The Bundle data value.
8532 *
8533 * @return Returns the same Intent object, for chaining multiple calls
8534 * into a single statement.
8535 *
8536 * @see #putExtras
8537 * @see #removeExtra
8538 * @see #getBundleExtra(String)
8539 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008540 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008541 if (mExtras == null) {
8542 mExtras = new Bundle();
8543 }
8544 mExtras.putBundle(name, value);
8545 return this;
8546 }
8547
8548 /**
8549 * Add extended data to the intent. The name must include a package
8550 * prefix, for example the app com.android.contacts would use names
8551 * like "com.android.contacts.ShowAll".
8552 *
8553 * @param name The name of the extra data, with package prefix.
8554 * @param value The IBinder data value.
8555 *
8556 * @return Returns the same Intent object, for chaining multiple calls
8557 * into a single statement.
8558 *
8559 * @see #putExtras
8560 * @see #removeExtra
8561 * @see #getIBinderExtra(String)
8562 *
8563 * @deprecated
8564 * @hide
8565 */
8566 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008567 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008568 if (mExtras == null) {
8569 mExtras = new Bundle();
8570 }
8571 mExtras.putIBinder(name, value);
8572 return this;
8573 }
8574
8575 /**
8576 * Copy all extras in 'src' in to this intent.
8577 *
8578 * @param src Contains the extras to copy.
8579 *
8580 * @see #putExtra
8581 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008582 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 if (src.mExtras != null) {
8584 if (mExtras == null) {
8585 mExtras = new Bundle(src.mExtras);
8586 } else {
8587 mExtras.putAll(src.mExtras);
8588 }
8589 }
8590 return this;
8591 }
8592
8593 /**
8594 * Add a set of extended data to the intent. The keys must include a package
8595 * prefix, for example the app com.android.contacts would use names
8596 * like "com.android.contacts.ShowAll".
8597 *
8598 * @param extras The Bundle of extras to add to this intent.
8599 *
8600 * @see #putExtra
8601 * @see #removeExtra
8602 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008603 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008604 if (mExtras == null) {
8605 mExtras = new Bundle();
8606 }
8607 mExtras.putAll(extras);
8608 return this;
8609 }
8610
8611 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008612 * Completely replace the extras in the Intent with the extras in the
8613 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008614 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008615 * @param src The exact extras contained in this Intent are copied
8616 * into the target intent, replacing any that were previously there.
8617 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008618 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008619 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8620 return this;
8621 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008622
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008623 /**
8624 * Completely replace the extras in the Intent with the given Bundle of
8625 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008626 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008627 * @param extras The new set of extras in the Intent, or null to erase
8628 * all extras.
8629 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008630 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008631 mExtras = extras != null ? new Bundle(extras) : null;
8632 return this;
8633 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008634
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008635 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008636 * Remove extended data from the intent.
8637 *
8638 * @see #putExtra
8639 */
8640 public void removeExtra(String name) {
8641 if (mExtras != null) {
8642 mExtras.remove(name);
8643 if (mExtras.size() == 0) {
8644 mExtras = null;
8645 }
8646 }
8647 }
8648
8649 /**
8650 * Set special flags controlling how this intent is handled. Most values
8651 * here depend on the type of component being executed by the Intent,
8652 * specifically the FLAG_ACTIVITY_* flags are all for use with
8653 * {@link Context#startActivity Context.startActivity()} and the
8654 * FLAG_RECEIVER_* flags are all for use with
8655 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8656 *
Scott Main7aee61f2011-02-08 11:25:01 -08008657 * <p>See the
8658 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8659 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008660 * the behavior of your application.
8661 *
8662 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008663 * @return Returns the same Intent object, for chaining multiple calls
8664 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008665 * @see #getFlags
8666 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008667 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008668 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008669 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008670 mFlags = flags;
8671 return this;
8672 }
8673
8674 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008675 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008676 *
8677 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008678 * @return Returns the same Intent object, for chaining multiple calls into
8679 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008680 * @see #setFlags
8681 * @see #getFlags
8682 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008683 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008684 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008685 mFlags |= flags;
8686 return this;
8687 }
8688
8689 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008690 * Remove these flags from the intent.
8691 *
8692 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008693 * @see #setFlags
8694 * @see #getFlags
8695 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008696 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008697 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008698 mFlags &= ~flags;
8699 }
8700
8701 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008702 * (Usually optional) Set an explicit application package name that limits
8703 * the components this Intent will resolve to. If left to the default
8704 * value of null, all components in all applications will considered.
8705 * If non-null, the Intent can only match the components in the given
8706 * application package.
8707 *
8708 * @param packageName The name of the application package to handle the
8709 * intent, or null to allow any application package.
8710 *
8711 * @return Returns the same Intent object, for chaining multiple calls
8712 * into a single statement.
8713 *
8714 * @see #getPackage
8715 * @see #resolveActivity
8716 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008717 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008718 if (packageName != null && mSelector != null) {
8719 throw new IllegalArgumentException(
8720 "Can't set package name when selector is already set");
8721 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008722 mPackage = packageName;
8723 return this;
8724 }
8725
8726 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008727 * (Usually optional) Explicitly set the component to handle the intent.
8728 * If left with the default value of null, the system will determine the
8729 * appropriate class to use based on the other fields (action, data,
8730 * type, categories) in the Intent. If this class is defined, the
8731 * specified class will always be used regardless of the other fields. You
8732 * should only set this value when you know you absolutely want a specific
8733 * class to be used; otherwise it is better to let the system find the
8734 * appropriate class so that you will respect the installed applications
8735 * and user preferences.
8736 *
8737 * @param component The name of the application component to handle the
8738 * intent, or null to let the system find one for you.
8739 *
8740 * @return Returns the same Intent object, for chaining multiple calls
8741 * into a single statement.
8742 *
8743 * @see #setClass
8744 * @see #setClassName(Context, String)
8745 * @see #setClassName(String, String)
8746 * @see #getComponent
8747 * @see #resolveActivity
8748 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008749 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008750 mComponent = component;
8751 return this;
8752 }
8753
8754 /**
8755 * Convenience for calling {@link #setComponent} with an
8756 * explicit class name.
8757 *
8758 * @param packageContext A Context of the application package implementing
8759 * this class.
8760 * @param className The name of a class inside of the application package
8761 * that will be used as the component for this Intent.
8762 *
8763 * @return Returns the same Intent object, for chaining multiple calls
8764 * into a single statement.
8765 *
8766 * @see #setComponent
8767 * @see #setClass
8768 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008769 public @NonNull Intent setClassName(@NonNull Context packageContext,
8770 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008771 mComponent = new ComponentName(packageContext, className);
8772 return this;
8773 }
8774
8775 /**
8776 * Convenience for calling {@link #setComponent} with an
8777 * explicit application package name and class name.
8778 *
8779 * @param packageName The name of the package implementing the desired
8780 * component.
8781 * @param className The name of a class inside of the application package
8782 * that will be used as the component for this Intent.
8783 *
8784 * @return Returns the same Intent object, for chaining multiple calls
8785 * into a single statement.
8786 *
8787 * @see #setComponent
8788 * @see #setClass
8789 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008790 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008791 mComponent = new ComponentName(packageName, className);
8792 return this;
8793 }
8794
8795 /**
8796 * Convenience for calling {@link #setComponent(ComponentName)} with the
8797 * name returned by a {@link Class} object.
8798 *
8799 * @param packageContext A Context of the application package implementing
8800 * this class.
8801 * @param cls The class name to set, equivalent to
8802 * <code>setClassName(context, cls.getName())</code>.
8803 *
8804 * @return Returns the same Intent object, for chaining multiple calls
8805 * into a single statement.
8806 *
8807 * @see #setComponent
8808 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008809 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008810 mComponent = new ComponentName(packageContext, cls);
8811 return this;
8812 }
8813
8814 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008815 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8816 * used as a hint to the receiver for animations and the like. Null means that there
8817 * is no source bounds.
8818 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008819 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008820 if (r != null) {
8821 mSourceBounds = new Rect(r);
8822 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008823 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008824 }
8825 }
8826
Tor Norbyed9273d62013-05-30 15:59:53 -07008827 /** @hide */
8828 @IntDef(flag = true,
8829 value = {
8830 FILL_IN_ACTION,
8831 FILL_IN_DATA,
8832 FILL_IN_CATEGORIES,
8833 FILL_IN_COMPONENT,
8834 FILL_IN_PACKAGE,
8835 FILL_IN_SOURCE_BOUNDS,
8836 FILL_IN_SELECTOR,
8837 FILL_IN_CLIP_DATA
8838 })
8839 @Retention(RetentionPolicy.SOURCE)
8840 public @interface FillInFlags {}
8841
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008842 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008843 * Use with {@link #fillIn} to allow the current action value to be
8844 * overwritten, even if it is already set.
8845 */
8846 public static final int FILL_IN_ACTION = 1<<0;
8847
8848 /**
8849 * Use with {@link #fillIn} to allow the current data or type value
8850 * overwritten, even if it is already set.
8851 */
8852 public static final int FILL_IN_DATA = 1<<1;
8853
8854 /**
8855 * Use with {@link #fillIn} to allow the current categories to be
8856 * overwritten, even if they are already set.
8857 */
8858 public static final int FILL_IN_CATEGORIES = 1<<2;
8859
8860 /**
8861 * Use with {@link #fillIn} to allow the current component value to be
8862 * overwritten, even if it is already set.
8863 */
8864 public static final int FILL_IN_COMPONENT = 1<<3;
8865
8866 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008867 * Use with {@link #fillIn} to allow the current package value to be
8868 * overwritten, even if it is already set.
8869 */
8870 public static final int FILL_IN_PACKAGE = 1<<4;
8871
8872 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008873 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008874 * overwritten, even if it is already set.
8875 */
8876 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8877
8878 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008879 * Use with {@link #fillIn} to allow the current selector to be
8880 * overwritten, even if it is already set.
8881 */
8882 public static final int FILL_IN_SELECTOR = 1<<6;
8883
8884 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008885 * Use with {@link #fillIn} to allow the current ClipData to be
8886 * overwritten, even if it is already set.
8887 */
8888 public static final int FILL_IN_CLIP_DATA = 1<<7;
8889
8890 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008891 * Copy the contents of <var>other</var> in to this object, but only
8892 * where fields are not defined by this object. For purposes of a field
8893 * being defined, the following pieces of data in the Intent are
8894 * considered to be separate fields:
8895 *
8896 * <ul>
8897 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008898 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008899 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8900 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008901 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008902 * <li> component, as set by {@link #setComponent(ComponentName)} or
8903 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008904 * <li> source bounds, as set by {@link #setSourceBounds}.
8905 * <li> selector, as set by {@link #setSelector(Intent)}.
8906 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008907 * <li> each top-level name in the associated extras.
8908 * </ul>
8909 *
8910 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008911 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008912 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8913 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8914 * the restriction where the corresponding field will not be replaced if
8915 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008916 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008917 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8918 * is explicitly specified. The selector will only be copied if
8919 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008920 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008921 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8922 * and Intent B with {action="gotit", data-type="some/thing",
8923 * categories="one","two"}.
8924 *
8925 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8926 * containing: {action="gotit", data-type="some/thing",
8927 * categories="bar"}.
8928 *
8929 * @param other Another Intent whose values are to be used to fill in
8930 * the current one.
8931 * @param flags Options to control which fields can be filled in.
8932 *
8933 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008934 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008935 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008936 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008937 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008938 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008939 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008940 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008941 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008942 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008943 if (other.mAction != null
8944 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008945 mAction = other.mAction;
8946 changes |= FILL_IN_ACTION;
8947 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008948 if ((other.mData != null || other.mType != null)
8949 && ((mData == null && mType == null)
8950 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008951 mData = other.mData;
8952 mType = other.mType;
8953 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008954 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008955 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008956 if (other.mCategories != null
8957 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008958 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008959 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008960 }
8961 changes |= FILL_IN_CATEGORIES;
8962 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008963 if (other.mPackage != null
8964 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008965 // Only do this if mSelector is not set.
8966 if (mSelector == null) {
8967 mPackage = other.mPackage;
8968 changes |= FILL_IN_PACKAGE;
8969 }
8970 }
8971 // Selector is special: it can only be set if explicitly allowed,
8972 // for the same reason as the component name.
8973 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8974 if (mPackage == null) {
8975 mSelector = new Intent(other.mSelector);
8976 mPackage = null;
8977 changes |= FILL_IN_SELECTOR;
8978 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008979 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008980 if (other.mClipData != null
8981 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8982 mClipData = other.mClipData;
8983 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008984 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008985 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008986 // Component is special: it can -only- be set if explicitly allowed,
8987 // since otherwise the sender could force the intent somewhere the
8988 // originator didn't intend.
8989 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008990 mComponent = other.mComponent;
8991 changes |= FILL_IN_COMPONENT;
8992 }
8993 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008994 if (other.mSourceBounds != null
8995 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8996 mSourceBounds = new Rect(other.mSourceBounds);
8997 changes |= FILL_IN_SOURCE_BOUNDS;
8998 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008999 if (mExtras == null) {
9000 if (other.mExtras != null) {
9001 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009002 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009003 }
9004 } else if (other.mExtras != null) {
9005 try {
9006 Bundle newb = new Bundle(other.mExtras);
9007 newb.putAll(mExtras);
9008 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009009 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009010 } catch (RuntimeException e) {
9011 // Modifying the extras can cause us to unparcel the contents
9012 // of the bundle, and if we do this in the system process that
9013 // may fail. We really should handle this (i.e., the Bundle
9014 // impl shouldn't be on top of a plain map), but for now just
9015 // ignore it and keep the original contents. :(
9016 Log.w("Intent", "Failure filling in extras", e);
9017 }
9018 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009019 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9020 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9021 mContentUserHint = other.mContentUserHint;
9022 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009023 return changes;
9024 }
9025
9026 /**
9027 * Wrapper class holding an Intent and implementing comparisons on it for
9028 * the purpose of filtering. The class implements its
9029 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9030 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9031 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9032 * on the wrapped Intent.
9033 */
9034 public static final class FilterComparison {
9035 private final Intent mIntent;
9036 private final int mHashCode;
9037
9038 public FilterComparison(Intent intent) {
9039 mIntent = intent;
9040 mHashCode = intent.filterHashCode();
9041 }
9042
9043 /**
9044 * Return the Intent that this FilterComparison represents.
9045 * @return Returns the Intent held by the FilterComparison. Do
9046 * not modify!
9047 */
9048 public Intent getIntent() {
9049 return mIntent;
9050 }
9051
9052 @Override
9053 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009054 if (obj instanceof FilterComparison) {
9055 Intent other = ((FilterComparison)obj).mIntent;
9056 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009057 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009058 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009059 }
9060
9061 @Override
9062 public int hashCode() {
9063 return mHashCode;
9064 }
9065 }
9066
9067 /**
9068 * Determine if two intents are the same for the purposes of intent
9069 * resolution (filtering). That is, if their action, data, type,
9070 * class, and categories are the same. This does <em>not</em> compare
9071 * any extra data included in the intents.
9072 *
9073 * @param other The other Intent to compare against.
9074 *
9075 * @return Returns true if action, data, type, class, and categories
9076 * are the same.
9077 */
9078 public boolean filterEquals(Intent other) {
9079 if (other == null) {
9080 return false;
9081 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009082 if (!Objects.equals(this.mAction, other.mAction)) return false;
9083 if (!Objects.equals(this.mData, other.mData)) return false;
9084 if (!Objects.equals(this.mType, other.mType)) return false;
9085 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9086 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9087 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009088
9089 return true;
9090 }
9091
9092 /**
9093 * Generate hash code that matches semantics of filterEquals().
9094 *
9095 * @return Returns the hash value of the action, data, type, class, and
9096 * categories.
9097 *
9098 * @see #filterEquals
9099 */
9100 public int filterHashCode() {
9101 int code = 0;
9102 if (mAction != null) {
9103 code += mAction.hashCode();
9104 }
9105 if (mData != null) {
9106 code += mData.hashCode();
9107 }
9108 if (mType != null) {
9109 code += mType.hashCode();
9110 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009111 if (mPackage != null) {
9112 code += mPackage.hashCode();
9113 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 if (mComponent != null) {
9115 code += mComponent.hashCode();
9116 }
9117 if (mCategories != null) {
9118 code += mCategories.hashCode();
9119 }
9120 return code;
9121 }
9122
9123 @Override
9124 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009125 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009126
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009127 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009128 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009129 b.append(" }");
9130
9131 return b.toString();
9132 }
9133
9134 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009135 public String toInsecureString() {
9136 StringBuilder b = new StringBuilder(128);
9137
9138 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009139 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009140 b.append(" }");
9141
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009142 return b.toString();
9143 }
Romain Guy4969af72009-06-17 10:53:19 -07009144
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009145 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009146 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009147 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009148
9149 b.append("Intent { ");
9150 toShortString(b, false, true, true, true);
9151 b.append(" }");
9152
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009153 return b.toString();
9154 }
9155
9156 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009157 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9158 StringBuilder b = new StringBuilder(128);
9159 toShortString(b, secure, comp, extras, clip);
9160 return b.toString();
9161 }
9162
9163 /** @hide */
9164 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9165 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009166 boolean first = true;
9167 if (mAction != null) {
9168 b.append("act=").append(mAction);
9169 first = false;
9170 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009171 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009172 if (!first) {
9173 b.append(' ');
9174 }
9175 first = false;
9176 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009177 for (int i=0; i<mCategories.size(); i++) {
9178 if (i > 0) b.append(',');
9179 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009180 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009181 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009182 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009183 if (mData != null) {
9184 if (!first) {
9185 b.append(' ');
9186 }
9187 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009188 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009189 if (secure) {
9190 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009191 } else {
9192 b.append(mData);
9193 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009194 }
9195 if (mType != null) {
9196 if (!first) {
9197 b.append(' ');
9198 }
9199 first = false;
9200 b.append("typ=").append(mType);
9201 }
9202 if (mFlags != 0) {
9203 if (!first) {
9204 b.append(' ');
9205 }
9206 first = false;
9207 b.append("flg=0x").append(Integer.toHexString(mFlags));
9208 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009209 if (mPackage != null) {
9210 if (!first) {
9211 b.append(' ');
9212 }
9213 first = false;
9214 b.append("pkg=").append(mPackage);
9215 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009216 if (comp && mComponent != null) {
9217 if (!first) {
9218 b.append(' ');
9219 }
9220 first = false;
9221 b.append("cmp=").append(mComponent.flattenToShortString());
9222 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009223 if (mSourceBounds != null) {
9224 if (!first) {
9225 b.append(' ');
9226 }
9227 first = false;
9228 b.append("bnds=").append(mSourceBounds.toShortString());
9229 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009230 if (mClipData != null) {
9231 if (!first) {
9232 b.append(' ');
9233 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009234 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009235 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009236 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009237 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009238 if (mClipData.getDescription() != null) {
9239 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9240 } else {
9241 first = true;
9242 }
9243 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009244 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009245 first = false;
9246 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009247 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009248 if (extras && mExtras != null) {
9249 if (!first) {
9250 b.append(' ');
9251 }
9252 first = false;
9253 b.append("(has extras)");
9254 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009255 if (mContentUserHint != UserHandle.USER_CURRENT) {
9256 if (!first) {
9257 b.append(' ');
9258 }
9259 first = false;
9260 b.append("u=").append(mContentUserHint);
9261 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009262 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009263 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009264 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009265 b.append("}");
9266 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009267 }
9268
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009269 /**
9270 * Call {@link #toUri} with 0 flags.
9271 * @deprecated Use {@link #toUri} instead.
9272 */
9273 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009274 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009275 return toUri(0);
9276 }
9277
9278 /**
9279 * Convert this Intent into a String holding a URI representation of it.
9280 * The returned URI string has been properly URI encoded, so it can be
9281 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9282 * Intent's data as the base URI, with an additional fragment describing
9283 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009284 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009285 * <p>You can convert the returned string back to an Intent with
9286 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009287 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009288 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009289 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009290 * @return Returns a URI encoding URI string describing the entire contents
9291 * of the Intent.
9292 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009293 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009294 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009295 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9296 if (mPackage == null) {
9297 throw new IllegalArgumentException(
9298 "Intent must include an explicit package name to build an android-app: "
9299 + this);
9300 }
9301 uri.append("android-app://");
9302 uri.append(mPackage);
9303 String scheme = null;
9304 if (mData != null) {
9305 scheme = mData.getScheme();
9306 if (scheme != null) {
9307 uri.append('/');
9308 uri.append(scheme);
9309 String authority = mData.getEncodedAuthority();
9310 if (authority != null) {
9311 uri.append('/');
9312 uri.append(authority);
9313 String path = mData.getEncodedPath();
9314 if (path != null) {
9315 uri.append(path);
9316 }
9317 String queryParams = mData.getEncodedQuery();
9318 if (queryParams != null) {
9319 uri.append('?');
9320 uri.append(queryParams);
9321 }
9322 String fragment = mData.getEncodedFragment();
9323 if (fragment != null) {
9324 uri.append('#');
9325 uri.append(fragment);
9326 }
9327 }
9328 }
9329 }
9330 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9331 mPackage, flags);
9332 return uri.toString();
9333 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009334 String scheme = null;
9335 if (mData != null) {
9336 String data = mData.toString();
9337 if ((flags&URI_INTENT_SCHEME) != 0) {
9338 final int N = data.length();
9339 for (int i=0; i<N; i++) {
9340 char c = data.charAt(i);
9341 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
9342 || c == '.' || c == '-') {
9343 continue;
9344 }
9345 if (c == ':' && i > 0) {
9346 // Valid scheme.
9347 scheme = data.substring(0, i);
9348 uri.append("intent:");
9349 data = data.substring(i+1);
9350 break;
9351 }
Tom Taylord4a47292009-12-21 13:59:18 -08009352
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009353 // No scheme.
9354 break;
9355 }
9356 }
9357 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009358
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009359 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9360 uri.append("intent:");
9361 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009362
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009363 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009364
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009365 return uri.toString();
9366 }
9367
9368 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9369 String defPackage, int flags) {
9370 StringBuilder frag = new StringBuilder(128);
9371
9372 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009373 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009374 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009375 // Note that for now we are not going to try to handle the
9376 // data part; not clear how to represent this as a URI, and
9377 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009378 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9379 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009380 }
9381
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009382 if (frag.length() > 0) {
9383 uri.append("#Intent;");
9384 uri.append(frag);
9385 uri.append("end");
9386 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009387 }
9388
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009389 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9390 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009391 if (scheme != null) {
9392 uri.append("scheme=").append(scheme).append(';');
9393 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009394 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009395 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009396 }
9397 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009398 for (int i=0; i<mCategories.size(); i++) {
9399 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009400 }
9401 }
9402 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009403 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009404 }
9405 if (mFlags != 0) {
9406 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9407 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009408 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009409 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9410 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009411 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009412 uri.append("component=").append(Uri.encode(
9413 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009414 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009415 if (mSourceBounds != null) {
9416 uri.append("sourceBounds=")
9417 .append(Uri.encode(mSourceBounds.flattenToString()))
9418 .append(';');
9419 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009420 if (mExtras != null) {
9421 for (String key : mExtras.keySet()) {
9422 final Object value = mExtras.get(key);
9423 char entryType =
9424 value instanceof String ? 'S' :
9425 value instanceof Boolean ? 'B' :
9426 value instanceof Byte ? 'b' :
9427 value instanceof Character ? 'c' :
9428 value instanceof Double ? 'd' :
9429 value instanceof Float ? 'f' :
9430 value instanceof Integer ? 'i' :
9431 value instanceof Long ? 'l' :
9432 value instanceof Short ? 's' :
9433 '\0';
9434
9435 if (entryType != '\0') {
9436 uri.append(entryType);
9437 uri.append('.');
9438 uri.append(Uri.encode(key));
9439 uri.append('=');
9440 uri.append(Uri.encode(value.toString()));
9441 uri.append(';');
9442 }
9443 }
9444 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009445 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009446
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009447 public int describeContents() {
9448 return (mExtras != null) ? mExtras.describeContents() : 0;
9449 }
9450
9451 public void writeToParcel(Parcel out, int flags) {
9452 out.writeString(mAction);
9453 Uri.writeToParcel(out, mData);
9454 out.writeString(mType);
9455 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009456 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009457 ComponentName.writeToParcel(mComponent, out);
9458
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009459 if (mSourceBounds != null) {
9460 out.writeInt(1);
9461 mSourceBounds.writeToParcel(out, flags);
9462 } else {
9463 out.writeInt(0);
9464 }
9465
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009466 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009467 final int N = mCategories.size();
9468 out.writeInt(N);
9469 for (int i=0; i<N; i++) {
9470 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009471 }
9472 } else {
9473 out.writeInt(0);
9474 }
9475
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009476 if (mSelector != null) {
9477 out.writeInt(1);
9478 mSelector.writeToParcel(out, flags);
9479 } else {
9480 out.writeInt(0);
9481 }
9482
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009483 if (mClipData != null) {
9484 out.writeInt(1);
9485 mClipData.writeToParcel(out, flags);
9486 } else {
9487 out.writeInt(0);
9488 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009489 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009490 out.writeBundle(mExtras);
9491 }
9492
9493 public static final Parcelable.Creator<Intent> CREATOR
9494 = new Parcelable.Creator<Intent>() {
9495 public Intent createFromParcel(Parcel in) {
9496 return new Intent(in);
9497 }
9498 public Intent[] newArray(int size) {
9499 return new Intent[size];
9500 }
9501 };
9502
Dianne Hackborneb034652009-09-07 00:49:58 -07009503 /** @hide */
9504 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009505 readFromParcel(in);
9506 }
9507
9508 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009509 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009510 mData = Uri.CREATOR.createFromParcel(in);
9511 mType = in.readString();
9512 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009513 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009514 mComponent = ComponentName.readFromParcel(in);
9515
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009516 if (in.readInt() != 0) {
9517 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9518 }
9519
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009520 int N = in.readInt();
9521 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009522 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009523 int i;
9524 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009525 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009526 }
9527 } else {
9528 mCategories = null;
9529 }
9530
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009531 if (in.readInt() != 0) {
9532 mSelector = new Intent(in);
9533 }
9534
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009535 if (in.readInt() != 0) {
9536 mClipData = new ClipData(in);
9537 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009538 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009539 mExtras = in.readBundle();
9540 }
9541
9542 /**
9543 * Parses the "intent" element (and its children) from XML and instantiates
9544 * an Intent object. The given XML parser should be located at the tag
9545 * where parsing should start (often named "intent"), from which the
9546 * basic action, data, type, and package and class name will be
9547 * retrieved. The function will then parse in to any child elements,
9548 * looking for <category android:name="xxx"> tags to add categories and
9549 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9550 * to the intent.
9551 *
9552 * @param resources The Resources to use when inflating resources.
9553 * @param parser The XML parser pointing at an "intent" tag.
9554 * @param attrs The AttributeSet interface for retrieving extended
9555 * attribute data at the current <var>parser</var> location.
9556 * @return An Intent object matching the XML data.
9557 * @throws XmlPullParserException If there was an XML parsing error.
9558 * @throws IOException If there was an I/O error.
9559 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009560 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9561 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009562 throws XmlPullParserException, IOException {
9563 Intent intent = new Intent();
9564
9565 TypedArray sa = resources.obtainAttributes(attrs,
9566 com.android.internal.R.styleable.Intent);
9567
9568 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9569
9570 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9571 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9572 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9573
9574 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9575 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9576 if (packageName != null && className != null) {
9577 intent.setComponent(new ComponentName(packageName, className));
9578 }
9579
9580 sa.recycle();
9581
9582 int outerDepth = parser.getDepth();
9583 int type;
9584 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9585 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9586 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9587 continue;
9588 }
9589
9590 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009591 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009592 sa = resources.obtainAttributes(attrs,
9593 com.android.internal.R.styleable.IntentCategory);
9594 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9595 sa.recycle();
9596
9597 if (cat != null) {
9598 intent.addCategory(cat);
9599 }
9600 XmlUtils.skipCurrentTag(parser);
9601
Craig Mautner21d24a22014-04-23 11:45:37 -07009602 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009603 if (intent.mExtras == null) {
9604 intent.mExtras = new Bundle();
9605 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009606 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009607 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009608
9609 } else {
9610 XmlUtils.skipCurrentTag(parser);
9611 }
9612 }
9613
9614 return intent;
9615 }
Nick Pellyccae4122012-01-09 14:12:58 -08009616
Craig Mautner21d24a22014-04-23 11:45:37 -07009617 /** @hide */
9618 public void saveToXml(XmlSerializer out) throws IOException {
9619 if (mAction != null) {
9620 out.attribute(null, ATTR_ACTION, mAction);
9621 }
9622 if (mData != null) {
9623 out.attribute(null, ATTR_DATA, mData.toString());
9624 }
9625 if (mType != null) {
9626 out.attribute(null, ATTR_TYPE, mType);
9627 }
9628 if (mComponent != null) {
9629 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9630 }
9631 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9632
9633 if (mCategories != null) {
9634 out.startTag(null, TAG_CATEGORIES);
9635 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9636 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9637 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009638 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009639 }
9640 }
9641
9642 /** @hide */
9643 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9644 XmlPullParserException {
9645 Intent intent = new Intent();
9646 final int outerDepth = in.getDepth();
9647
9648 int attrCount = in.getAttributeCount();
9649 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9650 final String attrName = in.getAttributeName(attrNdx);
9651 final String attrValue = in.getAttributeValue(attrNdx);
9652 if (ATTR_ACTION.equals(attrName)) {
9653 intent.setAction(attrValue);
9654 } else if (ATTR_DATA.equals(attrName)) {
9655 intent.setData(Uri.parse(attrValue));
9656 } else if (ATTR_TYPE.equals(attrName)) {
9657 intent.setType(attrValue);
9658 } else if (ATTR_COMPONENT.equals(attrName)) {
9659 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9660 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009661 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009662 } else {
9663 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9664 }
9665 }
9666
9667 int event;
9668 String name;
9669 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9670 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9671 if (event == XmlPullParser.START_TAG) {
9672 name = in.getName();
9673 if (TAG_CATEGORIES.equals(name)) {
9674 attrCount = in.getAttributeCount();
9675 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9676 intent.addCategory(in.getAttributeValue(attrNdx));
9677 }
9678 } else {
9679 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9680 XmlUtils.skipCurrentTag(in);
9681 }
9682 }
9683 }
9684
9685 return intent;
9686 }
9687
Nick Pellyccae4122012-01-09 14:12:58 -08009688 /**
9689 * Normalize a MIME data type.
9690 *
9691 * <p>A normalized MIME type has white-space trimmed,
9692 * content-type parameters removed, and is lower-case.
9693 * This aligns the type with Android best practices for
9694 * intent filtering.
9695 *
9696 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9697 * "text/x-vCard" becomes "text/x-vcard".
9698 *
9699 * <p>All MIME types received from outside Android (such as user input,
9700 * or external sources like Bluetooth, NFC, or the Internet) should
9701 * be normalized before they are used to create an Intent.
9702 *
9703 * @param type MIME data type to normalize
9704 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009705 * @see #setType
9706 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009707 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009708 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08009709 if (type == null) {
9710 return null;
9711 }
9712
Elliott Hughescb64d432013-08-02 10:00:44 -07009713 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009714
9715 final int semicolonIndex = type.indexOf(';');
9716 if (semicolonIndex != -1) {
9717 type = type.substring(0, semicolonIndex);
9718 }
9719 return type;
9720 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009721
9722 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009723 * Prepare this {@link Intent} to leave an app process.
9724 *
9725 * @hide
9726 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009727 public void prepareToLeaveProcess(Context context) {
9728 final boolean leavingPackage = (mComponent == null)
9729 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9730 prepareToLeaveProcess(leavingPackage);
9731 }
9732
9733 /**
9734 * Prepare this {@link Intent} to leave an app process.
9735 *
9736 * @hide
9737 */
9738 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009739 setAllowFds(false);
9740
9741 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009742 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009743 }
9744 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009745 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009746 }
9747
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -07009748 if (mExtras != null && !mExtras.isParcelled()) {
9749 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9750 if (intent instanceof Intent) {
9751 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9752 }
9753 }
9754
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009755 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9756 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009757 switch (mAction) {
9758 case ACTION_MEDIA_REMOVED:
9759 case ACTION_MEDIA_UNMOUNTED:
9760 case ACTION_MEDIA_CHECKING:
9761 case ACTION_MEDIA_NOFS:
9762 case ACTION_MEDIA_MOUNTED:
9763 case ACTION_MEDIA_SHARED:
9764 case ACTION_MEDIA_UNSHARED:
9765 case ACTION_MEDIA_BAD_REMOVAL:
9766 case ACTION_MEDIA_UNMOUNTABLE:
9767 case ACTION_MEDIA_EJECT:
9768 case ACTION_MEDIA_SCANNER_STARTED:
9769 case ACTION_MEDIA_SCANNER_FINISHED:
9770 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009771 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9772 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009773 // Ignore legacy actions
9774 break;
9775 default:
9776 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009777 }
9778 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009779
9780 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9781 && leavingPackage) {
9782 switch (mAction) {
9783 case ACTION_PROVIDER_CHANGED:
9784 // Ignore actions that don't need to grant
9785 break;
9786 default:
9787 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9788 }
9789 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009790 }
9791
9792 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009793 * @hide
9794 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009795 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009796 // We just entered destination process, so we should be able to read all
9797 // parcelables inside.
9798 setDefusable(true);
9799
9800 if (mSelector != null) {
9801 mSelector.prepareToEnterProcess();
9802 }
9803 if (mClipData != null) {
9804 mClipData.prepareToEnterProcess();
9805 }
9806
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009807 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009808 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9809 fixUris(mContentUserHint);
9810 mContentUserHint = UserHandle.USER_CURRENT;
9811 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009812 }
9813 }
9814
9815 /**
9816 * @hide
9817 */
9818 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009819 Uri data = getData();
9820 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009821 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009822 }
9823 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009824 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009825 }
9826 String action = getAction();
9827 if (ACTION_SEND.equals(action)) {
9828 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9829 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009830 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009831 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009832 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009833 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9834 if (streams != null) {
9835 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9836 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009837 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009838 }
9839 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9840 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009841 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9842 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9843 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9844 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9845 if (output != null) {
9846 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9847 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009848 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009849 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009850
9851 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009852 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009853 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9854 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009855 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009856 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009857 * @hide
9858 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009859 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009860 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009861 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009862
9863 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009864 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009865
9866 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009867 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009868 // Inspect contained intents to see if we need to migrate extras. We
9869 // don't promote ClipData to the parent, since ChooserActivity will
9870 // already start the picked item as the caller, and we can't combine
9871 // the flags in a safe way.
9872
9873 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009874 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009875 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9876 if (intent != null) {
9877 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009878 }
9879 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009880 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009881 try {
9882 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9883 if (intents != null) {
9884 for (int i = 0; i < intents.length; i++) {
9885 final Intent intent = (Intent) intents[i];
9886 if (intent != null) {
9887 migrated |= intent.migrateExtraStreamToClipData();
9888 }
9889 }
9890 }
9891 } catch (ClassCastException e) {
9892 }
9893 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009894
9895 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009896 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009897 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9898 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9899 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9900 if (stream != null || text != null || htmlText != null) {
9901 final ClipData clipData = new ClipData(
9902 null, new String[] { getType() },
9903 new ClipData.Item(text, htmlText, null, stream));
9904 setClipData(clipData);
9905 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009906 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009907 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009908 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009909 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009910
9911 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009912 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009913 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9914 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9915 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9916 int num = -1;
9917 if (streams != null) {
9918 num = streams.size();
9919 }
9920 if (texts != null) {
9921 if (num >= 0 && num != texts.size()) {
9922 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009923 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009924 }
9925 num = texts.size();
9926 }
9927 if (htmlTexts != null) {
9928 if (num >= 0 && num != htmlTexts.size()) {
9929 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009930 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009931 }
9932 num = htmlTexts.size();
9933 }
9934 if (num > 0) {
9935 final ClipData clipData = new ClipData(
9936 null, new String[] { getType() },
9937 makeClipItem(streams, texts, htmlTexts, 0));
9938
9939 for (int i = 1; i < num; i++) {
9940 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9941 }
9942
9943 setClipData(clipData);
9944 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009945 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009946 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009947 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009948 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009949 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9950 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9951 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9952 final Uri output;
9953 try {
9954 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9955 } catch (ClassCastException e) {
9956 return false;
9957 }
9958 if (output != null) {
9959 setClipData(ClipData.newRawUri("", output));
9960 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9961 return true;
9962 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009963 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009964
9965 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009966 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009967
9968 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9969 ArrayList<String> htmlTexts, int which) {
9970 Uri uri = streams != null ? streams.get(which) : null;
9971 CharSequence text = texts != null ? texts.get(which) : null;
9972 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9973 return new ClipData.Item(text, htmlText, null, uri);
9974 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009975
9976 /** @hide */
9977 public boolean isDocument() {
9978 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9979 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009980}