blob: 6bfddb06ca88aa09ba01d03203ded9c5771de85e [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
Makoto Onuki7d1911f2017-06-09 12:30:09 -070019import static android.content.ContentProvider.maybeAddUserId;
20
Tor Norbye7b9c9122013-05-30 16:48:33 -070021import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070022import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.annotation.IntDef;
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060024import android.annotation.NonNull;
25import android.annotation.Nullable;
Joel Galenson78ec58d2018-10-24 10:06:25 -070026import android.annotation.RequiresPermission;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.annotation.SdkConstant;
28import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050029import android.annotation.SystemApi;
Mathew Inwood5c0d3542018-08-14 13:54:31 +010030import android.annotation.UnsupportedAppUsage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050032import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060033import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070034import android.content.pm.PackageManager;
35import android.content.pm.ResolveInfo;
36import android.content.res.Resources;
37import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080038import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060040import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070041import android.os.Bundle;
42import android.os.IBinder;
43import android.os.Parcel;
44import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070045import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000046import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.os.ResultReceiver;
48import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070049import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010050import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070051import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070052import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070053import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050054import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070055import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000056import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050057import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058import android.util.AttributeSet;
59import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070060import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070061
Dianne Hackborn2269d1572010-02-24 19:54:22 -080062import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070063
Jason Monk2f68e8a2016-02-23 17:57:28 -050064import org.xmlpull.v1.XmlPullParser;
65import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070066import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070067
68import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080069import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070070import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070071import java.lang.annotation.Retention;
72import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070073import java.net.URISyntaxException;
74import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080075import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070076import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080077import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070078import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070079import java.util.Set;
80
81/**
82 * An intent is an abstract description of an operation to be performed. It
83 * can be used with {@link Context#startActivity(Intent) startActivity} to
84 * launch an {@link android.app.Activity},
85 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
86 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
87 * and {@link android.content.Context#startService} or
88 * {@link android.content.Context#bindService} to communicate with a
89 * background {@link android.app.Service}.
90 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070091 * <p>An Intent provides a facility for performing late runtime binding between the code in
92 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070093 * can be thought of as the glue between activities. It is basically a passive data structure
94 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070095 *
96 * <div class="special reference">
97 * <h3>Developer Guides</h3>
98 * <p>For information about how to create and resolve intents, read the
99 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
100 * developer guide.</p>
101 * </div>
102 *
103 * <a name="IntentStructure"></a>
104 * <h3>Intent Structure</h3>
105 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700106 *
107 * <ul>
108 * <li> <p><b>action</b> -- The general action to be performed, such as
109 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
110 * etc.</p>
111 * </li>
112 * <li> <p><b>data</b> -- The data to operate on, such as a person record
113 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
114 * </li>
115 * </ul>
116 *
117 *
118 * <p>Some examples of action/data pairs are:</p>
119 *
120 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700121 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700122 * information about the person whose identifier is "1".</p>
123 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700124 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700125 * the phone dialer with the person filled in.</p>
126 * </li>
127 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
128 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700129 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700130 * a particular URI.</p>
131 * </li>
132 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
133 * the phone dialer with the given number filled in.</p>
134 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700135 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700136 * information about the person whose identifier is "1".</p>
137 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700138 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700139 * a list of people, which the user can browse through. This example is a
140 * typical top-level entry into the Contacts application, showing you the
141 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700142 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700143 * being used to start an activity to display that person.</p>
144 * </li>
145 * </ul>
146 *
147 * <p>In addition to these primary attributes, there are a number of secondary
148 * attributes that you can also include with an intent:</p>
149 *
150 * <ul>
151 * <li> <p><b>category</b> -- Gives additional information about the action
152 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
153 * appear in the Launcher as a top-level application, while
154 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
155 * of alternative actions the user can perform on a piece of data.</p>
156 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
157 * intent data. Normally the type is inferred from the data itself.
158 * By setting this attribute, you disable that evaluation and force
159 * an explicit type.</p>
160 * <li> <p><b>component</b> -- Specifies an explicit name of a component
161 * class to use for the intent. Normally this is determined by looking
162 * at the other information in the intent (the action, data/type, and
163 * categories) and matching that with a component that can handle it.
164 * If this attribute is set then none of the evaluation is performed,
165 * and this component is used exactly as is. By specifying this attribute,
166 * all of the other Intent attributes become optional.</p>
167 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
168 * This can be used to provide extended information to the component.
169 * For example, if we have a action to send an e-mail message, we could
170 * also include extra pieces of data here to supply a subject, body,
171 * etc.</p>
172 * </ul>
173 *
174 * <p>Here are some examples of other operations you can specify as intents
175 * using these additional parameters:</p>
176 *
177 * <ul>
178 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
179 * Launch the home screen.</p>
180 * </li>
181 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
182 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
183 * vnd.android.cursor.item/phone}</i></b>
184 * -- Display the list of people's phone numbers, allowing the user to
185 * browse through them and pick one and return it to the parent activity.</p>
186 * </li>
187 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
188 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
189 * -- Display all pickers for data that can be opened with
190 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
191 * allowing the user to pick one of them and then some data inside of it
192 * and returning the resulting URI to the caller. This can be used,
193 * for example, in an e-mail application to allow the user to pick some
194 * data to include as an attachment.</p>
195 * </li>
196 * </ul>
197 *
198 * <p>There are a variety of standard Intent action and category constants
199 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700200 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700201 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700202 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700203 *
204 * <p>Put together, the set of actions, data types, categories, and extra data
205 * defines a language for the system allowing for the expression of phrases
206 * such as "call john smith's cell". As applications are added to the system,
207 * they can extend this language by adding new actions, types, and categories, or
208 * they can modify the behavior of existing phrases by supplying their own
209 * activities that handle them.</p>
210 *
211 * <a name="IntentResolution"></a>
212 * <h3>Intent Resolution</h3>
213 *
214 * <p>There are two primary forms of intents you will use.
215 *
216 * <ul>
217 * <li> <p><b>Explicit Intents</b> have specified a component (via
218 * {@link #setComponent} or {@link #setClass}), which provides the exact
219 * class to be run. Often these will not include any other information,
220 * simply being a way for an application to launch various internal
221 * activities it has as the user interacts with the application.
222 *
223 * <li> <p><b>Implicit Intents</b> have not specified a component;
224 * instead, they must include enough information for the system to
225 * determine which of the available components is best to run for that
226 * intent.
227 * </ul>
228 *
229 * <p>When using implicit intents, given such an arbitrary intent we need to
230 * know what to do with it. This is handled by the process of <em>Intent
231 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
232 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
233 * more activities/receivers) that can handle it.</p>
234 *
235 * <p>The intent resolution mechanism basically revolves around matching an
236 * Intent against all of the &lt;intent-filter&gt; descriptions in the
237 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
238 * objects explicitly registered with {@link Context#registerReceiver}.) More
239 * details on this can be found in the documentation on the {@link
240 * IntentFilter} class.</p>
241 *
242 * <p>There are three pieces of information in the Intent that are used for
243 * resolution: the action, type, and category. Using this information, a query
244 * is done on the {@link PackageManager} for a component that can handle the
245 * intent. The appropriate component is determined based on the intent
246 * information supplied in the <code>AndroidManifest.xml</code> file as
247 * follows:</p>
248 *
249 * <ul>
250 * <li> <p>The <b>action</b>, if given, must be listed by the component as
251 * one it handles.</p>
252 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
253 * already supplied in the Intent. Like the action, if a type is
254 * included in the intent (either explicitly or implicitly in its
255 * data), then this must be listed by the component as one it handles.</p>
256 * <li> For data that is not a <code>content:</code> URI and where no explicit
257 * type is included in the Intent, instead the <b>scheme</b> of the
258 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
259 * considered. Again like the action, if we are matching a scheme it
260 * must be listed by the component as one it can handle.
261 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
262 * by the activity as categories it handles. That is, if you include
263 * the categories {@link #CATEGORY_LAUNCHER} and
264 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
265 * with an intent that lists <em>both</em> of those categories.
266 * Activities will very often need to support the
267 * {@link #CATEGORY_DEFAULT} so that they can be found by
268 * {@link Context#startActivity Context.startActivity()}.</p>
269 * </ul>
270 *
271 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700272 * allows a user to browse through a list of notes data and view details about
273 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700274 * name with one specific to your own package.</p>
275 *
276 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
277 * package="<i>com.android.notepad</i>"&gt;
278 * &lt;application android:icon="@drawable/app_notes"
279 * android:label="@string/app_name"&gt;
280 *
281 * &lt;provider class=".NotePadProvider"
282 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
283 *
284 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.MAIN" /&gt;
287 * &lt;category android:name="android.intent.category.LAUNCHER" /&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.VIEW" /&gt;
291 * &lt;action android:name="android.intent.action.EDIT" /&gt;
292 * &lt;action android:name="android.intent.action.PICK" /&gt;
293 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
294 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700295 * &lt;/intent-filter&gt;
296 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700297 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
298 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
299 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;
301 * &lt;/activity&gt;
302 *
303 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
304 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700305 * &lt;action android:name="android.intent.action.VIEW" /&gt;
306 * &lt;action android:name="android.intent.action.EDIT" /&gt;
307 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
308 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700309 * &lt;/intent-filter&gt;
310 *
311 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700312 * &lt;action android:name="android.intent.action.INSERT" /&gt;
313 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
314 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700315 * &lt;/intent-filter&gt;
316 *
317 * &lt;/activity&gt;
318 *
319 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
320 * android:theme="@android:style/Theme.Dialog"&gt;
321 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700322 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
323 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
324 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
325 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
326 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700327 * &lt;/intent-filter&gt;
328 * &lt;/activity&gt;
329 *
330 * &lt;/application&gt;
331 * &lt;/manifest&gt;</pre>
332 *
333 * <p>The first activity,
334 * <code>com.android.notepad.NotesList</code>, serves as our main
335 * entry into the app. It can do three things as described by its three intent
336 * templates:
337 * <ol>
338 * <li><pre>
339 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700340 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
341 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700342 * &lt;/intent-filter&gt;</pre>
343 * <p>This provides a top-level entry into the NotePad application: the standard
344 * MAIN action is a main entry point (not requiring any other information in
345 * the Intent), and the LAUNCHER category says that this entry point should be
346 * listed in the application launcher.</p>
347 * <li><pre>
348 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700349 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
350 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
351 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
352 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700353 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700354 * &lt;/intent-filter&gt;</pre>
355 * <p>This declares the things that the activity can do on a directory of
356 * notes. The type being supported is given with the &lt;type&gt; tag, where
357 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
358 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
359 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
360 * The activity allows the user to view or edit the directory of data (via
361 * the VIEW and EDIT actions), or to pick a particular note and return it
362 * to the caller (via the PICK action). Note also the DEFAULT category
363 * supplied here: this is <em>required</em> for the
364 * {@link Context#startActivity Context.startActivity} method to resolve your
365 * activity when its component name is not explicitly specified.</p>
366 * <li><pre>
367 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700368 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
369 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
370 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700371 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700372 * <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 -0700373 * the user without needing to know where it came from. The data type
374 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
375 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
376 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
377 * The GET_CONTENT action is similar to the PICK action, where the activity
378 * will return to its caller a piece of data selected by the user. Here,
379 * however, the caller specifies the type of data they desire instead of
380 * the type of data the user will be picking from.</p>
381 * </ol>
382 *
383 * <p>Given these capabilities, the following intents will resolve to the
384 * NotesList activity:</p>
385 *
386 * <ul>
387 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
388 * activities that can be used as top-level entry points into an
389 * application.</p>
390 * <li> <p><b>{ action=android.app.action.MAIN,
391 * category=android.app.category.LAUNCHER }</b> is the actual intent
392 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700393 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700394 * data=content://com.google.provider.NotePad/notes }</b>
395 * displays a list of all the notes under
396 * "content://com.google.provider.NotePad/notes", which
397 * the user can browse through and see the details on.</p>
398 * <li> <p><b>{ action=android.app.action.PICK
399 * data=content://com.google.provider.NotePad/notes }</b>
400 * provides a list of the notes under
401 * "content://com.google.provider.NotePad/notes", from which
402 * the user can pick a note whose data URL is returned back to the caller.</p>
403 * <li> <p><b>{ action=android.app.action.GET_CONTENT
404 * type=vnd.android.cursor.item/vnd.google.note }</b>
405 * is similar to the pick action, but allows the caller to specify the
406 * kind of data they want back so that the system can find the appropriate
407 * activity to pick something of that data type.</p>
408 * </ul>
409 *
410 * <p>The second activity,
411 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
412 * note entry and allows them to edit it. It can do two things as described
413 * by its two intent templates:
414 * <ol>
415 * <li><pre>
416 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700417 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
418 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
419 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
420 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700421 * &lt;/intent-filter&gt;</pre>
422 * <p>The first, primary, purpose of this activity is to let the user interact
423 * with a single note, as decribed by the MIME type
424 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
425 * either VIEW a note or allow the user to EDIT it. Again we support the
426 * DEFAULT category to allow the activity to be launched without explicitly
427 * specifying its component.</p>
428 * <li><pre>
429 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700430 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
431 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
432 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700433 * &lt;/intent-filter&gt;</pre>
434 * <p>The secondary use of this activity is to insert a new note entry into
435 * an existing directory of notes. This is used when the user creates a new
436 * note: the INSERT action is executed on the directory of notes, causing
437 * this activity to run and have the user create the new note data which
438 * it then adds to the content provider.</p>
439 * </ol>
440 *
441 * <p>Given these capabilities, the following intents will resolve to the
442 * NoteEditor activity:</p>
443 *
444 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700445 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700446 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
447 * shows the user the content of note <var>{ID}</var>.</p>
448 * <li> <p><b>{ action=android.app.action.EDIT
449 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
450 * allows the user to edit the content of note <var>{ID}</var>.</p>
451 * <li> <p><b>{ action=android.app.action.INSERT
452 * data=content://com.google.provider.NotePad/notes }</b>
453 * creates a new, empty note in the notes list at
454 * "content://com.google.provider.NotePad/notes"
455 * and allows the user to edit it. If they keep their changes, the URI
456 * of the newly created note is returned to the caller.</p>
457 * </ul>
458 *
459 * <p>The last activity,
460 * <code>com.android.notepad.TitleEditor</code>, allows the user to
461 * edit the title of a note. This could be implemented as a class that the
462 * application directly invokes (by explicitly setting its component in
463 * the Intent), but here we show a way you can publish alternative
464 * operations on existing data:</p>
465 *
466 * <pre>
467 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700468 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
469 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
470 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
471 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
472 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700473 * &lt;/intent-filter&gt;</pre>
474 *
475 * <p>In the single intent template here, we
476 * have created our own private action called
477 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
478 * edit the title of a note. It must be invoked on a specific note
479 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
480 * view and edit actions, but here displays and edits the title contained
481 * in the note data.
482 *
483 * <p>In addition to supporting the default category as usual, our title editor
484 * also supports two other standard categories: ALTERNATIVE and
485 * SELECTED_ALTERNATIVE. Implementing
486 * these categories allows others to find the special action it provides
487 * without directly knowing about it, through the
488 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
489 * more often to build dynamic menu items with
490 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
491 * template here was also supply an explicit name for the template
492 * (via <code>android:label="@string/resolve_title"</code>) to better control
493 * what the user sees when presented with this activity as an alternative
494 * action to the data they are viewing.
495 *
496 * <p>Given these capabilities, the following intent will resolve to the
497 * TitleEditor activity:</p>
498 *
499 * <ul>
500 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
501 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
502 * displays and allows the user to edit the title associated
503 * with note <var>{ID}</var>.</p>
504 * </ul>
505 *
506 * <h3>Standard Activity Actions</h3>
507 *
508 * <p>These are the current standard actions that Intent defines for launching
509 * activities (usually through {@link Context#startActivity}. The most
510 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
511 * {@link #ACTION_EDIT}.
512 *
513 * <ul>
514 * <li> {@link #ACTION_MAIN}
515 * <li> {@link #ACTION_VIEW}
516 * <li> {@link #ACTION_ATTACH_DATA}
517 * <li> {@link #ACTION_EDIT}
518 * <li> {@link #ACTION_PICK}
519 * <li> {@link #ACTION_CHOOSER}
520 * <li> {@link #ACTION_GET_CONTENT}
521 * <li> {@link #ACTION_DIAL}
522 * <li> {@link #ACTION_CALL}
523 * <li> {@link #ACTION_SEND}
524 * <li> {@link #ACTION_SENDTO}
525 * <li> {@link #ACTION_ANSWER}
526 * <li> {@link #ACTION_INSERT}
527 * <li> {@link #ACTION_DELETE}
528 * <li> {@link #ACTION_RUN}
529 * <li> {@link #ACTION_SYNC}
530 * <li> {@link #ACTION_PICK_ACTIVITY}
531 * <li> {@link #ACTION_SEARCH}
532 * <li> {@link #ACTION_WEB_SEARCH}
533 * <li> {@link #ACTION_FACTORY_TEST}
534 * </ul>
535 *
536 * <h3>Standard Broadcast Actions</h3>
537 *
538 * <p>These are the current standard actions that Intent defines for receiving
539 * broadcasts (usually through {@link Context#registerReceiver} or a
540 * &lt;receiver&gt; tag in a manifest).
541 *
542 * <ul>
543 * <li> {@link #ACTION_TIME_TICK}
544 * <li> {@link #ACTION_TIME_CHANGED}
545 * <li> {@link #ACTION_TIMEZONE_CHANGED}
546 * <li> {@link #ACTION_BOOT_COMPLETED}
547 * <li> {@link #ACTION_PACKAGE_ADDED}
548 * <li> {@link #ACTION_PACKAGE_CHANGED}
549 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800550 * <li> {@link #ACTION_PACKAGE_RESTARTED}
551 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000552 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
553 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700554 * <li> {@link #ACTION_UID_REMOVED}
555 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700556 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700557 * <li> {@link #ACTION_POWER_DISCONNECTED}
558 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700559 * </ul>
560 *
561 * <h3>Standard Categories</h3>
562 *
563 * <p>These are the current standard categories that can be used to further
564 * clarify an Intent via {@link #addCategory}.
565 *
566 * <ul>
567 * <li> {@link #CATEGORY_DEFAULT}
568 * <li> {@link #CATEGORY_BROWSABLE}
569 * <li> {@link #CATEGORY_TAB}
570 * <li> {@link #CATEGORY_ALTERNATIVE}
571 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
572 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700574 * <li> {@link #CATEGORY_HOME}
575 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700576 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400577 * <li> {@link #CATEGORY_CAR_DOCK}
578 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500579 * <li> {@link #CATEGORY_LE_DESK_DOCK}
580 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200581 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700582 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800583 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700584 * </ul>
585 *
586 * <h3>Standard Extra Data</h3>
587 *
588 * <p>These are the current standard fields that can be used as extra data via
589 * {@link #putExtra}.
590 *
591 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800592 * <li> {@link #EXTRA_ALARM_COUNT}
593 * <li> {@link #EXTRA_BCC}
594 * <li> {@link #EXTRA_CC}
595 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
596 * <li> {@link #EXTRA_DATA_REMOVED}
597 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500598 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
599 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_DOCK_STATE_CAR}
601 * <li> {@link #EXTRA_DOCK_STATE_DESK}
602 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
603 * <li> {@link #EXTRA_DONT_KILL_APP}
604 * <li> {@link #EXTRA_EMAIL}
605 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700608 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700610 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800611 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
612 * <li> {@link #EXTRA_REPLACING}
613 * <li> {@link #EXTRA_SHORTCUT_ICON}
614 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
615 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800617 * <li> {@link #EXTRA_SHORTCUT_NAME}
618 * <li> {@link #EXTRA_SUBJECT}
619 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700620 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800621 * <li> {@link #EXTRA_TITLE}
622 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700623 * </ul>
624 *
625 * <h3>Flags</h3>
626 *
627 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800628 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
629 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700630 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800631public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700632 private static final String ATTR_ACTION = "action";
633 private static final String TAG_CATEGORIES = "categories";
634 private static final String ATTR_CATEGORY = "category";
635 private static final String TAG_EXTRA = "extra";
636 private static final String ATTR_TYPE = "type";
637 private static final String ATTR_COMPONENT = "component";
638 private static final String ATTR_DATA = "data";
639 private static final String ATTR_FLAGS = "flags";
640
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700641 // ---------------------------------------------------------------------
642 // ---------------------------------------------------------------------
643 // Standard intent activity actions (see action variable).
644
645 /**
646 * Activity Action: Start as a main entry point, does not expect to
647 * receive data.
648 * <p>Input: nothing
649 * <p>Output: nothing
650 */
651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
652 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 /**
655 * Activity Action: Display the data to the user. This is the most common
656 * action performed on data -- it is the generic action you can use on
657 * a piece of data to get the most reasonable thing to occur. For example,
658 * when used on a contacts entry it will view the entry; when used on a
659 * mailto: URI it will bring up a compose window filled with the information
660 * supplied by the URI; when used with a tel: URI it will invoke the
661 * dialer.
662 * <p>Input: {@link #getData} is URI from which to retrieve data.
663 * <p>Output: nothing.
664 */
665 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
666 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800667
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700668 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700669 * Extra that can be included on activity intents coming from the storage UI
670 * when it launches sub-activities to manage various types of storage. For example,
671 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
672 * the images on the device, and in that case also include this extra to tell the
673 * app it is coming from the storage UI so should help the user manage storage of
674 * this type.
675 */
676 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
677
678 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700679 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
680 * performed on a piece of data.
681 */
682 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800683
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700684 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900685 * Activity Action: Quick view the data. Launches a quick viewer for
686 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900687 * <p>Activities handling this intent action should handle the vast majority of
688 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700689 * <p>Quick viewers must render the quick view image locally, and must not send
690 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900691 * <p>Input: {@link #getData} is a mandatory content URI of the item to
692 * preview. {@link #getClipData} contains an optional list of content URIs
693 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
694 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700695 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
696 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700697 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900698 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700699 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
703
704 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700705 * Used to indicate that some piece of data should be attached to some other
706 * place. For example, image data could be attached to a contact. It is up
707 * to the recipient to decide where the data should be attached; the intent
708 * does not specify the ultimate destination.
709 * <p>Input: {@link #getData} is URI of data to be attached.
710 * <p>Output: nothing.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715 /**
716 * Activity Action: Provide explicit editable access to the given data.
717 * <p>Input: {@link #getData} is URI of data to be edited.
718 * <p>Output: nothing.
719 */
720 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
721 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800722
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700723 /**
724 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
725 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
726 * The extras can contain type specific data to pass through to the editing/creating
727 * activity.
728 * <p>Output: The URI of the item that was picked. This must be a content:
729 * URI so that any receiver can access it.
730 */
731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
732 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 /**
735 * Activity Action: Pick an item from the data, returning what was selected.
736 * <p>Input: {@link #getData} is URI containing a directory of data
737 * (vnd.android.cursor.dir/*) from which to pick an item.
738 * <p>Output: The URI of the item that was picked.
739 */
740 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
741 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800742
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700743 /**
744 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800745 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800746 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
747 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
749 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800750 * (value: ShortcutIconResource).</p>
751 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800752 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700753 * @see #EXTRA_SHORTCUT_INTENT
754 * @see #EXTRA_SHORTCUT_NAME
755 * @see #EXTRA_SHORTCUT_ICON
756 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
757 * @see android.content.Intent.ShortcutIconResource
758 */
759 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
760 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
761
762 /**
763 * The name of the extra used to define the Intent of a shortcut.
764 *
765 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800766 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800768 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700769 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
770 /**
771 * The name of the extra used to define the name of a shortcut.
772 *
773 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800776 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700777 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
778 /**
779 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
780 *
781 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800782 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700783 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800784 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700785 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
786 /**
787 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
788 *
789 * @see #ACTION_CREATE_SHORTCUT
790 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800791 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700792 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800793 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700794 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
795 "android.intent.extra.shortcut.ICON_RESOURCE";
796
797 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500798 * An activity that provides a user interface for adjusting application preferences.
799 * Optional but recommended settings for all applications which have settings.
800 */
801 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
802 public static final String ACTION_APPLICATION_PREFERENCES
803 = "android.intent.action.APPLICATION_PREFERENCES";
804
805 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700806 * Activity Action: Launch an activity showing the app information.
807 * For applications which install other applications (such as app stores), it is recommended
808 * to handle this action for providing the app information to the user.
809 *
810 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
811 * to be displayed.
812 * <p>Output: Nothing.
813 */
814 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
815 public static final String ACTION_SHOW_APP_INFO
816 = "android.intent.action.SHOW_APP_INFO";
817
818 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800819 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700820 *
821 * @see Intent#ACTION_CREATE_SHORTCUT
822 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800823 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
824 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700825 */
826 public static class ShortcutIconResource implements Parcelable {
827 /**
828 * The package name of the application containing the icon.
829 */
830 public String packageName;
831
832 /**
833 * The resource name of the icon, including package, name and type.
834 */
835 public String resourceName;
836
837 /**
838 * Creates a new ShortcutIconResource for the specified context and resource
839 * identifier.
840 *
841 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700842 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700843 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700844 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700845 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700846 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700847 ShortcutIconResource icon = new ShortcutIconResource();
848 icon.packageName = context.getPackageName();
849 icon.resourceName = context.getResources().getResourceName(resourceId);
850 return icon;
851 }
852
853 /**
854 * Used to read a ShortcutIconResource from a Parcel.
855 */
856 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
857 new Parcelable.Creator<ShortcutIconResource>() {
858
859 public ShortcutIconResource createFromParcel(Parcel source) {
860 ShortcutIconResource icon = new ShortcutIconResource();
861 icon.packageName = source.readString();
862 icon.resourceName = source.readString();
863 return icon;
864 }
865
866 public ShortcutIconResource[] newArray(int size) {
867 return new ShortcutIconResource[size];
868 }
869 };
870
871 /**
872 * No special parcel contents.
873 */
874 public int describeContents() {
875 return 0;
876 }
877
878 public void writeToParcel(Parcel dest, int flags) {
879 dest.writeString(packageName);
880 dest.writeString(resourceName);
881 }
882
883 @Override
884 public String toString() {
885 return resourceName;
886 }
887 }
888
889 /**
890 * Activity Action: Display an activity chooser, allowing the user to pick
891 * what they want to before proceeding. This can be used as an alternative
892 * to the standard activity picker that is displayed by the system when
893 * you try to start an activity with multiple possible matches, with these
894 * differences in behavior:
895 * <ul>
896 * <li>You can specify the title that will appear in the activity chooser.
897 * <li>The user does not have the option to make one of the matching
898 * activities a preferred activity, and all possible activities will
899 * always be shown even if one of them is currently marked as the
900 * preferred activity.
901 * </ul>
902 * <p>
903 * This action should be used when the user will naturally expect to
904 * select an activity in order to proceed. An example if when not to use
905 * it is when the user clicks on a "mailto:" link. They would naturally
906 * expect to go directly to their mail app, so startActivity() should be
907 * called directly: it will
908 * either launch the current preferred app, or put up a dialog allowing the
909 * user to pick an app to use and optionally marking that as preferred.
910 * <p>
911 * In contrast, if the user is selecting a menu item to send a picture
912 * they are viewing to someone else, there are many different things they
913 * may want to do at this point: send it through e-mail, upload it to a
914 * web service, etc. In this case the CHOOSER action should be used, to
915 * always present to the user a list of the things they can do, with a
916 * nice title given by the caller such as "Send this photo with:".
917 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700918 * If you need to grant URI permissions through a chooser, you must specify
919 * the permissions to be granted on the ACTION_CHOOSER Intent
920 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
921 * {@link #setClipData} to specify the URIs to be granted as well as
922 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
923 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
924 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700925 * As a convenience, an Intent of this form can be created with the
926 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700927 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700928 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700929 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
930 * and can optionally have a {@link #EXTRA_TITLE} field containing the
931 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700932 * <p>
933 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700934 */
935 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
936 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
937
938 /**
939 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
940 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700941 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
942 * target intent, also optionally supplying a title. If the target
943 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
944 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
945 * set in the returned chooser intent, with its ClipData set appropriately:
946 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500947 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700948 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700949 * @param target The Intent that the user will be selecting an activity
950 * to perform.
951 * @param title Optional title that will be displayed in the chooser.
952 * @return Return a new Intent object that you can hand to
953 * {@link Context#startActivity(Intent) Context.startActivity()} and
954 * related methods.
955 */
956 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700957 return createChooser(target, title, null);
958 }
959
960 /**
961 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
962 *
963 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
964 * target intent, also optionally supplying a title. If the target
965 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
966 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
967 * set in the returned chooser intent, with its ClipData set appropriately:
968 * either a direct reflection of {@link #getClipData()} if that is non-null,
969 * or a new ClipData built from {@link #getData()}.</p>
970 *
971 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
972 * when the user makes a choice. This can be useful if the calling application wants
973 * to remember the last chosen target and surface it as a more prominent or one-touch
974 * affordance elsewhere in the UI for next time.</p>
975 *
976 * @param target The Intent that the user will be selecting an activity
977 * to perform.
978 * @param title Optional title that will be displayed in the chooser.
979 * @param sender Optional IntentSender to be called when a choice is made.
980 * @return Return a new Intent object that you can hand to
981 * {@link Context#startActivity(Intent) Context.startActivity()} and
982 * related methods.
983 */
984 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700985 Intent intent = new Intent(ACTION_CHOOSER);
986 intent.putExtra(EXTRA_INTENT, target);
987 if (title != null) {
988 intent.putExtra(EXTRA_TITLE, title);
989 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700990
Adam Powell0b3c1122014-10-09 12:50:14 -0700991 if (sender != null) {
992 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
993 }
994
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700995 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700996 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
997 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
998 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700999 if (permFlags != 0) {
1000 ClipData targetClipData = target.getClipData();
1001 if (targetClipData == null && target.getData() != null) {
1002 ClipData.Item item = new ClipData.Item(target.getData());
1003 String[] mimeTypes;
1004 if (target.getType() != null) {
1005 mimeTypes = new String[] { target.getType() };
1006 } else {
1007 mimeTypes = new String[] { };
1008 }
1009 targetClipData = new ClipData(null, mimeTypes, item);
1010 }
1011 if (targetClipData != null) {
1012 intent.setClipData(targetClipData);
1013 intent.addFlags(permFlags);
1014 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001015 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001016
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001017 return intent;
1018 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001019
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001020 /**
1021 * Activity Action: Allow the user to select a particular kind of data and
1022 * return it. This is different than {@link #ACTION_PICK} in that here we
1023 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001024 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001025 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001026 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001027 * etc.
1028 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001029 * 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 -07001030 * of data, such as a person contact, you set the MIME type to the kind of
1031 * data you want and launch it with {@link Context#startActivity(Intent)}.
1032 * The system will then launch the best application to select that kind
1033 * of data for you.
1034 * <p>
1035 * You may also be interested in any of a set of types of content the user
1036 * can pick. For example, an e-mail application that wants to allow the
1037 * user to add an attachment to an e-mail message can use this action to
1038 * bring up a list of all of the types of content the user can attach.
1039 * <p>
1040 * In this case, you should wrap the GET_CONTENT intent with a chooser
1041 * (through {@link #createChooser}), which will give the proper interface
1042 * for the user to pick how to send your data and allow you to specify
1043 * a prompt indicating what they are doing. You will usually specify a
1044 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1045 * broad range of content types the user can select from.
1046 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001047 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001048 * only pick from data that can be represented as a stream. This is
1049 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1050 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001051 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001052 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001053 * is locally available on the device. For example, if this extra is set
1054 * to true then an image picker should not show any pictures that are available
1055 * from a remote server but not already on the local device (thus requiring
1056 * they be downloaded when opened).
1057 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001058 * If the caller can handle multiple returned items (the user performing
1059 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1060 * to indicate this.
1061 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001062 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1063 * that no URI is supplied in the intent, as there are no constraints on
1064 * where the returned data originally comes from. You may also include the
1065 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001066 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001067 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1068 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001069 * <p>
1070 * Output: The URI of the item that was picked. This must be a content:
1071 * URI so that any receiver can access it.
1072 */
1073 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1074 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1075 /**
1076 * Activity Action: Dial a number as specified by the data. This shows a
1077 * UI with the number being dialed, allowing the user to explicitly
1078 * initiate the call.
1079 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1080 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1081 * number.
1082 * <p>Output: nothing.
1083 */
1084 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1085 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1086 /**
1087 * Activity Action: Perform a call to someone specified by the data.
1088 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1089 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1090 * number.
1091 * <p>Output: nothing.
1092 *
1093 * <p>Note: there will be restrictions on which applications can initiate a
1094 * call; most applications should use the {@link #ACTION_DIAL}.
1095 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1096 * numbers. Applications can <strong>dial</strong> emergency numbers using
1097 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001098 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001099 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001100 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001101 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001102 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001103 */
1104 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1105 public static final String ACTION_CALL = "android.intent.action.CALL";
1106 /**
1107 * Activity Action: Perform a call to an emergency number specified by the
1108 * data.
1109 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1110 * tel: URI of an explicit phone number.
1111 * <p>Output: nothing.
1112 * @hide
1113 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001114 @SystemApi
1115 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001116 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1117 /**
1118 * Activity action: Perform a call to any number (emergency or not)
1119 * specified by the data.
1120 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1121 * tel: URI of an explicit phone number.
1122 * <p>Output: nothing.
1123 * @hide
1124 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001125 @SystemApi
1126 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001127 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001128
Santos Cordon15a13782015-03-31 18:32:31 -07001129 /**
fionaxuadfe7002017-02-17 17:20:46 -08001130 * Activity Action: Main entry point for carrier setup apps.
1131 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1132 * carrier service and typically require
1133 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1134 * fulfill their duties.
1135 */
1136 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1137 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1138 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001139 * Activity Action: Send a message to someone specified by the data.
1140 * <p>Input: {@link #getData} is URI describing the target.
1141 * <p>Output: nothing.
1142 */
1143 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1144 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1145 /**
1146 * Activity Action: Deliver some data to someone else. Who the data is
1147 * being delivered to is not specified; it is up to the receiver of this
1148 * action to ask the user where the data should be sent.
1149 * <p>
1150 * When launching a SEND intent, you should usually wrap it in a chooser
1151 * (through {@link #createChooser}), which will give the proper interface
1152 * for the user to pick how to send your data and allow you to specify
1153 * a prompt indicating what they are doing.
1154 * <p>
1155 * Input: {@link #getType} is the MIME type of the data being sent.
1156 * get*Extra can have either a {@link #EXTRA_TEXT}
1157 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1158 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1159 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1160 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001161 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1162 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1163 * your text with HTML formatting.
1164 * <p>
1165 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1166 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1167 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1168 * content: URIs and other advanced features of {@link ClipData}. If
1169 * using this approach, you still must supply the same data through the
1170 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1171 * for compatibility with old applications. If you don't set a ClipData,
1172 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001173 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001174 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1175 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1176 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1177 * be openable only as asset typed files using
1178 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1179 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001180 * Optional standard extras, which may be interpreted by some recipients as
1181 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1182 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1183 * <p>
1184 * Output: nothing.
1185 */
1186 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187 public static final String ACTION_SEND = "android.intent.action.SEND";
1188 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001189 * Activity Action: Deliver multiple data to someone else.
1190 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001191 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001192 * <p>
1193 * Input: {@link #getType} is the MIME type of the data being sent.
1194 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001195 * #EXTRA_STREAM} field, containing the data to be sent. If using
1196 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1197 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001198 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001199 * Multiple types are supported, and receivers should handle mixed types
1200 * whenever possible. The right way for the receiver to check them is to
1201 * use the content resolver on each URI. The intent sender should try to
1202 * put the most concrete mime type in the intent type, but it can fall
1203 * back to {@literal <type>/*} or {@literal *}/* as needed.
1204 * <p>
1205 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1206 * be image/jpg, but if you are sending image/jpg and image/png, then the
1207 * intent's type should be image/*.
1208 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001209 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1210 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1211 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1212 * content: URIs and other advanced features of {@link ClipData}. If
1213 * using this approach, you still must supply the same data through the
1214 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1215 * for compatibility with old applications. If you don't set a ClipData,
1216 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1217 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001218 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1219 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1220 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1221 * be openable only as asset typed files using
1222 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1223 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001224 * Optional standard extras, which may be interpreted by some recipients as
1225 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1226 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1227 * <p>
1228 * Output: nothing.
1229 */
1230 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1231 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1232 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001233 * Activity Action: Handle an incoming phone call.
1234 * <p>Input: nothing.
1235 * <p>Output: nothing.
1236 */
1237 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1238 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1239 /**
1240 * Activity Action: Insert an empty item into the given container.
1241 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1242 * in which to place the data.
1243 * <p>Output: URI of the new data that was created.
1244 */
1245 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1246 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1247 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001248 * Activity Action: Create a new item in the given container, initializing it
1249 * from the current contents of the clipboard.
1250 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1251 * in which to place the data.
1252 * <p>Output: URI of the new data that was created.
1253 */
1254 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1255 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1256 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001257 * Activity Action: Delete the given data from its container.
1258 * <p>Input: {@link #getData} is URI of data to be deleted.
1259 * <p>Output: nothing.
1260 */
1261 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1262 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1263 /**
1264 * Activity Action: Run the data, whatever that means.
1265 * <p>Input: ? (Note: this is currently specific to the test harness.)
1266 * <p>Output: nothing.
1267 */
1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1269 public static final String ACTION_RUN = "android.intent.action.RUN";
1270 /**
1271 * Activity Action: Perform a data synchronization.
1272 * <p>Input: ?
1273 * <p>Output: ?
1274 */
1275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1276 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1277 /**
1278 * Activity Action: Pick an activity given an intent, returning the class
1279 * selected.
1280 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1281 * used with {@link PackageManager#queryIntentActivities} to determine the
1282 * set of activities from which to pick.
1283 * <p>Output: Class name of the activity that was selected.
1284 */
1285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1286 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1287 /**
1288 * Activity Action: Perform a search.
1289 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1290 * is the text to search for. If empty, simply
1291 * enter your search results Activity with the search UI activated.
1292 * <p>Output: nothing.
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1296 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001297 * Activity Action: Start the platform-defined tutorial
1298 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1299 * is the text to search for. If empty, simply
1300 * enter your search results Activity with the search UI activated.
1301 * <p>Output: nothing.
1302 */
1303 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1304 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1305 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001306 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001307 * <p>
1308 * Input: {@link android.app.SearchManager#QUERY
1309 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1310 * a url starts with http or https, the site will be opened. If it is plain
1311 * text, Google search will be applied.
1312 * <p>
1313 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001314 */
1315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1316 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001317
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001318 /**
Jim Miller07994402012-05-02 14:22:27 -07001319 * Activity Action: Perform assist action.
1320 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001321 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1322 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001323 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1324 * information.
Jim Miller07994402012-05-02 14:22:27 -07001325 * Output: nothing.
1326 */
1327 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1328 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001329
1330 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001331 * Activity Action: Perform voice assist action.
1332 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001333 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1334 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001335 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001336 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001337 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001338 */
Amith Yamasani16452032017-03-03 10:15:57 -08001339 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001340 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1341 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1342
1343 /**
Adam Skory7140a252013-09-11 12:04:58 +01001344 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1345 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001346 */
1347 public static final String EXTRA_ASSIST_PACKAGE
1348 = "android.intent.extra.ASSIST_PACKAGE";
1349
1350 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001351 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1352 * application package at the time the assist was invoked.
1353 */
1354 public static final String EXTRA_ASSIST_UID
1355 = "android.intent.extra.ASSIST_UID";
1356
1357 /**
Adam Skory7140a252013-09-11 12:04:58 +01001358 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1359 * information supplied by the current foreground app at the time of the assist request.
1360 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001361 */
1362 public static final String EXTRA_ASSIST_CONTEXT
1363 = "android.intent.extra.ASSIST_CONTEXT";
1364
Jim Miller07994402012-05-02 14:22:27 -07001365 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001366 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1367 * keyboard as the primary input device for assistance.
1368 */
1369 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1370 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1371
1372 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001373 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1374 * that was used to invoke the assist.
1375 */
1376 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1377 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1378
1379 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001380 * Activity Action: List all available applications.
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_ALL_APPS = "android.intent.action.ALL_APPS";
1386 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001387 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001388 * <p>Input: Nothing.
1389 * <p>Output: Nothing.
1390 */
1391 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1392 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1393
1394 /**
1395 * Activity Action: Show activity for reporting a bug.
1396 * <p>Input: Nothing.
1397 * <p>Output: Nothing.
1398 */
1399 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1400 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1401
1402 /**
1403 * Activity Action: Main entry point for factory tests. Only used when
1404 * the device is booting in factory test node. The implementing package
1405 * must be installed in the system image.
1406 * <p>Input: nothing
1407 * <p>Output: nothing
1408 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001409 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001410 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1411
1412 /**
1413 * Activity Action: The user pressed the "call" button to go to the dialer
1414 * or other appropriate UI for placing a call.
1415 * <p>Input: Nothing.
1416 * <p>Output: Nothing.
1417 */
1418 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1419 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1420
1421 /**
1422 * Activity Action: Start Voice Command.
1423 * <p>Input: Nothing.
1424 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001425 * <p class="note">
1426 * In some cases, a matching Activity may not exist, so ensure you
1427 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001428 */
1429 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1430 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001431
1432 /**
1433 * Activity Action: Start action associated with long pressing on the
1434 * search key.
1435 * <p>Input: Nothing.
1436 * <p>Output: Nothing.
1437 */
1438 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1439 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001440
Jacek Surazski86b6c532009-05-13 14:38:28 +02001441 /**
1442 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1443 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001444 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001445 * <p>Input: No data is specified. The bug report is passed in using
1446 * an {@link #EXTRA_BUG_REPORT} field.
1447 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001448 *
1449 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001450 */
1451 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1452 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001453
1454 /**
1455 * Activity Action: Show power usage information to the user.
1456 * <p>Input: Nothing.
1457 * <p>Output: Nothing.
1458 */
1459 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1460 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001461
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001462 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001463 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1464 * to run.
1465 * <p>Input: Nothing.
1466 * <p>Output: Nothing.
1467 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1468 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1469 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001470 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001471 */
1472 @Deprecated
1473 @SystemApi
1474 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1475 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1476
1477 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001478 * Activity Action: Setup wizard to launch after a platform update. This
1479 * activity should have a string meta-data field associated with it,
1480 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1481 * the platform for setup. The activity will be launched only if
1482 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1483 * same value.
1484 * <p>Input: Nothing.
1485 * <p>Output: Nothing.
1486 * @hide
1487 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001488 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001489 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1490 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001491
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001492 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001493 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1494 * <p>Input: Nothing.
1495 * <p>Output: Nothing.
1496 * @hide
1497 */
1498 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1499 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001500 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001501
1502 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001503 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1504 * <p>Input: Nothing.
1505 * <p>Output: Nothing.
1506 * @hide
1507 */
1508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1509 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001510 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001511
1512 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001513 * Activity Action: Show settings for managing network data usage of a
1514 * specific application. Applications should define an activity that offers
1515 * options to control data usage.
1516 */
1517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1518 public static final String ACTION_MANAGE_NETWORK_USAGE =
1519 "android.intent.action.MANAGE_NETWORK_USAGE";
1520
1521 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001522 * Activity Action: Launch application installer.
1523 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001524 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001525 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1526 * you can also use "package:<package-name>" to install an application for the
1527 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001528 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1529 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1530 * <p>
1531 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1532 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001533 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001534 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001535 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1536 * in order to launch the application installer.
1537 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001538 *
1539 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1540 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1541 * @see #EXTRA_RETURN_RESULT
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001542 *
1543 * @deprecated use {@link android.content.pm.PackageInstaller} instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001544 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001545 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001546 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1547 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1548
1549 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001550 * Activity Action: Activity to handle split installation failures.
1551 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1552 * but the split that contains the application isn't installed. When a split is
1553 * installed in this manner, the containing package usually doesn't know this is
1554 * happening. However, if an error occurs during installation, the containing
1555 * package can define a single activity handling this action to deal with such
1556 * failures.
1557 * <p>The activity handling this action must be in the base package.
1558 * <p>
1559 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1560 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1561 */
1562 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1563 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1564
1565 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001566 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001567 * <p class="note">
1568 * This is a protected intent that can only be sent by the system.
1569 * </p>
1570 *
1571 * @hide
1572 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001573 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001574 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001575 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1576 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001577
1578 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001579 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001580 * <p>
1581 * The system will have a persistent connection to this service.
1582 * This is a protected intent that can only be sent by the system.
1583 * </p>
1584 *
1585 * @hide
1586 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001587 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001588 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001589 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1590 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001591
1592 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001593 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001594 *
1595 * <p class="note">
1596 * This is a protected intent that can only be sent by the system.
1597 * </p>
1598 *
1599 * @hide
1600 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001601 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001602 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001603 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1604 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001605
1606 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001607 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1608 * package. Specifies the installer package name; this package will receive the
1609 * {@link #ACTION_APP_ERROR} intent.
1610 */
1611 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1612 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1613
1614 /**
1615 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1616 * package. Specifies that the application being installed should not be
1617 * treated as coming from an unknown source, but as coming from the app
1618 * invoking the Intent. For this to work you must start the installer with
1619 * startActivityForResult().
1620 */
1621 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1622 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1623
1624 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001625 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1626 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001627 * data field originated from.
1628 */
rich cannings706e8ba2012-08-20 13:20:14 -07001629 public static final String EXTRA_ORIGINATING_URI
1630 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001631
1632 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001633 * This extra can be used with any Intent used to launch an activity, supplying information
1634 * about who is launching that activity. This field contains a {@link android.net.Uri}
1635 * object, typically an http: or https: URI of the web site that the referral came from;
1636 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1637 * a native application that it came from.
1638 *
1639 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1640 * instead of directly retrieving the extra. It is also valid for applications to
1641 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1642 * a string, not a Uri; the field here, if supplied, will always take precedence,
1643 * however.</p>
1644 *
1645 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001646 */
1647 public static final String EXTRA_REFERRER
1648 = "android.intent.extra.REFERRER";
1649
1650 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001651 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1652 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1653 * not be created, in particular when Intent extras are supplied through the
1654 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1655 * schemes.
1656 *
1657 * @see #EXTRA_REFERRER
1658 */
1659 public static final String EXTRA_REFERRER_NAME
1660 = "android.intent.extra.REFERRER_NAME";
1661
1662 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001663 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001664 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001665 * Currently only a system app that hosts the provider authority "downloads" or holds the
1666 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001667 * @hide
1668 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001669 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001670 public static final String EXTRA_ORIGINATING_UID
1671 = "android.intent.extra.ORIGINATING_UID";
1672
1673 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001674 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1675 * package. Tells the installer UI to skip the confirmation with the user
1676 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001677 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1678 * will no longer show an interstitial message about updating existing
1679 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001680 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001681 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001682 public static final String EXTRA_ALLOW_REPLACE
1683 = "android.intent.extra.ALLOW_REPLACE";
1684
1685 /**
1686 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1687 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1688 * return to the application the result code of the install/uninstall. The returned result
1689 * code will be {@link android.app.Activity#RESULT_OK} on success or
1690 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1691 */
1692 public static final String EXTRA_RETURN_RESULT
1693 = "android.intent.extra.RETURN_RESULT";
1694
1695 /**
1696 * Package manager install result code. @hide because result codes are not
1697 * yet ready to be exposed.
1698 */
1699 public static final String EXTRA_INSTALL_RESULT
1700 = "android.intent.extra.INSTALL_RESULT";
1701
1702 /**
1703 * Activity Action: Launch application uninstaller.
1704 * <p>
1705 * Input: The data must be a package: URI whose scheme specific part is
1706 * the package name of the current installed package to be uninstalled.
1707 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1708 * <p>
1709 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1710 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001711 * <p>
1712 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1713 * since {@link Build.VERSION_CODES#P}.
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001714 *
1715 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1716 * instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001717 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001718 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001719 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1720 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1721
1722 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001723 * Specify whether the package should be uninstalled for all users.
1724 * @hide because these should not be part of normal application flow.
1725 */
1726 public static final String EXTRA_UNINSTALL_ALL_USERS
1727 = "android.intent.extra.UNINSTALL_ALL_USERS";
1728
1729 /**
Varun Shahb9fd6be2018-10-22 19:16:33 -07001730 * A string that associates with a metadata entry, indicating the last run version of the
1731 * platform that was setup.
1732 *
1733 * @see #ACTION_UPGRADE_SETUP
1734 *
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001735 * @hide
1736 */
Varun Shahb9fd6be2018-10-22 19:16:33 -07001737 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001738 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1739
Svet Ganov3695b8a2015-03-24 16:30:25 -07001740 /**
1741 * Activity action: Launch UI to manage the permissions of an app.
1742 * <p>
1743 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1744 * will be managed by the launched UI.
1745 * </p>
1746 * <p>
1747 * Output: Nothing.
1748 * </p>
1749 *
1750 * @see #EXTRA_PACKAGE_NAME
1751 *
1752 * @hide
1753 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001754 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001755 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1756 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1757 "android.intent.action.MANAGE_APP_PERMISSIONS";
1758
1759 /**
Philip P. Moltmanned988282018-11-07 16:19:42 -08001760 * Activity action: Launch UI to manage a specific permissions of an app.
1761 * <p>
1762 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1763 * will be managed by the launched UI.
1764 * </p>
1765 * <p>
1766 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1767 * that should be managed by the launched UI.
1768 * </p>
1769 * <p>
Joel Galensonad219782018-11-21 10:43:18 -08001770 * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1771 * </p>
1772 * <p>
Philip P. Moltmanned988282018-11-07 16:19:42 -08001773 * Output: Nothing.
1774 * </p>
1775 *
1776 * @see #EXTRA_PACKAGE_NAME
1777 * @see #EXTRA_PERMISSION_NAME
1778 *
1779 * @hide
1780 */
1781 @SystemApi
1782 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1783 public static final String ACTION_MANAGE_APP_PERMISSION =
1784 "android.intent.action.MANAGE_APP_PERMISSION";
1785
1786 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001787 * Activity action: Launch UI to manage permissions.
1788 * <p>
1789 * Input: Nothing.
1790 * </p>
1791 * <p>
1792 * Output: Nothing.
1793 * </p>
1794 *
1795 * @hide
1796 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001797 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001798 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1799 public static final String ACTION_MANAGE_PERMISSIONS =
1800 "android.intent.action.MANAGE_PERMISSIONS";
1801
1802 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001803 * Activity action: Launch UI to review permissions for an app.
1804 * The system uses this intent if permission review for apps not
1805 * supporting the new runtime permissions model is enabled. In
1806 * this mode a permission review is required before any of the
1807 * app components can run.
1808 * <p>
1809 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1810 * permissions will be reviewed (mandatory).
1811 * </p>
1812 * <p>
1813 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1814 * be fired after the permission review (optional).
1815 * </p>
1816 * <p>
1817 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1818 * be invoked after the permission review (optional).
1819 * </p>
1820 * <p>
1821 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1822 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1823 * </p>
1824 * <p>
1825 * Output: Nothing.
1826 * </p>
1827 *
1828 * @see #EXTRA_PACKAGE_NAME
1829 * @see #EXTRA_INTENT
1830 * @see #EXTRA_REMOTE_CALLBACK
1831 * @see #EXTRA_RESULT_NEEDED
1832 *
1833 * @hide
1834 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001835 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001836 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1837 public static final String ACTION_REVIEW_PERMISSIONS =
1838 "android.intent.action.REVIEW_PERMISSIONS";
1839
1840 /**
1841 * Intent extra: A callback for reporting remote result as a bundle.
1842 * <p>
1843 * Type: IRemoteCallback
1844 * </p>
1845 *
1846 * @hide
1847 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001848 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001849 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1850
1851 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001852 * Intent extra: An app package name.
1853 * <p>
1854 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001855 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001856 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001857 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001858 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1859
1860 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001861 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1862 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1863 *
1864 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1865 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1866 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001867 *
1868 * @see #ACTION_MY_PACKAGE_SUSPENDED
1869 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1870 * @see PackageManager#isPackageSuspended()
1871 * @see PackageManager#getSuspendedPackageAppExtras()
1872 */
1873 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1874
1875 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001876 * Intent extra: An app split name.
1877 * <p>
1878 * Type: String
1879 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001880 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001881 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1882
1883 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001884 * Intent extra: A {@link ComponentName} value.
1885 * <p>
1886 * Type: String
1887 * </p>
1888 */
1889 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1890
1891 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001892 * Intent extra: An extra for specifying whether a result is needed.
1893 * <p>
1894 * Type: boolean
1895 * </p>
1896 *
1897 * @hide
1898 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001899 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001900 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1901
1902 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001903 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1904 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1905 *
1906 * @see PackageManager#isPackageSuspended()
1907 * @see #ACTION_PACKAGES_SUSPENDED
1908 *
1909 * @hide
1910 */
1911 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1912
1913 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001914 * Activity action: Launch UI to manage which apps have a given permission.
1915 * <p>
Philip P. Moltmanned988282018-11-07 16:19:42 -08001916 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
1917 * which will be managed by the launched UI.
Svet Ganov3695b8a2015-03-24 16:30:25 -07001918 * </p>
1919 * <p>
1920 * Output: Nothing.
1921 * </p>
1922 *
1923 * @see #EXTRA_PERMISSION_NAME
1924 *
1925 * @hide
1926 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001927 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001928 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1929 public static final String ACTION_MANAGE_PERMISSION_APPS =
1930 "android.intent.action.MANAGE_PERMISSION_APPS";
1931
1932 /**
1933 * Intent extra: The name of a permission.
1934 * <p>
1935 * Type: String
1936 * </p>
1937 *
1938 * @hide
1939 */
1940 @SystemApi
1941 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1942
Joel Galenson13096ea2018-09-27 11:18:44 -07001943 /**
1944 * Activity action: Launch UI to review app uses of permissions.
1945 * <p>
1946 * Input: Nothing
1947 * </p>
1948 * <p>
1949 * Output: Nothing.
1950 * </p>
1951 *
1952 * @hide
1953 */
1954 @SystemApi
1955 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1956 public static final String ACTION_REVIEW_PERMISSION_USAGE =
1957 "android.intent.action.REVIEW_PERMISSION_USAGE";
1958
Joel Galenson78ec58d2018-10-24 10:06:25 -07001959 /**
1960 * Activity action: Launch UI to review uses of permissions for a single app.
1961 * <p>
1962 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1963 * permissions will be reviewed (mandatory).
1964 * </p>
1965 * <p>
1966 * Output: Nothing.
1967 * </p>
1968 * <p class="note">
1969 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
1970 * </p>
1971 *
1972 * @see #EXTRA_PACKAGE_NAME
1973 *
1974 * @hide
1975 */
1976 @SystemApi
1977 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1978 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1979 public static final String ACTION_REVIEW_APP_PERMISSION_USAGE =
1980 "android.intent.action.REVIEW_APP_PERMISSION_USAGE";
1981
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001982 // ---------------------------------------------------------------------
1983 // ---------------------------------------------------------------------
1984 // Standard intent broadcast actions (see action variable).
1985
1986 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001987 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1988 * <p>
1989 * For historical reasons, the name of this broadcast action refers to the power
1990 * state of the screen but it is actually sent in response to changes in the
1991 * overall interactive state of the device.
1992 * </p><p>
1993 * This broadcast is sent when the device becomes non-interactive which may have
1994 * nothing to do with the screen turning off. To determine the
1995 * actual state of the screen, use {@link android.view.Display#getState}.
1996 * </p><p>
1997 * See {@link android.os.PowerManager#isInteractive} for details.
1998 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001999 * You <em>cannot</em> receive this through components declared in
2000 * manifests, only by explicitly registering for it with
2001 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2002 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002003 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002004 * <p class="note">This is a protected intent that can only be sent
2005 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002006 */
2007 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2008 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07002009
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002010 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07002011 * Broadcast Action: Sent when the device wakes up and becomes interactive.
2012 * <p>
2013 * For historical reasons, the name of this broadcast action refers to the power
2014 * state of the screen but it is actually sent in response to changes in the
2015 * overall interactive state of the device.
2016 * </p><p>
2017 * This broadcast is sent when the device becomes interactive which may have
2018 * nothing to do with the screen turning on. To determine the
2019 * actual state of the screen, use {@link android.view.Display#getState}.
2020 * </p><p>
2021 * See {@link android.os.PowerManager#isInteractive} for details.
2022 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07002023 * You <em>cannot</em> receive this through components declared in
2024 * manifests, only by explicitly registering for it with
2025 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2026 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002027 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002028 * <p class="note">This is a protected intent that can only be sent
2029 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002030 */
2031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2032 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002033
2034 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07002035 * Broadcast Action: Sent after the system stops dreaming.
2036 *
2037 * <p class="note">This is a protected intent that can only be sent by the system.
2038 * It is only sent to registered receivers.</p>
2039 */
2040 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2041 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2042
2043 /**
2044 * Broadcast Action: Sent after the system starts dreaming.
2045 *
2046 * <p class="note">This is a protected intent that can only be sent by the system.
2047 * It is only sent to registered receivers.</p>
2048 */
2049 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2050 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2051
2052 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07002053 * 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 -07002054 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08002055 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002056 * <p class="note">This is a protected intent that can only be sent
2057 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002058 */
2059 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002060 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002061
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002062 /**
2063 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07002064 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04002065 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002066 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2067 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002068 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002069 * <p class="note">This is a protected intent that can only be sent
2070 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002071 */
2072 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2073 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2074 /**
2075 * Broadcast Action: The time was set.
2076 */
2077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2078 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2079 /**
2080 * Broadcast Action: The date has changed.
2081 */
2082 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2083 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2084 /**
2085 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2086 * <ul>
2087 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2088 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002089 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002090 * <p class="note">This is a protected intent that can only be sent
2091 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002092 */
2093 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2094 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2095 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002096 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2097 * DNS entries should be tossed.
2098 * @hide
2099 */
2100 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2101 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2102 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002103 * Alarm Changed Action: This is broadcast when the AlarmClock
2104 * application's alarm is set or unset. It is used by the
2105 * AlarmClock application and the StatusBar service.
2106 * @hide
2107 */
2108 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002109 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002110 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002111
2112 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002113 * Broadcast Action: This is broadcast once, after the user has finished
2114 * booting, but while still in the "locked" state. It can be used to perform
2115 * application-specific initialization, such as installing alarms. You must
2116 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2117 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002118 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002119 * This broadcast is sent immediately at boot by all devices (regardless of
2120 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2121 * higher. Upon receipt of this broadcast, the user is still locked and only
2122 * device-protected storage can be accessed safely. If you want to access
2123 * credential-protected storage, you need to wait for the user to be
2124 * unlocked (typically by entering their lock pattern or PIN for the first
2125 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2126 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2127 * <p>
2128 * To receive this broadcast, your receiver component must be marked as
2129 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002130 * <p class="note">
2131 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002132 *
2133 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002134 */
2135 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2136 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2137
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002138 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002139 * Broadcast Action: This is broadcast once, after the user has finished
2140 * booting. It can be used to perform application-specific initialization,
2141 * such as installing alarms. You must hold the
2142 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2143 * order to receive this broadcast.
2144 * <p>
2145 * This broadcast is sent at boot by all devices (both with and without
2146 * direct boot support). Upon receipt of this broadcast, the user is
2147 * unlocked and both device-protected and credential-protected storage can
2148 * accessed safely.
2149 * <p>
2150 * If you need to run while the user is still locked (before they've entered
2151 * their lock pattern or PIN for the first time), you can listen for the
2152 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2153 * <p class="note">
2154 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002157 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002158 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002159
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002160 /**
2161 * Broadcast Action: This is broadcast when a user action should request a
2162 * temporary system dialog to dismiss. Some examples of temporary system
2163 * dialogs are the notification window-shade and the recent tasks dialog.
2164 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002165 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002166 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2167 /**
2168 * Broadcast Action: Trigger the download and eventual installation
2169 * of a package.
2170 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002171 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002172 * <p class="note">This is a protected intent that can only be sent
2173 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002174 *
2175 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002176 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002177 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002178 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2179 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2180 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002181 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002182 * device. The data contains the name of the package. Note that the
2183 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002184 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002185 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002186 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2187 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002188 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2189 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002190 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002191 * <p class="note">This is a protected intent that can only be sent
2192 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002193 */
2194 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2195 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2196 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002197 * Broadcast Action: A new version of an application package has been
2198 * installed, replacing an existing version that was previously installed.
2199 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002200 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002201 * <ul>
2202 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2203 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002204 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002205 * <p class="note">This is a protected intent that can only be sent
2206 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002207 */
2208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2209 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2210 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002211 * Broadcast Action: A new version of your application has been installed
2212 * over an existing one. This is only sent to the application that was
2213 * replaced. It does not contain any additional data; to receive it, just
2214 * use an intent filter for this action.
2215 *
2216 * <p class="note">This is a protected intent that can only be sent
2217 * by the system.
2218 */
2219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2220 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2221 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002222 * Broadcast Action: An existing application package has been removed from
2223 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002224 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002225 * <ul>
2226 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2227 * to the package.
2228 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2229 * application -- data and code -- is being removed.
2230 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2231 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2232 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002233 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002234 * <p class="note">This is a protected intent that can only be sent
2235 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002236 */
2237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2238 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2239 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002240 * Broadcast Action: An existing application package has been completely
2241 * removed from the device. The data contains the name of the package.
2242 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2243 * {@link #EXTRA_DATA_REMOVED} is true and
2244 * {@link #EXTRA_REPLACING} is false of that broadcast.
2245 *
2246 * <ul>
2247 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2248 * to the package.
2249 * </ul>
2250 *
2251 * <p class="note">This is a protected intent that can only be sent
2252 * by the system.
2253 */
2254 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2255 public static final String ACTION_PACKAGE_FULLY_REMOVED
2256 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2257 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002258 * Broadcast Action: An existing application package has been changed (for
2259 * example, a component has been enabled or disabled). The data contains
2260 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002261 * <ul>
2262 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002263 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002264 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002265 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2266 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002267 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002268 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002269 * <p class="note">This is a protected intent that can only be sent
2270 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002271 */
2272 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2273 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2274 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002275 * @hide
2276 * Broadcast Action: Ask system services if there is any reason to
2277 * restart the given package. The data contains the name of the
2278 * package.
2279 * <ul>
2280 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2281 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2282 * </ul>
2283 *
2284 * <p class="note">This is a protected intent that can only be sent
2285 * by the system.
2286 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002287 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002288 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2289 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2290 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002291 * Broadcast Action: The user has restarted a package, and all of its
2292 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002293 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002294 * be removed. Note that the restarted package does <em>not</em>
2295 * receive this broadcast.
2296 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002297 * <ul>
2298 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2299 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002300 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002301 * <p class="note">This is a protected intent that can only be sent
2302 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002303 */
2304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2305 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2306 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002307 * Broadcast Action: The user has cleared the data of a package. This should
2308 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002309 * its persistent data is erased and this broadcast sent.
2310 * Note that the cleared package does <em>not</em>
2311 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002312 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002313 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2314 * package whose data was cleared is an uninstalled instant app, then the UID
2315 * will be -1. The platform keeps some meta-data associated with instant apps
2316 * after they are uninstalled.
2317 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2318 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002319 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002320 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002321 * <p class="note">This is a protected intent that can only be sent
2322 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002323 */
2324 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2325 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2326 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002327 * Broadcast Action: Packages have been suspended.
2328 * <p>Includes the following extras:
2329 * <ul>
2330 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002331 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002332 * </ul>
2333 *
2334 * <p class="note">This is a protected intent that can only be sent
2335 * by the system. It is only sent to registered receivers.
2336 */
2337 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2338 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2339 /**
2340 * Broadcast Action: Packages have been unsuspended.
2341 * <p>Includes the following extras:
2342 * <ul>
2343 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002344 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002345 * </ul>
2346 *
2347 * <p class="note">This is a protected intent that can only be sent
2348 * by the system. It is only sent to registered receivers.
2349 */
2350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2351 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002352
2353 /**
2354 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002355 * whenever a package is put into a suspended state or any of its app extras change while in the
2356 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002357 * <p> Optionally includes the following extras:
2358 * <ul>
2359 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2360 * useful information for the app being suspended.
2361 * </ul>
2362 * <p class="note">This is a protected intent that can only be sent
2363 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2364 * the manifest.</em>
2365 *
2366 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2367 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2368 * @see PackageManager#isPackageSuspended()
2369 * @see PackageManager#getSuspendedPackageAppExtras()
2370 */
2371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2372 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2373
2374 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002375 * Activity Action: Started to show more details about why an application was suspended.
2376 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002377 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2378 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002379 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002380 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2381 * handling this intent and protect it with
2382 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2383 *
2384 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2385 *
2386 * <p class="note">This is a protected intent that can only be sent
2387 * by the system.
2388 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002389 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2390 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002391 * @see PackageManager#isPackageSuspended()
2392 * @see #ACTION_PACKAGES_SUSPENDED
2393 *
2394 * @hide
2395 */
2396 @SystemApi
2397 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2398 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2399 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2400
2401 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002402 * Broadcast Action: Sent to a package that has been unsuspended.
2403 *
2404 * <p class="note">This is a protected intent that can only be sent
2405 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2406 * the manifest.</em>
2407 *
2408 * @see #ACTION_MY_PACKAGE_SUSPENDED
2409 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2410 * @see PackageManager#isPackageSuspended()
2411 * @see PackageManager#getSuspendedPackageAppExtras()
2412 */
2413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2414 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2415
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002416 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002417 * Broadcast Action: A user ID has been removed from the system. The user
2418 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002419 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002420 * <p class="note">This is a protected intent that can only be sent
2421 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002422 */
2423 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2424 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002425
2426 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002427 * Broadcast Action: Sent to the installer package of an application when
2428 * that application is first launched (that is the first time it is moved
2429 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002430 *
2431 * <p class="note">This is a protected intent that can only be sent
2432 * by the system.
2433 */
2434 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2435 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2436
2437 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002438 * Broadcast Action: Sent to the system package verifier when a package
2439 * needs to be verified. The data contains the package URI.
2440 * <p class="note">
2441 * This is a protected intent that can only be sent by the system.
2442 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002443 */
2444 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2445 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2446
2447 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002448 * Broadcast Action: Sent to the system package verifier when a package is
2449 * verified. The data contains the package URI.
2450 * <p class="note">
2451 * This is a protected intent that can only be sent by the system.
2452 */
2453 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2454 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2455
2456 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002457 * Broadcast Action: Sent to the system intent filter verifier when an
2458 * intent filter needs to be verified. The data contains the filter data
2459 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002460 * <p class="note">
2461 * This is a protected intent that can only be sent by the system.
2462 * </p>
2463 *
2464 * @hide
2465 */
2466 @SystemApi
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2468 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2469
2470 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002471 * Broadcast Action: Resources for a set of packages (which were
2472 * previously unavailable) are currently
2473 * available since the media on which they exist is available.
2474 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2475 * list of packages whose availability changed.
2476 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2477 * list of uids of packages whose availability changed.
2478 * Note that the
2479 * packages in this list do <em>not</em> receive this broadcast.
2480 * The specified set of packages are now available on the system.
2481 * <p>Includes the following extras:
2482 * <ul>
2483 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2484 * whose resources(were previously unavailable) are currently available.
2485 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2486 * packages whose resources(were previously unavailable)
2487 * are currently available.
2488 * </ul>
2489 *
2490 * <p class="note">This is a protected intent that can only be sent
2491 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002492 */
2493 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002494 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2495 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002496
2497 /**
2498 * Broadcast Action: Resources for a set of packages are currently
2499 * unavailable since the media on which they exist is unavailable.
2500 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2501 * list of packages whose availability changed.
2502 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2503 * list of uids of packages whose availability changed.
2504 * The specified set of packages can no longer be
2505 * launched and are practically unavailable on the system.
2506 * <p>Inclues the following extras:
2507 * <ul>
2508 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2509 * whose resources are no longer available.
2510 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2511 * whose resources are no longer available.
2512 * </ul>
2513 *
2514 * <p class="note">This is a protected intent that can only be sent
2515 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002516 */
2517 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002518 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002519 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002520
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002521 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002522 * Broadcast Action: preferred activities have changed *explicitly*.
2523 *
2524 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2525 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2526 * be sent.
2527 *
2528 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2529 *
2530 * @hide
2531 */
2532 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2533 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2534 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2535
2536
2537 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002538 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002539 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002540 * This should <em>only</em> be used to determine when the wallpaper
2541 * has changed to show the new wallpaper to the user. You should certainly
2542 * never, in response to this, change the wallpaper or other attributes of
2543 * it such as the suggested size. That would be crazy, right? You'd cause
2544 * all kinds of loops, especially if other apps are doing similar things,
2545 * right? Of course. So please don't do this.
2546 *
2547 * @deprecated Modern applications should use
2548 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2549 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2550 * shown behind their UI, rather than watching for this broadcast and
2551 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002552 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002553 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002554 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2555 /**
2556 * Broadcast Action: The current device {@link android.content.res.Configuration}
2557 * (orientation, locale, etc) has changed. When such a change happens, the
2558 * UIs (view hierarchy) will need to be rebuilt based on this new
2559 * information; for the most part, applications don't need to worry about
2560 * this, because the system will take care of stopping and restarting the
2561 * application to make sure it sees the new changes. Some system code that
2562 * can not be restarted will need to watch for this action and handle it
2563 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002564 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002565 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002566 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002567 * in manifests, only by explicitly registering for it with
2568 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2569 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002570 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002571 * <p class="note">This is a protected intent that can only be sent
2572 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002573 *
2574 * @see android.content.res.Configuration
2575 */
2576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2577 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002578
2579 /**
2580 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2581 * such that the device may be eligible for the installation of additional configuration splits.
2582 * Configuration properties that can trigger this broadcast include locale and display density.
2583 *
2584 * <p class="note">
2585 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2586 * components declared in manifests. However, the receiver <em>must</em> hold the
2587 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2588 *
2589 * <p class="note">
2590 * This is a protected intent that can only be sent by the system.
2591 *
2592 * @hide
2593 */
2594 @SystemApi
2595 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2596 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2597 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002598 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002599 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002600 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002601 * <p class="note">This is a protected intent that can only be sent
2602 * by the system.
2603 */
2604 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2605 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2606 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002607 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2608 * charging state, level, and other information about the battery.
2609 * See {@link android.os.BatteryManager} for documentation on the
2610 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002611 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002612 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002613 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002614 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002615 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002616 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2617 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2618 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2619 * broadcasts that are sent and can be received through manifest
2620 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002621 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002622 * <p class="note">This is a protected intent that can only be sent
2623 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002624 */
2625 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2626 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002627
2628
2629 /**
2630 * Broadcast Action: Sent when the current battery level changes.
2631 *
2632 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2633 * instances representing individual battery level changes with associated
2634 * extras from {@link #ACTION_BATTERY_CHANGED}.
2635 *
2636 * <p class="note">
2637 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2638 *
2639 * @hide
2640 */
2641 @SystemApi
2642 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2643 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002644 /**
2645 * Broadcast Action: Indicates low battery condition on the device.
2646 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002647 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002648 * <p class="note">This is a protected intent that can only be sent
2649 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002650 */
2651 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2652 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2653 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002654 * Broadcast Action: Indicates the battery is now okay after being low.
2655 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2656 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002657 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002658 * <p class="note">This is a protected intent that can only be sent
2659 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002660 */
2661 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2662 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2663 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002664 * Broadcast Action: External power has been connected to the device.
2665 * This is intended for applications that wish to register specifically to this notification.
2666 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2667 * stay active to receive this notification. This action can be used to implement actions
2668 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002669 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002670 * <p class="note">This is a protected intent that can only be sent
2671 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002672 */
2673 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002674 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002675 /**
2676 * Broadcast Action: External power has been removed from the device.
2677 * This is intended for applications that wish to register specifically to this notification.
2678 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2679 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002680 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002681 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002682 * <p class="note">This is a protected intent that can only be sent
2683 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002684 */
2685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002686 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002687 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002688 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002689 * Broadcast Action: Device is shutting down.
2690 * This is broadcast when the device is being shut down (completely turned
2691 * off, not sleeping). Once the broadcast is complete, the final shutdown
2692 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002693 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002694 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2695 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2696 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002697 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002698 * <p class="note">This is a protected intent that can only be sent
2699 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002700 * <p>May include the following extras:
2701 * <ul>
2702 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2703 * shutdown is only for userspace processes. If not set, assumed to be false.
2704 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002705 */
2706 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002707 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002708 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002709 * Activity Action: Start this activity to request system shutdown.
2710 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002711 * to request confirmation from the user before shutting down. The optional boolean
2712 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2713 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002714 *
2715 * <p class="note">This is a protected intent that can only be sent
2716 * by the system.
2717 *
2718 * {@hide}
2719 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002720 public static final String ACTION_REQUEST_SHUTDOWN
2721 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002722 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002723 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002724 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002725 * <p class="note">
2726 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002727 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002728 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2729 * or above, this broadcast will no longer be delivered to any
2730 * {@link BroadcastReceiver} defined in your manifest. Instead,
2731 * apps are strongly encouraged to use the improved
2732 * {@link Context#getCacheDir()} behavior so the system can
2733 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002734 */
2735 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002736 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002737 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2738 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002739 * Broadcast Action: Indicates low storage space condition on the device no
2740 * longer exists
2741 * <p class="note">
2742 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002743 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002744 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2745 * or above, this broadcast will no longer be delivered to any
2746 * {@link BroadcastReceiver} defined in your manifest. Instead,
2747 * apps are strongly encouraged to use the improved
2748 * {@link Context#getCacheDir()} behavior so the system can
2749 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002750 */
2751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002752 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002753 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2754 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002755 * Broadcast Action: A sticky broadcast that indicates a storage space full
2756 * condition on the device. This is intended for activities that want to be
2757 * able to fill the data partition completely, leaving only enough free
2758 * space to prevent system-wide SQLite failures.
2759 * <p class="note">
2760 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002761 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002762 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2763 * or above, this broadcast will no longer be delivered to any
2764 * {@link BroadcastReceiver} defined in your manifest. Instead,
2765 * apps are strongly encouraged to use the improved
2766 * {@link Context#getCacheDir()} behavior so the system can
2767 * automatically free up storage when needed.
2768 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002769 */
2770 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002771 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002772 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2773 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002774 * Broadcast Action: Indicates storage space full condition on the device no
2775 * longer exists.
2776 * <p class="note">
2777 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002778 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002779 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2780 * or above, this broadcast will no longer be delivered to any
2781 * {@link BroadcastReceiver} defined in your manifest. Instead,
2782 * apps are strongly encouraged to use the improved
2783 * {@link Context#getCacheDir()} behavior so the system can
2784 * automatically free up storage when needed.
2785 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002786 */
2787 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002788 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002789 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2790 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002791 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2792 * and package management should be started.
2793 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2794 * notification.
2795 */
2796 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2797 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2798 /**
2799 * Broadcast Action: The device has entered USB Mass Storage mode.
2800 * This is used mainly for the USB Settings panel.
2801 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2802 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002803 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002804 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002805 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002806 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002807 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2808
2809 /**
2810 * Broadcast Action: The device has exited USB Mass Storage mode.
2811 * This is used mainly for the USB Settings panel.
2812 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2813 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002814 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002815 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002816 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002817 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002818 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2819
2820 /**
2821 * Broadcast Action: External media has been removed.
2822 * The path to the mount point for the removed media is contained in the Intent.mData field.
2823 */
2824 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2825 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2826
2827 /**
2828 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002829 * 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 -07002830 */
2831 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2832 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2833
2834 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002835 * Broadcast Action: External media is present, and being disk-checked
2836 * 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 -08002837 */
2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2839 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2840
2841 /**
2842 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2843 * 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 -08002844 */
2845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2846 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2847
2848 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002849 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002850 * 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 -07002851 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2852 * media was mounted read only.
2853 */
2854 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2855 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2856
2857 /**
2858 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002859 * 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 -07002860 */
2861 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2862 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2863
2864 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002865 * Broadcast Action: External media is no longer being shared via USB mass storage.
2866 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2867 *
2868 * @hide
2869 */
2870 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2871
2872 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2874 * The path to the mount point for the removed media is contained in the Intent.mData field.
2875 */
2876 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2877 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2878
2879 /**
2880 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002881 * 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 -07002882 */
2883 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2884 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2885
2886 /**
2887 * Broadcast Action: User has expressed the desire to remove the external storage media.
2888 * Applications should close all files they have open within the mount point when they receive this intent.
2889 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2890 */
2891 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2892 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2893
2894 /**
2895 * Broadcast Action: The media scanner has started scanning a directory.
2896 * The path to the directory being scanned is contained in the Intent.mData field.
2897 */
2898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2899 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2900
2901 /**
2902 * Broadcast Action: The media scanner has finished scanning a directory.
2903 * The path to the scanned directory is contained in the Intent.mData field.
2904 */
2905 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2906 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2907
2908 /**
2909 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2910 * The path to the file is contained in the Intent.mData field.
2911 */
2912 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2913 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2914
2915 /**
2916 * Broadcast Action: The "Media Button" was pressed. Includes a single
2917 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2918 * caused the broadcast.
2919 */
2920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2921 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2922
2923 /**
2924 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2925 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2926 * caused the broadcast.
2927 */
2928 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2929 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2930
2931 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2932 // location; they are not general-purpose actions.
2933
2934 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002935 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002936 */
2937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2938 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2939 "android.intent.action.GTALK_CONNECTED";
2940
2941 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002942 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002943 */
2944 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2945 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2946 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002947
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002948 /**
2949 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002950 */
2951 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2952 public static final String ACTION_INPUT_METHOD_CHANGED =
2953 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002954
2955 /**
2956 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2957 * more radios have been turned off or on. The intent will have the following extra value:</p>
2958 * <ul>
2959 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2960 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2961 * turned off</li>
2962 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002963 *
Peng Xua35b5532016-01-20 00:05:45 -08002964 * <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 -07002965 */
2966 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2967 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2968
2969 /**
2970 * Broadcast Action: Some content providers have parts of their namespace
2971 * where they publish new events or items that the user may be especially
2972 * interested in. For these things, they may broadcast this action when the
2973 * set of interesting items change.
2974 *
2975 * For example, GmailProvider sends this notification when the set of unread
2976 * mail in the inbox changes.
2977 *
2978 * <p>The data of the intent identifies which part of which provider
2979 * changed. When queried through the content resolver, the data URI will
2980 * return the data set in question.
2981 *
2982 * <p>The intent will have the following extra values:
2983 * <ul>
2984 * <li><em>count</em> - The number of items in the data set. This is the
2985 * same as the number of items in the cursor returned by querying the
2986 * data URI. </li>
2987 * </ul>
2988 *
2989 * This intent will be sent at boot (if the count is non-zero) and when the
2990 * data set changes. It is possible for the data set to change without the
2991 * count changing (for example, if a new unread message arrives in the same
2992 * sync operation in which a message is archived). The phone should still
2993 * ring/vibrate/etc as normal in this case.
2994 */
2995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2996 public static final String ACTION_PROVIDER_CHANGED =
2997 "android.intent.action.PROVIDER_CHANGED";
2998
2999 /**
3000 * Broadcast Action: Wired Headset plugged in or unplugged.
3001 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003002 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3003 * and documentation.
3004 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07003005 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003006 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003007 */
3008 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003009 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07003010
3011 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07003012 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3013 * <ul>
3014 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3015 * </ul>
3016 *
3017 * <p class="note">This is a protected intent that can only be sent
3018 * by the system.
3019 *
3020 * @hide
3021 */
3022 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3023 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3024 = "android.intent.action.ADVANCED_SETTINGS";
3025
3026 /**
Robin Lee66e5d962014-04-09 16:44:21 +01003027 * Broadcast Action: Sent after application restrictions are changed.
3028 *
3029 * <p class="note">This is a protected intent that can only be sent
3030 * by the system.</p>
3031 */
3032 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3033 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3034 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3035
3036 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003037 * Broadcast Action: An outgoing call is about to be placed.
3038 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07003039 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003040 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07003041 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003042 * the phone number originally intended to be dialed.</li>
3043 * </ul>
3044 * <p>Once the broadcast is finished, the resultData is used as the actual
3045 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07003046 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003047 * outgoing call in turn: for example, a parental control application
3048 * might verify that the user is authorized to place the call at that
3049 * time, then a number-rewriting application might add an area code if
3050 * one was not specified.</p>
3051 * <p>For consistency, any receiver whose purpose is to prohibit phone
3052 * calls should have a priority of 0, to ensure it will see the final
3053 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07003054 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003055 * should have a positive priority.
3056 * Negative priorities are reserved for the system for this broadcast;
3057 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07003058 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3059 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003060 * <p>Emergency calls cannot be intercepted using this mechanism, and
3061 * other calls cannot be modified to call emergency numbers using this
3062 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07003063 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3064 * call to use their own service instead. Those apps should first prevent
3065 * the call from being placed by setting resultData to <code>null</code>
3066 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07003067 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003068 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3069 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08003070 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003071 * <p class="note">This is a protected intent that can only be sent
3072 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003073 */
3074 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3075 public static final String ACTION_NEW_OUTGOING_CALL =
3076 "android.intent.action.NEW_OUTGOING_CALL";
3077
3078 /**
3079 * Broadcast Action: Have the device reboot. This is only for use by
3080 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003081 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003082 * <p class="note">This is a protected intent that can only be sent
3083 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003084 */
3085 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3086 public static final String ACTION_REBOOT =
3087 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003088
Wei Huang97ecc9c2009-05-11 17:44:20 -07003089 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003090 * Broadcast Action: A sticky broadcast for changes in the physical
3091 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003092 *
3093 * <p>The intent will have the following extra values:
3094 * <ul>
3095 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003096 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003097 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003098 * <p>This is intended for monitoring the current physical dock state.
3099 * See {@link android.app.UiModeManager} for the normal API dealing with
3100 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003101 */
3102 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3103 public static final String ACTION_DOCK_EVENT =
3104 "android.intent.action.DOCK_EVENT";
3105
3106 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003107 * Broadcast Action: A broadcast when idle maintenance can be started.
3108 * This means that the user is not interacting with the device and is
3109 * not expected to do so soon. Typical use of the idle maintenance is
3110 * to perform somehow expensive tasks that can be postponed at a moment
3111 * when they will not degrade user experience.
3112 * <p>
3113 * <p class="note">In order to keep the device responsive in case of an
3114 * unexpected user interaction, implementations of a maintenance task
3115 * should be interruptible. In such a scenario a broadcast with action
3116 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3117 * should not do the maintenance work in
3118 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3119 * maintenance service by {@link Context#startService(Intent)}. Also
3120 * you should hold a wake lock while your maintenance service is running
3121 * to prevent the device going to sleep.
3122 * </p>
3123 * <p>
3124 * <p class="note">This is a protected intent that can only be sent by
3125 * the system.
3126 * </p>
3127 *
3128 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003129 *
3130 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003131 */
3132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3133 public static final String ACTION_IDLE_MAINTENANCE_START =
3134 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3135
3136 /**
3137 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3138 * This means that the user was not interacting with the device as a result
3139 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3140 * was sent and now the user started interacting with the device. Typical
3141 * use of the idle maintenance is to perform somehow expensive tasks that
3142 * can be postponed at a moment when they will not degrade user experience.
3143 * <p>
3144 * <p class="note">In order to keep the device responsive in case of an
3145 * unexpected user interaction, implementations of a maintenance task
3146 * should be interruptible. Hence, on receiving a broadcast with this
3147 * action, the maintenance task should be interrupted as soon as possible.
3148 * In other words, you should not do the maintenance work in
3149 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3150 * maintenance service that was started on receiving of
3151 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3152 * lock you acquired when your maintenance service started.
3153 * </p>
3154 * <p class="note">This is a protected intent that can only be sent
3155 * by the system.
3156 *
3157 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003158 *
3159 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003160 */
3161 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3162 public static final String ACTION_IDLE_MAINTENANCE_END =
3163 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3164
3165 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003166 * Broadcast Action: a remote intent is to be broadcasted.
3167 *
3168 * A remote intent is used for remote RPC between devices. The remote intent
3169 * is serialized and sent from one device to another device. The receiving
3170 * device parses the remote intent and broadcasts it. Note that anyone can
3171 * broadcast a remote intent. However, if the intent receiver of the remote intent
3172 * does not trust intent broadcasts from arbitrary intent senders, it should require
3173 * the sender to hold certain permissions so only trusted sender's broadcast will be
3174 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003175 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003176 */
3177 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003178 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003179
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003180 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003181 * Broadcast Action: This is broadcast once when the user is booting after a
3182 * system update. It can be used to perform cleanup or upgrades after a
3183 * system update.
3184 * <p>
3185 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3186 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3187 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3188 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003189 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003190 * @hide
3191 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003192 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003193 public static final String ACTION_PRE_BOOT_COMPLETED =
3194 "android.intent.action.PRE_BOOT_COMPLETED";
3195
Amith Yamasani13593602012-03-22 16:16:17 -07003196 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003197 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003198 * on restricted users. The broadcast intent contains an extra
3199 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3200 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3201 * String[] depending on the restriction type.<p/>
3202 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003203 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3204 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3205 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003206 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3207 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003208 * @see RestrictionEntry
3209 */
3210 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3211 "android.intent.action.GET_RESTRICTION_ENTRIES";
3212
3213 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003214 * Sent the first time a user is starting, to allow system apps to
3215 * perform one time initialization. (This will not be seen by third
3216 * party applications because a newly initialized user does not have any
3217 * third party applications installed for it.) This is sent early in
3218 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003219 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3220 * broadcast, since it is part of a visible user interaction; be as quick
3221 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003222 */
3223 public static final String ACTION_USER_INITIALIZE =
3224 "android.intent.action.USER_INITIALIZE";
3225
3226 /**
3227 * Sent when a user switch is happening, causing the process's user to be
3228 * brought to the foreground. This is only sent to receivers registered
3229 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3230 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003231 * foreground. This is sent as a foreground
3232 * broadcast, since it is part of a visible user interaction; be as quick
3233 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003234 */
3235 public static final String ACTION_USER_FOREGROUND =
3236 "android.intent.action.USER_FOREGROUND";
3237
3238 /**
3239 * Sent when a user switch is happening, causing the process's user to be
3240 * sent to the background. This is only sent to receivers registered
3241 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3242 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003243 * background. This is sent as a foreground
3244 * broadcast, since it is part of a visible user interaction; be as quick
3245 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003246 */
3247 public static final String ACTION_USER_BACKGROUND =
3248 "android.intent.action.USER_BACKGROUND";
3249
3250 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003251 * Broadcast sent to the system when a user is added. Carries an extra
3252 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3253 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003254 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003255 * @hide
3256 */
3257 public static final String ACTION_USER_ADDED =
3258 "android.intent.action.USER_ADDED";
3259
3260 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003261 * Broadcast sent by the system when a user is started. Carries an extra
3262 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003263 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003264 * that has been started. This is sent as a foreground
3265 * broadcast, since it is part of a visible user interaction; be as quick
3266 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003267 * @hide
3268 */
3269 public static final String ACTION_USER_STARTED =
3270 "android.intent.action.USER_STARTED";
3271
3272 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003273 * Broadcast sent when a user is in the process of starting. Carries an extra
3274 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3275 * sent to registered receivers, not manifest receivers. It is sent to all
3276 * users (including the one that is being started). You must hold
3277 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3278 * this broadcast. This is sent as a background broadcast, since
3279 * its result is not part of the primary UX flow; to safely keep track of
3280 * started/stopped state of a user you can use this in conjunction with
3281 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3282 * other user state broadcasts since those are foreground broadcasts so can
3283 * execute in a different order.
3284 * @hide
3285 */
3286 public static final String ACTION_USER_STARTING =
3287 "android.intent.action.USER_STARTING";
3288
3289 /**
3290 * Broadcast sent when a user is going to be stopped. Carries an extra
3291 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3292 * sent to registered receivers, not manifest receivers. It is sent to all
3293 * users (including the one that is being stopped). You must hold
3294 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3295 * this broadcast. The user will not stop until all receivers have
3296 * handled the broadcast. This is sent as a background broadcast, since
3297 * its result is not part of the primary UX flow; to safely keep track of
3298 * started/stopped state of a user you can use this in conjunction with
3299 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3300 * other user state broadcasts since those are foreground broadcasts so can
3301 * execute in a different order.
3302 * @hide
3303 */
3304 public static final String ACTION_USER_STOPPING =
3305 "android.intent.action.USER_STOPPING";
3306
3307 /**
3308 * Broadcast sent to the system when a user is stopped. Carries an extra
3309 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3310 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3311 * specific package. This is only sent to registered receivers, not manifest
3312 * receivers. It is sent to all running users <em>except</em> the one that
3313 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003314 * @hide
3315 */
3316 public static final String ACTION_USER_STOPPED =
3317 "android.intent.action.USER_STOPPED";
3318
3319 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003320 * 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 -07003321 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003322 * one that has been removed. The user will not be completely removed until all receivers have
3323 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003324 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003325 * @hide
3326 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003327 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003328 public static final String ACTION_USER_REMOVED =
3329 "android.intent.action.USER_REMOVED";
3330
3331 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003332 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003333 * the userHandle of the user to become the current one. This is only sent to
3334 * registered receivers, not manifest receivers. It is sent to all running users.
3335 * You must hold
3336 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003337 * @hide
3338 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003339 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003340 public static final String ACTION_USER_SWITCHED =
3341 "android.intent.action.USER_SWITCHED";
3342
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003343 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003344 * Broadcast Action: Sent when the credential-encrypted private storage has
3345 * become unlocked for the target user. This is only sent to registered
3346 * receivers, not manifest receivers.
3347 */
3348 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3349 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3350
3351 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003352 * Broadcast sent to the system when a user's information changes. Carries an extra
3353 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003354 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003355 * @hide
3356 */
3357 public static final String ACTION_USER_INFO_CHANGED =
3358 "android.intent.action.USER_INFO_CHANGED";
3359
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003360 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003361 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3362 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003363 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3364 * that need to display merged content across both primary and managed profiles need to
3365 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003366 * not manifest receivers.
3367 */
3368 public static final String ACTION_MANAGED_PROFILE_ADDED =
3369 "android.intent.action.MANAGED_PROFILE_ADDED";
3370
3371 /**
3372 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003373 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3374 * Only applications (for example Launchers) that need to display merged content across both
3375 * primary and managed profiles need to worry about this broadcast. This is only sent to
3376 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003377 */
3378 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3379 "android.intent.action.MANAGED_PROFILE_REMOVED";
3380
3381 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003382 * Broadcast sent to the primary user when the credential-encrypted private storage for
3383 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3384 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3385 * Launchers) that need to display merged content across both primary and managed profiles
3386 * need to worry about this broadcast. This is only sent to registered receivers,
3387 * not manifest receivers.
3388 */
3389 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3390 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3391
3392 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003393 * Broadcast sent to the primary user when an associated managed profile has become available.
3394 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003395 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3396 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3397 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003398 */
Rubin Xue95057a2016-04-01 16:49:25 +01003399 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3400 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3401
3402 /**
3403 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3404 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3405 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3406 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3407 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3408 */
3409 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3410 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003411
3412 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003413 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3414 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3415 * the device was locked or unlocked.
3416 *
3417 * This is only sent to registered receivers.
3418 *
3419 * @hide
3420 */
3421 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3422 "android.intent.action.DEVICE_LOCKED_CHANGED";
3423
3424 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003425 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3426 */
3427 public static final String ACTION_QUICK_CLOCK =
3428 "android.intent.action.QUICK_CLOCK";
3429
Michael Wright0087a142013-02-05 16:29:39 -08003430 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003431 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003432 * @hide
3433 */
3434 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003435 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003436
Justin Kohd378ad72013-04-01 12:18:26 -07003437 /**
3438 * Broadcast Action: A global button was pressed. Includes a single
3439 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3440 * caused the broadcast.
3441 * @hide
3442 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003443 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003444 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3445
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003446 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003447 * Broadcast Action: Sent when media resource is granted.
3448 * <p>
3449 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3450 * granted.
3451 * </p>
3452 * <p class="note">
3453 * This is a protected intent that can only be sent by the system.
3454 * </p>
3455 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003456 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003457 * </p>
3458 *
3459 * @hide
3460 */
3461 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3462 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3463
3464 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003465 * Broadcast Action: An overlay package has changed. The data contains the
3466 * name of the overlay package which has changed. This is broadcast on all
3467 * changes to the OverlayInfo returned by {@link
3468 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3469 * most common change is a state change that will change whether the
3470 * overlay is enabled or not.
3471 * @hide
3472 */
3473 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3474
3475 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003476 * Activity Action: Allow the user to select and return one or more existing
3477 * documents. When invoked, the system will display the various
3478 * {@link DocumentsProvider} instances installed on the device, letting the
3479 * user interactively navigate through them. These documents include local
3480 * media, such as photos and video, and documents provided by installed
3481 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003482 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003483 * Each document is represented as a {@code content://} URI backed by a
3484 * {@link DocumentsProvider}, which can be opened as a stream with
3485 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3486 * {@link android.provider.DocumentsContract.Document} metadata.
3487 * <p>
3488 * All selected documents are returned to the calling application with
3489 * persistable read and write permission grants. If you want to maintain
3490 * access to the documents across device reboots, you need to explicitly
3491 * take the persistable permissions using
3492 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3493 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003494 * Callers must indicate the acceptable document MIME types through
3495 * {@link #setType(String)}. For example, to select photos, use
3496 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3497 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3498 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003499 * <p>
3500 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003501 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3502 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003503 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003504 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3505 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003506 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003507 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003508 * Callers can set a document URI through
3509 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3510 * location of documents navigator. System will do its best to launch the
3511 * navigator in the specified document if it's a folder, or the folder that
3512 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003513 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003514 * Output: The URI of the item that was picked, returned in
3515 * {@link #getData()}. This must be a {@code content://} URI so that any
3516 * receiver can access it. If multiple documents were selected, they are
3517 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003518 *
3519 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003520 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003521 * @see #ACTION_CREATE_DOCUMENT
3522 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003523 */
3524 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3525 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3526
3527 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003528 * Activity Action: Allow the user to create a new document. When invoked,
3529 * the system will display the various {@link DocumentsProvider} instances
3530 * installed on the device, letting the user navigate through them. The
3531 * returned document may be a newly created document with no content, or it
3532 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003533 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003534 * Each document is represented as a {@code content://} URI backed by a
3535 * {@link DocumentsProvider}, which can be opened as a stream with
3536 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3537 * {@link android.provider.DocumentsContract.Document} metadata.
3538 * <p>
3539 * Callers must indicate the concrete MIME type of the document being
3540 * created by setting {@link #setType(String)}. This MIME type cannot be
3541 * changed after the document is created.
3542 * <p>
3543 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3544 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003545 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003546 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3547 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003548 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003549 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003550 * Callers can set a document URI through
3551 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3552 * location of documents navigator. System will do its best to launch the
3553 * navigator in the specified document if it's a folder, or the folder that
3554 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003555 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003556 * Output: The URI of the item that was created. This must be a
3557 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003558 *
3559 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003560 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003561 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003562 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003563 */
3564 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3565 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3566
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003567 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003568 * Activity Action: Allow the user to pick a directory subtree. When
3569 * invoked, the system will display the various {@link DocumentsProvider}
3570 * instances installed on the device, letting the user navigate through
3571 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003572 * <p>
3573 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003574 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3575 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3576 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003577 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003578 * Callers can set a document URI through
3579 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3580 * location of documents navigator. System will do its best to launch the
3581 * navigator in the specified document if it's a folder, or the folder that
3582 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003583 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003584 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003585 *
3586 * @see DocumentsContract
3587 */
3588 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003589 public static final String
3590 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003591
Abodunrinwa Toki4bad09c2018-10-25 18:12:28 +01003592
3593 /**
3594 * Activity Action: Perform text translation.
3595 * <p>
3596 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
3597 * <p>
3598 * Output: nothing.
3599 */
3600 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3601 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
3602
Felipe Lemec7b1f892016-01-15 15:02:31 -08003603 /**
Peng Xua35b5532016-01-20 00:05:45 -08003604 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3605 * exisiting sensor being disconnected.
3606 *
3607 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3608 *
3609 * {@hide}
3610 */
3611 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3612 public static final String
3613 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3614
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003615 /**
Sam Line707f832017-04-13 17:00:55 -07003616 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003617 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003618 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003619 */
3620 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003621 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003622 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3623
Christopher Tate6597e342015-02-17 12:15:25 -08003624 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003625 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3626 * is about to be performed.
3627 * @hide
3628 */
3629 @SystemApi
3630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3631 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3632 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3633
3634 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003635 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3636 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3637 *
3638 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3639 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003640 * @hide
3641 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003642 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003643 public static final String EXTRA_FORCE_MASTER_CLEAR =
3644 "android.intent.extra.FORCE_MASTER_CLEAR";
3645
3646 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003647 * A broadcast action to trigger a factory reset.
3648 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003649 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3650 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003651 *
3652 * <p>Not for use by third-party applications.
3653 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003654 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003655 *
3656 * {@hide}
3657 */
3658 @SystemApi
3659 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3660 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3661
3662 /**
3663 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3664 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3665 *
3666 * <p>Not for use by third-party applications.
3667 *
3668 * @hide
3669 */
3670 @SystemApi
3671 public static final String EXTRA_FORCE_FACTORY_RESET =
3672 "android.intent.extra.FORCE_FACTORY_RESET";
3673
3674 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003675 * Broadcast action: report that a settings element is being restored from backup. The intent
3676 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3677 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3678 * is the value of that settings entry prior to the restore operation, and
3679 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3680 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3681 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003682 *
3683 * <p>This broadcast is sent only for settings provider entries known to require special handling
3684 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3685 * the provider's backup agent implementation.
3686 *
3687 * @see #EXTRA_SETTING_NAME
3688 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3689 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003690 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003691 * {@hide}
3692 */
3693 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3694
3695 /** {@hide} */
3696 public static final String EXTRA_SETTING_NAME = "setting_name";
3697 /** {@hide} */
3698 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3699 /** {@hide} */
3700 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003701 /** {@hide} */
3702 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003703
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003704 /**
3705 * Activity Action: Process a piece of text.
3706 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3707 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3708 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3709 */
3710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3711 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003712
3713 /**
3714 * Broadcast Action: The sim card state has changed.
3715 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3716 * because TelephonyIntents is an internal class.
3717 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003718 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3719 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003720 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003721 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003722 @SystemApi
3723 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3724 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3725
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003726 /**
fionaxu90fee272017-03-31 12:45:12 -07003727 * Broadcast Action: indicate that the phone service state has changed.
3728 * The intent will have the following extra values:</p>
3729 * <p>
3730 * @see #EXTRA_VOICE_REG_STATE
3731 * @see #EXTRA_DATA_REG_STATE
3732 * @see #EXTRA_VOICE_ROAMING_TYPE
3733 * @see #EXTRA_DATA_ROAMING_TYPE
3734 * @see #EXTRA_OPERATOR_ALPHA_LONG
3735 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3736 * @see #EXTRA_OPERATOR_NUMERIC
3737 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3738 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3739 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3740 * @see #EXTRA_MANUAL
3741 * @see #EXTRA_VOICE_RADIO_TECH
3742 * @see #EXTRA_DATA_RADIO_TECH
3743 * @see #EXTRA_CSS_INDICATOR
3744 * @see #EXTRA_NETWORK_ID
3745 * @see #EXTRA_SYSTEM_ID
3746 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3747 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3748 * @see #EXTRA_EMERGENCY_ONLY
3749 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3750 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3751 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3752 *
3753 * <p class="note">
3754 * Requires the READ_PHONE_STATE permission.
3755 *
3756 * <p class="note">This is a protected intent that can only be sent by the system.
3757 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003758 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003759 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3760 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3761 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3762 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003763 */
3764 @Deprecated
3765 @SystemApi
3766 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3767 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3768
3769 /**
3770 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3771 * state.
3772 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3773 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3774 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3775 * @see android.telephony.ServiceState#STATE_POWER_OFF
3776 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003777 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003778 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003779 */
3780 @Deprecated
3781 @SystemApi
3782 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3783
3784 /**
3785 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3786 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3787 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3788 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3789 * @see android.telephony.ServiceState#STATE_POWER_OFF
3790 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003791 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003792 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003793 */
3794 @Deprecated
3795 @SystemApi
3796 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3797
3798 /**
3799 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3800 * type.
3801 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003802 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003803 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003804 */
3805 @Deprecated
3806 @SystemApi
3807 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3808
3809 /**
3810 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3811 * type.
3812 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003813 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003814 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003815 */
3816 @Deprecated
3817 @SystemApi
3818 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3819
3820 /**
3821 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3822 * registered voice operator name in long alphanumeric format.
3823 * {@code null} if the operator name is not known or unregistered.
3824 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003825 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003826 * @deprecated Use
3827 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003828 */
3829 @Deprecated
3830 @SystemApi
3831 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3832
3833 /**
3834 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3835 * registered voice operator name in short alphanumeric format.
3836 * {@code null} if the operator name is not known or unregistered.
3837 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003838 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003839 * @deprecated Use
3840 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003841 */
3842 @Deprecated
3843 @SystemApi
3844 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3845
3846 /**
3847 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3848 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3849 * network.
3850 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003851 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003852 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003853 */
3854 @Deprecated
3855 @SystemApi
3856 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3857
3858 /**
3859 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3860 * registered data operator name in long alphanumeric format.
3861 * {@code null} if the operator name is not known or unregistered.
3862 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003863 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003864 * @deprecated Use
3865 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003866 */
3867 @Deprecated
3868 @SystemApi
3869 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3870
3871 /**
3872 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3873 * registered data operator name in short alphanumeric format.
3874 * {@code null} if the operator name is not known or unregistered.
3875 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003876 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003877 * @deprecated Use
3878 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003879 */
3880 @Deprecated
3881 @SystemApi
3882 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3883
3884 /**
3885 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3886 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3887 * data operator.
3888 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003889 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003890 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003891 */
3892 @Deprecated
3893 @SystemApi
3894 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3895
3896 /**
3897 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3898 * network selection mode is manual.
3899 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3900 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003901 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003902 * @deprecated Use
3903 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07003904 */
3905 @Deprecated
3906 @SystemApi
3907 public static final String EXTRA_MANUAL = "manual";
3908
3909 /**
3910 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3911 * radio technology.
3912 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003913 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003914 * @deprecated Use
3915 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003916 */
3917 @Deprecated
3918 @SystemApi
3919 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3920
3921 /**
3922 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3923 * radio technology.
3924 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003925 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003926 * @deprecated Use
3927 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003928 */
3929 @Deprecated
3930 @SystemApi
3931 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3932
3933 /**
3934 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3935 * support on CDMA network.
3936 * Will be {@code true} if support, {@code false} otherwise.
3937 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003938 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003939 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003940 */
3941 @Deprecated
3942 @SystemApi
3943 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3944
3945 /**
3946 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3947 * id. {@code Integer.MAX_VALUE} if unknown.
3948 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003949 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003950 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003951 */
3952 @Deprecated
3953 @SystemApi
3954 public static final String EXTRA_NETWORK_ID = "networkId";
3955
3956 /**
3957 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3958 * {@code Integer.MAX_VALUE} if unknown.
3959 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003960 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003961 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003962 */
3963 @Deprecated
3964 @SystemApi
3965 public static final String EXTRA_SYSTEM_ID = "systemId";
3966
3967 /**
3968 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3969 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3970 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003971 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003972 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003973 */
3974 @Deprecated
3975 @SystemApi
3976 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3977
3978 /**
3979 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3980 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3981 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003982 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003983 * @deprecated Use
3984 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003985 */
3986 @Deprecated
3987 @SystemApi
3988 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3989
3990 /**
3991 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3992 * only mode.
3993 * {@code true} if in emergency only mode, {@code false} otherwise.
3994 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003995 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003996 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07003997 */
3998 @Deprecated
3999 @SystemApi
4000 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4001
4002 /**
4003 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4004 * registration state is roaming.
4005 * {@code true} if registration indicates roaming, {@code false} otherwise
4006 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004007 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004008 * @deprecated Use
4009 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07004010 */
4011 @Deprecated
4012 @SystemApi
4013 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4014 "isDataRoamingFromRegistration";
4015
4016 /**
4017 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4018 * aggregation is in use.
4019 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4020 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004021 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004022 * @deprecated Use
4023 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07004024 */
4025 @Deprecated
4026 @SystemApi
4027 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4028
4029 /**
4030 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4031 * is reduced from the rsrp threshold while calculating signal strength level.
4032 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004033 * @removed
fionaxu90fee272017-03-31 12:45:12 -07004034 */
4035 @Deprecated
4036 @SystemApi
4037 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4038
4039 /**
chen xu02811692018-10-03 19:07:09 -07004040 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
4041 * @hide
4042 */
4043 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
4044
4045 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004046 * The name of the extra used to define the text to be processed, as a
4047 * CharSequence. Note that this may be a styled CharSequence, so you must use
4048 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00004049 */
4050 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4051 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004052 * 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 +00004053 */
4054 public static final String EXTRA_PROCESS_TEXT_READONLY =
4055 "android.intent.extra.PROCESS_TEXT_READONLY";
4056
Bryce Leebc58f592015-09-25 16:43:01 -07004057 /**
4058 * Broadcast action: reports when a new thermal event has been reached. When the device
4059 * is reaching its maximum temperatue, the thermal level reported
4060 * {@hide}
4061 */
4062 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4063 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4064
4065 /** {@hide} */
4066 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4067
4068 /**
4069 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004070 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004071 * {@hide}
4072 */
4073 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4074
4075 /**
4076 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004077 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004078 * {@hide}
4079 */
4080 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4081
4082 /**
4083 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004084 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004085 * {@hide}
4086 */
4087 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4088
lpeter318abc92018-05-04 16:13:14 +08004089 /**
4090 * Broadcast Action: Indicates the dock in idle state while device is docked.
4091 *
4092 * <p class="note">This is a protected intent that can only be sent
4093 * by the system.
4094 *
4095 * @hide
4096 */
4097 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4098
4099 /**
4100 * Broadcast Action: Indicates the dock in active state while device is docked.
4101 *
4102 * <p class="note">This is a protected intent that can only be sent
4103 * by the system.
4104 *
4105 * @hide
4106 */
4107 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4108
Bryce Leebc58f592015-09-25 16:43:01 -07004109
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004110 // ---------------------------------------------------------------------
4111 // ---------------------------------------------------------------------
4112 // Standard intent categories (see addCategory()).
4113
4114 /**
4115 * Set if the activity should be an option for the default action
4116 * (center press) to perform on a piece of data. Setting this will
4117 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004118 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004119 * Intent when initiating an action -- it is for use in intent filters
4120 * specified in packages.
4121 */
4122 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4123 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4124 /**
4125 * Activities that can be safely invoked from a browser must support this
4126 * category. For example, if the user is viewing a web page or an e-mail
4127 * and clicks on a link in the text, the Intent generated execute that
4128 * link will require the BROWSABLE category, so that only activities
4129 * supporting this category will be considered as possible actions. By
4130 * supporting this category, you are promising that there is nothing
4131 * damaging (without user intervention) that can happen by invoking any
4132 * matching Intent.
4133 */
4134 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4135 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4136 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004137 * Categories for activities that can participate in voice interaction.
4138 * An activity that supports this category must be prepared to run with
4139 * no UI shown at all (though in some case it may have a UI shown), and
4140 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4141 */
4142 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4143 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4144 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004145 * Set if the activity should be considered as an alternative action to
4146 * the data the user is currently viewing. See also
4147 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4148 * applies to the selection in a list of items.
4149 *
4150 * <p>Supporting this category means that you would like your activity to be
4151 * displayed in the set of alternative things the user can do, usually as
4152 * part of the current activity's options menu. You will usually want to
4153 * include a specific label in the &lt;intent-filter&gt; of this action
4154 * describing to the user what it does.
4155 *
4156 * <p>The action of IntentFilter with this category is important in that it
4157 * describes the specific action the target will perform. This generally
4158 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4159 * a specific name such as "com.android.camera.action.CROP. Only one
4160 * alternative of any particular action will be shown to the user, so using
4161 * a specific action like this makes sure that your alternative will be
4162 * displayed while also allowing other applications to provide their own
4163 * overrides of that particular action.
4164 */
4165 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4166 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4167 /**
4168 * Set if the activity should be considered as an alternative selection
4169 * action to the data the user has currently selected. This is like
4170 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4171 * of items from which the user can select, giving them alternatives to the
4172 * default action that will be performed on it.
4173 */
4174 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4175 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4176 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004177 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004178 */
4179 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4180 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4181 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004182 * Should be displayed in the top-level launcher.
4183 */
4184 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4185 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4186 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004187 * Indicates an activity optimized for Leanback mode, and that should
4188 * be displayed in the Leanback launcher.
4189 */
4190 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4191 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4192 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004193 * Indicates the preferred entry-point activity when an application is launched from a Car
4194 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4195 * fallback, or exclude the application entirely.
4196 * @hide
4197 */
4198 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4199 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4200 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004201 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4202 * @hide
4203 */
4204 @SystemApi
4205 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4206 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004207 * Provides information about the package it is in; typically used if
4208 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4209 * a front-door to the user without having to be shown in the all apps list.
4210 */
4211 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4212 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4213 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004214 * This is the home activity, that is the first activity that is displayed
4215 * when the device boots.
4216 */
4217 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4218 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4219 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004220 * This is the home activity that is displayed when the device is finished setting up and ready
4221 * for use.
4222 * @hide
4223 */
4224 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4225 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4226 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004227 * This is the setup wizard activity, that is the first activity that is displayed
4228 * when the user sets up the device for the first time.
4229 * @hide
4230 */
4231 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4232 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4233 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004234 * This is the home activity, that is the activity that serves as the launcher app
4235 * from there the user can start other apps. Often components with lower/higher
4236 * priority intent filters handle the home intent, for example SetupWizard, to
4237 * setup the device and we need to be able to distinguish the home app from these
4238 * setup helpers.
4239 * @hide
4240 */
4241 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4242 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4243 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004244 * This activity is a preference panel.
4245 */
4246 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4247 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4248 /**
4249 * This activity is a development preference panel.
4250 */
4251 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4252 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4253 /**
4254 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004255 */
4256 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4257 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4258 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004259 * This activity allows the user to browse and download new applications.
4260 */
4261 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4262 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4263 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004264 * This activity may be exercised by the monkey or other automated test tools.
4265 */
4266 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4267 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4268 /**
4269 * To be used as a test (not part of the normal user experience).
4270 */
4271 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4272 /**
4273 * To be used as a unit test (run through the Test Harness).
4274 */
4275 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4276 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004277 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004278 * experience).
4279 */
4280 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004281
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004282 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004283 * Used to indicate that an intent only wants URIs that can be opened with
4284 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4285 * must support at least the columns defined in {@link OpenableColumns} when
4286 * queried.
4287 *
4288 * @see #ACTION_GET_CONTENT
4289 * @see #ACTION_OPEN_DOCUMENT
4290 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004291 */
4292 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4293 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4294
4295 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004296 * Used to indicate that an intent filter can accept files which are not necessarily
4297 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4298 * at least streamable via
4299 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4300 * using one of the stream types exposed via
4301 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4302 *
4303 * @see #ACTION_SEND
4304 * @see #ACTION_SEND_MULTIPLE
4305 */
4306 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4307 public static final String CATEGORY_TYPED_OPENABLE =
4308 "android.intent.category.TYPED_OPENABLE";
4309
4310 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004311 * To be used as code under test for framework instrumentation tests.
4312 */
4313 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4314 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004315 /**
4316 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004317 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4318 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004319 */
4320 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4321 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4322 /**
4323 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004324 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4325 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004326 */
4327 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4328 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004329 /**
4330 * An activity to run when device is inserted into a analog (low end) dock.
4331 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4332 * information, see {@link android.app.UiModeManager}.
4333 */
4334 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4335 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4336
4337 /**
4338 * An activity to run when device is inserted into a digital (high end) dock.
4339 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4340 * information, see {@link android.app.UiModeManager}.
4341 */
4342 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4343 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004344
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004345 /**
4346 * Used to indicate that the activity can be used in a car environment.
4347 */
4348 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4349 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4350
Zak Cohendb6ca492017-01-26 14:09:00 -08004351 /**
4352 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4353 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4354 * information, see {@link android.app.UiModeManager}.
4355 */
4356 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4357 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004358 // ---------------------------------------------------------------------
4359 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004360 // Application launch intent categories (see addCategory()).
4361
4362 /**
4363 * Used with {@link #ACTION_MAIN} to launch the browser application.
4364 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004365 * <p>NOTE: This should not be used as the primary key of an Intent,
4366 * since it will not result in the app launching with the correct
4367 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004368 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004369 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004370 */
4371 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4372 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4373
4374 /**
4375 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4376 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004377 * <p>NOTE: This should not be used as the primary key of an Intent,
4378 * since it will not result in the app launching with the correct
4379 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004380 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004381 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004382 */
4383 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4384 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4385
4386 /**
4387 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4388 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004389 * <p>NOTE: This should not be used as the primary key of an Intent,
4390 * since it will not result in the app launching with the correct
4391 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004392 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004393 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004394 */
4395 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4396 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4397
4398 /**
4399 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4400 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004401 * <p>NOTE: This should not be used as the primary key of an Intent,
4402 * since it will not result in the app launching with the correct
4403 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004404 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004405 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004406 */
4407 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4408 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4409
4410 /**
4411 * Used with {@link #ACTION_MAIN} to launch the email application.
4412 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004413 * <p>NOTE: This should not be used as the primary key of an Intent,
4414 * since it will not result in the app launching with the correct
4415 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004416 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004417 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004418 */
4419 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4420 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4421
4422 /**
4423 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4424 * The activity should be able to view and manipulate image and video files
4425 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004426 * <p>NOTE: This should not be used as the primary key of an Intent,
4427 * since it will not result in the app launching with the correct
4428 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004429 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004430 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004431 */
4432 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4433 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4434
4435 /**
4436 * Used with {@link #ACTION_MAIN} to launch the maps application.
4437 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004438 * <p>NOTE: This should not be used as the primary key of an Intent,
4439 * since it will not result in the app launching with the correct
4440 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004441 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004442 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004443 */
4444 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4445 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4446
4447 /**
4448 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4449 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004450 * <p>NOTE: This should not be used as the primary key of an Intent,
4451 * since it will not result in the app launching with the correct
4452 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004453 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004454 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004455 */
4456 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4457 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4458
4459 /**
4460 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004461 * The activity should be able to play, browse, or manipulate music files
4462 * stored on the device.
4463 * <p>NOTE: This should not be used as the primary key of an Intent,
4464 * since it will not result in the app launching with the correct
4465 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004466 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004467 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004468 */
4469 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4470 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4471
4472 // ---------------------------------------------------------------------
4473 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004474 // Standard extra data keys.
4475
4476 /**
4477 * The initial data to place in a newly created record. Use with
4478 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4479 * fields as would be given to the underlying ContentProvider.insert()
4480 * call.
4481 */
4482 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4483
4484 /**
4485 * A constant CharSequence that is associated with the Intent, used with
4486 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4487 * this may be a styled CharSequence, so you must use
4488 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4489 * retrieve it.
4490 */
4491 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4492
4493 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004494 * A constant String that is associated with the Intent, used with
4495 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4496 * as HTML formatted text. Note that you <em>must</em> also supply
4497 * {@link #EXTRA_TEXT}.
4498 */
4499 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4500
4501 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004502 * A content: URI holding a stream of data associated with the Intent,
4503 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004504 */
4505 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4506
4507 /**
4508 * A String[] holding e-mail addresses that should be delivered to.
4509 */
4510 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4511
4512 /**
4513 * A String[] holding e-mail addresses that should be carbon copied.
4514 */
4515 public static final String EXTRA_CC = "android.intent.extra.CC";
4516
4517 /**
4518 * A String[] holding e-mail addresses that should be blind carbon copied.
4519 */
4520 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4521
4522 /**
4523 * A constant string holding the desired subject line of a message.
4524 */
4525 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4526
4527 /**
4528 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004529 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004530 */
4531 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4532
4533 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004534 * An int representing the user id to be used.
4535 *
4536 * @hide
4537 */
4538 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4539
4540 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004541 * An int representing the task id to be retrieved. This is used when a launch from recents is
4542 * intercepted by another action such as credentials confirmation to remember which task should
4543 * be resumed when complete.
4544 *
4545 * @hide
4546 */
4547 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4548
4549 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004550 * An Intent[] describing additional, alternate choices you would like shown with
4551 * {@link #ACTION_CHOOSER}.
4552 *
4553 * <p>An app may be capable of providing several different payload types to complete a
4554 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4555 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4556 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4557 * photo data or a hosted link where the photos can be viewed.</p>
4558 *
4559 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4560 * first/primary/preferred intent in the set. Additional intents specified in
4561 * this extra are ordered; by default intents that appear earlier in the array will be
4562 * preferred over intents that appear later in the array as matches for the same
4563 * target component. To alter this preference, a calling app may also supply
4564 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4565 */
4566 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4567
4568 /**
Adam Powell52c39212016-04-07 15:14:18 -07004569 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4570 * and omitted from a list of components presented to the user.
4571 *
4572 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4573 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4574 * from your own package or other apps from your organization if the idea of sending to those
4575 * targets would be redundant with other app functionality. Filtered components will not
4576 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4577 */
4578 public static final String EXTRA_EXCLUDE_COMPONENTS
4579 = "android.intent.extra.EXCLUDE_COMPONENTS";
4580
4581 /**
4582 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4583 * describing additional high-priority deep-link targets for the chooser to present to the user.
4584 *
4585 * <p>Targets provided in this way will be presented inline with all other targets provided
4586 * by services from other apps. They will be prioritized before other service targets, but
4587 * after those targets provided by sources that the user has manually pinned to the front.</p>
4588 *
4589 * @see #ACTION_CHOOSER
4590 */
4591 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4592
4593 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004594 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4595 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4596 *
4597 * <p>An app preparing an action for another app to complete may wish to allow the user to
4598 * disambiguate between several options for completing the action based on the chosen target
4599 * or otherwise refine the action before it is invoked.
4600 * </p>
4601 *
4602 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4603 * <ul>
4604 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4605 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4606 * chosen target beyond the first</li>
4607 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4608 * should fill in and send once the disambiguation is complete</li>
4609 * </ul>
4610 */
4611 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4612 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4613
4614 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004615 * An {@code ArrayList} of {@code String} annotations describing content for
4616 * {@link #ACTION_CHOOSER}.
4617 *
4618 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4619 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4620 *
4621 * <p>Annotations should describe the major components or topics of the content. It is up to
4622 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4623 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004624 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4625 * character. Performance on customized annotations can suffer, if they are rarely used for
4626 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4627 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004628 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004629 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004630 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004631 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004632 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004633 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004634 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004635 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004636 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004637 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4638 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4639 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4640 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4641 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004642 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004643 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4644 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004645 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004646 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004647 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004648 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004649 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004650 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004651 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004652 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004653 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004654 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004655 * Christmas and Thanksgiving.</li>
4656 * </ul>
4657 */
4658 public static final String EXTRA_CONTENT_ANNOTATIONS
4659 = "android.intent.extra.CONTENT_ANNOTATIONS";
4660
4661 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004662 * A {@link ResultReceiver} used to return data back to the sender.
4663 *
4664 * <p>Used to complete an app-specific
4665 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4666 *
4667 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4668 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4669 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4670 * when the user selects a target component from the chooser. It is up to the recipient
4671 * to send a result to this ResultReceiver to signal that disambiguation is complete
4672 * and that the chooser should invoke the user's choice.</p>
4673 *
4674 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4675 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4676 * to match and fill in the final Intent or ChooserTarget before starting it.
4677 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4678 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4679 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4680 *
4681 * <p>The result code passed to the ResultReceiver should be
4682 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4683 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4684 * the chooser should finish without starting a target.</p>
4685 */
4686 public static final String EXTRA_RESULT_RECEIVER
4687 = "android.intent.extra.RESULT_RECEIVER";
4688
4689 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004690 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004691 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004692 */
4693 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4694
4695 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004696 * A Parcelable[] of {@link Intent} or
4697 * {@link android.content.pm.LabeledIntent} objects as set with
4698 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4699 * a the front of the list of choices, when shown to the user with a
4700 * {@link #ACTION_CHOOSER}.
4701 */
4702 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4703
4704 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004705 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004706 * @hide
4707 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004708 @SystemApi
4709 public static final String EXTRA_INSTANT_APP_SUCCESS =
4710 "android.intent.extra.INSTANT_APP_SUCCESS";
4711
4712 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004713 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004714 * @hide
4715 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004716 @SystemApi
4717 public static final String EXTRA_INSTANT_APP_FAILURE =
4718 "android.intent.extra.INSTANT_APP_FAILURE";
4719
4720 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004721 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004722 * @hide
4723 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004724 @SystemApi
4725 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4726 "android.intent.extra.INSTANT_APP_HOSTNAME";
4727
4728 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004729 * An opaque token to track instant app resolution.
4730 * @hide
4731 */
4732 @SystemApi
4733 public static final String EXTRA_INSTANT_APP_TOKEN =
4734 "android.intent.extra.INSTANT_APP_TOKEN";
4735
4736 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004737 * The action that triggered an instant application resolution.
4738 * @hide
4739 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004740 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004741 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4742
4743 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004744 * An array of {@link Bundle}s containing details about resolved instant apps..
4745 * @hide
4746 */
4747 @SystemApi
4748 public static final String EXTRA_INSTANT_APP_BUNDLES =
4749 "android.intent.extra.INSTANT_APP_BUNDLES";
4750
4751 /**
4752 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004753 * installed. This data is populated from the response to
4754 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4755 * instant application resolver.
4756 * @hide
4757 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004758 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004759 public static final String EXTRA_INSTANT_APP_EXTRAS =
4760 "android.intent.extra.INSTANT_APP_EXTRAS";
4761
4762 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004763 * A boolean value indicating that the instant app resolver was unable to state with certainty
4764 * that it did or did not have an app for the sanitized {@link Intent} defined at
4765 * {@link #EXTRA_INTENT}.
4766 * @hide
4767 */
4768 @SystemApi
4769 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4770 "android.intent.extra.UNKNOWN_INSTANT_APP";
4771
4772 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004773 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004774 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004775 * @hide
4776 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004777 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004778 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4779
4780 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004781 * The version code of the app to install components from.
4782 * @hide
4783 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004784 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004785 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4786
4787 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004788 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004789 * @hide
4790 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004791 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004792 public static final String EXTRA_CALLING_PACKAGE
4793 = "android.intent.extra.CALLING_PACKAGE";
4794
4795 /**
4796 * Optional calling app provided bundle containing additional launch information the
4797 * installer may use.
4798 * @hide
4799 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004800 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004801 public static final String EXTRA_VERIFICATION_BUNDLE
4802 = "android.intent.extra.VERIFICATION_BUNDLE";
4803
4804 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004805 * A Bundle forming a mapping of potential target package names to different extras Bundles
4806 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4807 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4808 * be currently installed on the device.
4809 *
4810 * <p>An application may choose to provide alternate extras for the case where a user
4811 * selects an activity from a predetermined set of target packages. If the activity
4812 * the user selects from the chooser belongs to a package with its package name as
4813 * a key in this bundle, the corresponding extras for that package will be merged with
4814 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4815 * extra has the same key as an extra already present in the intent it will overwrite
4816 * the extra from the intent.</p>
4817 *
4818 * <p><em>Examples:</em>
4819 * <ul>
4820 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4821 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4822 * parameters for that target.</li>
4823 * <li>An application may offer additional metadata for known targets of a given intent
4824 * to pass along information only relevant to that target such as account or content
4825 * identifiers already known to that application.</li>
4826 * </ul></p>
4827 */
4828 public static final String EXTRA_REPLACEMENT_EXTRAS =
4829 "android.intent.extra.REPLACEMENT_EXTRAS";
4830
4831 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004832 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4833 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4834 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4835 * {@link ComponentName} of the chosen component.
4836 *
4837 * <p>In some situations this callback may never come, for example if the user abandons
4838 * the chooser, switches to another task or any number of other reasons. Apps should not
4839 * be written assuming that this callback will always occur.</p>
4840 */
4841 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4842 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4843
4844 /**
4845 * The {@link ComponentName} chosen by the user to complete an action.
4846 *
4847 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4848 */
4849 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4850
4851 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004852 * A {@link android.view.KeyEvent} object containing the event that
4853 * triggered the creation of the Intent it is in.
4854 */
4855 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4856
4857 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004858 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4859 * before shutting down.
4860 *
4861 * {@hide}
4862 */
4863 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4864
4865 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004866 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4867 * requested by the user.
4868 *
4869 * {@hide}
4870 */
4871 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4872 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4873
4874 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004875 * 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 -07004876 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4877 * of restarting the application.
4878 */
4879 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4880
4881 /**
4882 * A String holding the phone number originally entered in
4883 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4884 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4885 */
4886 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004887
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004888 /**
4889 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4890 * intents to supply the uid the package had been assigned. Also an optional
4891 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4892 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4893 * purpose.
4894 */
4895 public static final String EXTRA_UID = "android.intent.extra.UID";
4896
4897 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004898 * @hide String array of package names.
4899 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004900 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004901 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4902
4903 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004904 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4905 * intents to indicate whether this represents a full uninstall (removing
4906 * both the code and its data) or a partial uninstall (leaving its data,
4907 * implying that this is an update).
4908 */
4909 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004910
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004911 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004912 * @hide
4913 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4914 * intents to indicate that at this point the package has been removed for
4915 * all users on the device.
4916 */
4917 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4918 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4919
4920 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004921 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4922 * intents to indicate that this is a replacement of the package, so this
4923 * broadcast will immediately be followed by an add broadcast for a
4924 * different version of the same package.
4925 */
4926 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004927
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004928 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004929 * Used as an int extra field in {@link android.app.AlarmManager} intents
4930 * to tell the application being invoked how many pending alarms are being
4931 * delievered with the intent. For one-shot alarms this will always be 1.
4932 * For recurring alarms, this might be greater than 1 if the device was
4933 * asleep or powered off at the time an earlier alarm would have been
4934 * delivered.
4935 */
4936 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004937
Jacek Surazski86b6c532009-05-13 14:38:28 +02004938 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004939 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4940 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004941 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4942 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004943 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4944 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4945 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004946 */
4947 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4948
4949 /**
4950 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4951 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004952 */
4953 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4954
4955 /**
4956 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4957 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004958 */
4959 public static final int EXTRA_DOCK_STATE_DESK = 1;
4960
4961 /**
4962 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4963 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004964 */
4965 public static final int EXTRA_DOCK_STATE_CAR = 2;
4966
4967 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004968 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4969 * to represent that the phone is in a analog (low end) dock.
4970 */
4971 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4972
4973 /**
4974 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4975 * to represent that the phone is in a digital (high end) dock.
4976 */
4977 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4978
4979 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004980 * Boolean that can be supplied as meta-data with a dock activity, to
4981 * indicate that the dock should take over the home key when it is active.
4982 */
4983 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004984
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004985 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004986 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4987 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004988 */
4989 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4990
4991 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004992 * Used in the extra field in the remote intent. It's astring token passed with the
4993 * remote intent.
4994 */
4995 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4996 "android.intent.extra.remote_intent_token";
4997
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004998 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004999 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005000 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005001 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08005002 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005003 "android.intent.extra.changed_component_name";
5004
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005005 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005006 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08005007 * and contains a string array of all of the components that have changed. If
5008 * the state of the overall package has changed, then it will contain an entry
5009 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005010 */
5011 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5012 "android.intent.extra.changed_component_name_list";
5013
5014 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005015 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005016 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00005017 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5018 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5019 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005020 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005021 */
5022 public static final String EXTRA_CHANGED_PACKAGE_LIST =
5023 "android.intent.extra.changed_package_list";
5024
5025 /**
5026 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005027 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5028 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005029 * and contains an integer array of uids of all of the components
5030 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005031 */
5032 public static final String EXTRA_CHANGED_UID_LIST =
5033 "android.intent.extra.changed_uid_list";
5034
5035 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005036 * @hide
5037 * Magic extra system code can use when binding, to give a label for
5038 * who it is that has bound to a service. This is an integer giving
5039 * a framework string resource that can be displayed to the user.
5040 */
5041 public static final String EXTRA_CLIENT_LABEL =
5042 "android.intent.extra.client_label";
5043
5044 /**
5045 * @hide
5046 * Magic extra system code can use when binding, to give a PendingIntent object
5047 * that can be launched for the user to disable the system's use of this
5048 * service.
5049 */
5050 public static final String EXTRA_CLIENT_INTENT =
5051 "android.intent.extra.client_intent";
5052
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005053 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005054 * Extra used to indicate that an intent should only return data that is on
5055 * the local device. This is a boolean extra; the default is false. If true,
5056 * an implementation should only allow the user to select data that is
5057 * already on the device, not requiring it be downloaded from a remote
5058 * service when opened.
5059 *
5060 * @see #ACTION_GET_CONTENT
5061 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07005062 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005063 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005064 */
5065 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005066 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005067
Amith Yamasani13593602012-03-22 16:16:17 -07005068 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005069 * Extra used to indicate that an intent can allow the user to select and
5070 * return multiple items. This is a boolean extra; the default is false. If
5071 * true, an implementation is allowed to present the user with a UI where
5072 * they can pick multiple items that are all returned to the caller. When
5073 * this happens, they should be returned as the {@link #getClipData()} part
5074 * of the result Intent.
5075 *
5076 * @see #ACTION_GET_CONTENT
5077 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005078 */
5079 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005080 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005081
5082 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005083 * The integer userHandle carried with broadcast intents related to addition, removal and
5084 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5085 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5086 *
Amith Yamasani13593602012-03-22 16:16:17 -07005087 * @hide
5088 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005089 public static final String EXTRA_USER_HANDLE =
5090 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005091
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005092 /**
Philip P. Moltmannc54c36d2018-10-08 15:51:07 -07005093 * The UserHandle carried with intents.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005094 */
5095 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005096 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005097
5098 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005099 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005100 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5101 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005102 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005103 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5104
5105 /**
5106 * Extra sent in the intent to the BroadcastReceiver that handles
5107 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5108 * the restrictions as key/value pairs.
5109 */
5110 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5111 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005112
Amith Yamasani86118ba2013-03-28 14:33:16 -07005113 /**
5114 * Extra used in the response from a BroadcastReceiver that handles
5115 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5116 */
5117 public static final String EXTRA_RESTRICTIONS_INTENT =
5118 "android.intent.extra.restrictions_intent";
5119
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005120 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005121 * Extra used to communicate a set of acceptable MIME types. The type of the
5122 * extra is {@code String[]}. Values may be a combination of concrete MIME
5123 * types (such as "image/png") and/or partial MIME types (such as
5124 * "audio/*").
5125 *
5126 * @see #ACTION_GET_CONTENT
5127 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005128 */
5129 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5130
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005131 /**
5132 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5133 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005134 * When this is true, hardware devices can use this information to determine that
5135 * they shouldn't do a complete shutdown of their device since this is not a
5136 * complete shutdown down to the kernel, but only user space restarting.
5137 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005138 */
5139 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5140 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5141
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005142 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005143 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5144 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5145 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5146 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005147 *
5148 * @hide for internal use only.
5149 */
5150 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5151 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005152 /** @hide */
5153 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5154 /** @hide */
5155 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5156 /** @hide */
5157 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005158
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005159 /**
5160 * Intent extra: the reason that the operation associated with this intent is being performed.
5161 *
5162 * <p>Type: String
5163 * @hide
5164 */
5165 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005166 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5167
qingxi240c2bb2017-04-12 17:31:18 -07005168 /**
5169 * {@hide}
5170 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5171 */
Rubin Xue8490f12015-06-25 12:17:48 +01005172 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5173
Santos Cordon15a13782015-03-31 18:32:31 -07005174 /**
qingxi240c2bb2017-04-12 17:31:18 -07005175 * {@hide}
5176 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5177 * reset for the device with eSIM. This extra will be sent together with
5178 * {@link #ACTION_FACTORY_RESET}
5179 */
5180 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5181
5182 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005183 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5184 * activation request.
5185 * TODO: Add information about the structure and response data used with the pending intent.
5186 * @hide
5187 */
5188 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5189 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5190
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005191 /**
5192 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005193 *
5194 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005195 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005196 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005197 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5198
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005199 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005200 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5201 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5202 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005203 *
5204 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005205 * @see #ACTION_QUICK_VIEW
5206 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005207 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005208 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005209 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5210 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005211
5212 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005213 * An optional extra of {@code String[]} indicating which quick view features should be made
5214 * available to the user in the quick view UI while handing a
5215 * {@link Intent#ACTION_QUICK_VIEW} intent.
5216 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5217 * Quick viewer can implement features not listed below.
5218 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005219 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5220 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5221 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005222 * <p>
5223 * Requirements:
5224 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5225 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5226 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5227 * internal policies.
5228 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5229 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5230 * disable or hide features.
5231 *
5232 * @see #ACTION_QUICK_VIEW
5233 */
5234 public static final String EXTRA_QUICK_VIEW_FEATURES =
5235 "android.intent.extra.QUICK_VIEW_FEATURES";
5236
5237 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005238 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005239 * When a profile goes into quiet mode, all apps in the profile are killed and the
5240 * profile user is stopped. Widgets originating from the profile are masked, and app
5241 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005242 */
5243 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005244
5245 /**
Amin Shaikh710d1232018-11-14 16:58:13 -05005246 * Optional CharSequence extra to provide a search query.
5247 *
5248 * <p>Applicable to {@link Intent} with actions:
5249 * <ul>
5250 * <li>{@link Intent#ACTION_GET_CONTENT}</li>
5251 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
5252 * </ul>
5253 */
5254 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
5255
5256 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005257 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005258 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005259 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5260 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005261 *
5262 * @hide
5263 */
5264 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5265 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5266
5267 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005268 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5269 * whether to show the chooser or not when there is only one application available
5270 * to choose from.
5271 *
5272 * @hide
5273 */
5274 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5275 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5276
5277 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005278 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005279 * to represent that a video codec is allowed to use.
5280 *
5281 * @hide
5282 */
5283 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5284
5285 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005286 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005287 * to represent that a audio codec is allowed to use.
5288 *
5289 * @hide
5290 */
5291 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5292
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005293 // ---------------------------------------------------------------------
5294 // ---------------------------------------------------------------------
5295 // Intent flags (see mFlags variable).
5296
Tor Norbyed9273d62013-05-30 15:59:53 -07005297 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005298 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005299 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5300 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005301 @Retention(RetentionPolicy.SOURCE)
5302 public @interface GrantUriMode {}
5303
Jeff Sharkey846318a2014-04-04 12:12:41 -07005304 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005305 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005306 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5307 @Retention(RetentionPolicy.SOURCE)
5308 public @interface AccessUriMode {}
5309
5310 /**
5311 * Test if given mode flags specify an access mode, which must be at least
5312 * read and/or write.
5313 *
5314 * @hide
5315 */
5316 public static boolean isAccessUriMode(int modeFlags) {
5317 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5318 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5319 }
5320
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005321 /** @hide */
5322 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5323 FLAG_GRANT_READ_URI_PERMISSION,
5324 FLAG_GRANT_WRITE_URI_PERMISSION,
5325 FLAG_FROM_BACKGROUND,
5326 FLAG_DEBUG_LOG_RESOLUTION,
5327 FLAG_EXCLUDE_STOPPED_PACKAGES,
5328 FLAG_INCLUDE_STOPPED_PACKAGES,
5329 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5330 FLAG_GRANT_PREFIX_URI_PERMISSION,
5331 FLAG_DEBUG_TRIAGED_MISSING,
5332 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005333 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005334 FLAG_ACTIVITY_NO_HISTORY,
5335 FLAG_ACTIVITY_SINGLE_TOP,
5336 FLAG_ACTIVITY_NEW_TASK,
5337 FLAG_ACTIVITY_MULTIPLE_TASK,
5338 FLAG_ACTIVITY_CLEAR_TOP,
5339 FLAG_ACTIVITY_FORWARD_RESULT,
5340 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5341 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5342 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5343 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5344 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5345 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5346 FLAG_ACTIVITY_NEW_DOCUMENT,
5347 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5348 FLAG_ACTIVITY_NO_USER_ACTION,
5349 FLAG_ACTIVITY_REORDER_TO_FRONT,
5350 FLAG_ACTIVITY_NO_ANIMATION,
5351 FLAG_ACTIVITY_CLEAR_TASK,
5352 FLAG_ACTIVITY_TASK_ON_HOME,
5353 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5354 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5355 FLAG_RECEIVER_REGISTERED_ONLY,
5356 FLAG_RECEIVER_REPLACE_PENDING,
5357 FLAG_RECEIVER_FOREGROUND,
5358 FLAG_RECEIVER_NO_ABORT,
5359 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5360 FLAG_RECEIVER_BOOT_UPGRADE,
5361 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5362 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5363 FLAG_RECEIVER_FROM_SHELL,
5364 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005365 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005366 })
5367 @Retention(RetentionPolicy.SOURCE)
5368 public @interface Flags {}
5369
5370 /** @hide */
5371 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5372 FLAG_FROM_BACKGROUND,
5373 FLAG_DEBUG_LOG_RESOLUTION,
5374 FLAG_EXCLUDE_STOPPED_PACKAGES,
5375 FLAG_INCLUDE_STOPPED_PACKAGES,
5376 FLAG_DEBUG_TRIAGED_MISSING,
5377 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005378 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005379 FLAG_ACTIVITY_NO_HISTORY,
5380 FLAG_ACTIVITY_SINGLE_TOP,
5381 FLAG_ACTIVITY_NEW_TASK,
5382 FLAG_ACTIVITY_MULTIPLE_TASK,
5383 FLAG_ACTIVITY_CLEAR_TOP,
5384 FLAG_ACTIVITY_FORWARD_RESULT,
5385 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5386 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5387 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5388 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5389 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5390 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5391 FLAG_ACTIVITY_NEW_DOCUMENT,
5392 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5393 FLAG_ACTIVITY_NO_USER_ACTION,
5394 FLAG_ACTIVITY_REORDER_TO_FRONT,
5395 FLAG_ACTIVITY_NO_ANIMATION,
5396 FLAG_ACTIVITY_CLEAR_TASK,
5397 FLAG_ACTIVITY_TASK_ON_HOME,
5398 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5399 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5400 FLAG_RECEIVER_REGISTERED_ONLY,
5401 FLAG_RECEIVER_REPLACE_PENDING,
5402 FLAG_RECEIVER_FOREGROUND,
5403 FLAG_RECEIVER_NO_ABORT,
5404 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5405 FLAG_RECEIVER_BOOT_UPGRADE,
5406 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5407 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5408 FLAG_RECEIVER_FROM_SHELL,
5409 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005410 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005411 })
5412 @Retention(RetentionPolicy.SOURCE)
5413 public @interface MutableFlags {}
5414
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005415 /**
5416 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005417 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005418 * specified in its ClipData. When applying to an Intent's ClipData,
5419 * all URIs as well as recursive traversals through data or other ClipData
5420 * in Intent items will be granted; only the grant flags of the top-level
5421 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005422 */
5423 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5424 /**
5425 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005426 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005427 * specified in its ClipData. When applying to an Intent's ClipData,
5428 * all URIs as well as recursive traversals through data or other ClipData
5429 * in Intent items will be granted; only the grant flags of the top-level
5430 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005431 */
5432 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5433 /**
5434 * Can be set by the caller to indicate that this Intent is coming from
5435 * a background operation, not from direct user interaction.
5436 */
5437 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5438 /**
5439 * A flag you can enable for debugging: when set, log messages will be
5440 * printed during the resolution of this intent to show you what has
5441 * been found to create the final resolved list.
5442 */
5443 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005444 /**
5445 * If set, this intent will not match any components in packages that
5446 * are currently stopped. If this is not set, then the default behavior
5447 * is to include such applications in the result.
5448 */
5449 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5450 /**
5451 * If set, this intent will always match any components in packages that
5452 * are currently stopped. This is the default behavior when
5453 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5454 * flags are set, this one wins (it allows overriding of exclude for
5455 * places where the framework may automatically set the exclude flag).
5456 */
5457 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005458
5459 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005460 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005461 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005462 * persisted across device reboots until explicitly revoked with
5463 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5464 * grant for possible persisting; the receiving application must call
5465 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5466 * actually persist.
5467 *
5468 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5469 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5470 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005471 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005472 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005473 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005474
5475 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005476 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5477 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5478 * applies to any URI that is a prefix match against the original granted
5479 * URI. (Without this flag, the URI must match exactly for access to be
5480 * granted.) Another URI is considered a prefix match only when scheme,
5481 * authority, and all path segments defined by the prefix are an exact
5482 * match.
5483 */
5484 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5485
5486 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005487 * Flag used to automatically match intents based on their Direct Boot
5488 * awareness and the current user state.
5489 * <p>
5490 * Since the default behavior is to automatically apply the current user
5491 * state, this is effectively a sentinel value that doesn't change the
5492 * output of any queries based on its presence or absence.
5493 * <p>
5494 * Instead, this value can be useful in conjunction with
5495 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5496 * to detect when a caller is relying on implicit automatic matching,
5497 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005498 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005499 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5500
5501 /** {@hide} */
5502 @Deprecated
5503 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005504
5505 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005506 * Internal flag used to indicate ephemeral applications should not be
5507 * considered when resolving the intent.
5508 *
5509 * @hide
5510 */
5511 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5512
5513 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005514 * If set, the new activity is not kept in the history stack. As soon as
5515 * the user navigates away from it, the activity is finished. This may also
5516 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5517 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005518 *
5519 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5520 * is never invoked when the current activity starts a new activity which
5521 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005522 */
5523 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5524 /**
5525 * If set, the activity will not be launched if it is already running
5526 * at the top of the history stack.
5527 */
5528 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5529 /**
5530 * If set, this activity will become the start of a new task on this
5531 * history stack. A task (from the activity that started it to the
5532 * next task activity) defines an atomic group of activities that the
5533 * user can move to. Tasks can be moved to the foreground and background;
5534 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005535 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005536 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5537 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005538 *
5539 * <p>This flag is generally used by activities that want
5540 * to present a "launcher" style behavior: they give the user a list of
5541 * separate things that can be done, which otherwise run completely
5542 * independently of the activity launching them.
5543 *
5544 * <p>When using this flag, if a task is already running for the activity
5545 * you are now starting, then a new activity will not be started; instead,
5546 * the current task will simply be brought to the front of the screen with
5547 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5548 * to disable this behavior.
5549 *
5550 * <p>This flag can not be used when the caller is requesting a result from
5551 * the activity being launched.
5552 */
5553 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5554 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005555 * This flag is used to create a new task and launch an activity into it.
5556 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5557 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5558 * search through existing tasks for ones matching this Intent. Only if no such
5559 * task is found would a new task be created. When paired with
5560 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5561 * the search for a matching task and unconditionally start a new task.
5562 *
5563 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5564 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005565 * top-level application launcher.</strong> Used in conjunction with
5566 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5567 * behavior of bringing an existing task to the foreground. When set,
5568 * a new task is <em>always</em> started to host the Activity for the
5569 * Intent, regardless of whether there is already an existing task running
5570 * the same thing.
5571 *
5572 * <p><strong>Because the default system does not include graphical task management,
5573 * you should not use this flag unless you provide some way for a user to
5574 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005575 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005576 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5577 * creating new document tasks.
5578 *
5579 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005580 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005581 *
Scott Main7aee61f2011-02-08 11:25:01 -08005582 * <p>See
5583 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5584 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005585 *
5586 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5587 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005588 */
5589 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5590 /**
5591 * If set, and the activity being launched is already running in the
5592 * current task, then instead of launching a new instance of that activity,
5593 * all of the other activities on top of it will be closed and this Intent
5594 * will be delivered to the (now on top) old activity as a new Intent.
5595 *
5596 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5597 * If D calls startActivity() with an Intent that resolves to the component
5598 * of activity B, then C and D will be finished and B receive the given
5599 * Intent, resulting in the stack now being: A, B.
5600 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005601 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005602 * either receive the new intent you are starting here in its
5603 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005604 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005605 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5606 * the same intent, then it will be finished and re-created; for all other
5607 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5608 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005609 *
5610 * <p>This launch mode can also be used to good effect in conjunction with
5611 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5612 * of a task, it will bring any currently running instance of that task
5613 * to the foreground, and then clear it to its root state. This is
5614 * especially useful, for example, when launching an activity from the
5615 * notification manager.
5616 *
Scott Main7aee61f2011-02-08 11:25:01 -08005617 * <p>See
5618 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5619 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005620 */
5621 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5622 /**
5623 * If set and this intent is being used to launch a new activity from an
5624 * existing one, then the reply target of the existing activity will be
kopriva219f7dc2018-10-09 13:42:28 -07005625 * transferred to the new activity. This way, the new activity can call
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005626 * {@link android.app.Activity#setResult} and have that result sent back to
5627 * the reply target of the original activity.
5628 */
5629 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5630 /**
5631 * If set and this intent is being used to launch a new activity from an
5632 * existing one, the current activity will not be counted as the top
5633 * activity for deciding whether the new intent should be delivered to
5634 * the top instead of starting a new one. The previous activity will
5635 * be used as the top, with the assumption being that the current activity
5636 * will finish itself immediately.
5637 */
5638 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5639 /**
5640 * If set, the new activity is not kept in the list of recently launched
5641 * activities.
5642 */
5643 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5644 /**
5645 * This flag is not normally set by application code, but set for you by
5646 * the system as described in the
5647 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5648 * launchMode} documentation for the singleTask mode.
5649 */
5650 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5651 /**
5652 * If set, and this activity is either being started in a new task or
5653 * bringing to the top an existing task, then it will be launched as
5654 * the front door of the task. This will result in the application of
5655 * any affinities needed to have that task in the proper state (either
5656 * moving activities to or from it), or simply resetting that task to
5657 * its initial state if needed.
5658 */
5659 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5660 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005661 * This flag is not normally set by application code, but set for you by
5662 * the system if this activity is being launched from history
5663 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005664 */
5665 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005666 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005667 * @deprecated As of API 21 this performs identically to
5668 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005669 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005670 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005671 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005672 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005673 * This flag is used to open a document into a new task rooted at the activity launched
5674 * by this Intent. Through the use of this flag, or its equivalent attribute,
5675 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005676 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005677 *
Craig Mautner026596b2014-05-21 15:35:44 -07005678 * <p>The use of the activity attribute form of this,
5679 * {@link android.R.attr#documentLaunchMode}, is
5680 * preferred over the Intent flag described here. The attribute form allows the
5681 * Activity to specify multiple document behavior for all launchers of the Activity
5682 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005683 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005684 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5685 * it is kept after the activity is finished is different than the use of
5686 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5687 * this flag is being used to create a new recents entry, then by default that entry
5688 * will be removed once the activity is finished. You can modify this behavior with
5689 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5690 *
Craig Mautner026596b2014-05-21 15:35:44 -07005691 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5692 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5693 * equivalent of the Activity manifest specifying {@link
5694 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5695 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5696 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005697 *
Craig Mautner026596b2014-05-21 15:35:44 -07005698 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005699 *
Craig Mautner026596b2014-05-21 15:35:44 -07005700 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005701 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5702 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005703 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005704 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005705 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005706 * callback from occurring on the current frontmost activity before it is
5707 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005708 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005709 * <p>Typically, an activity can rely on that callback to indicate that an
5710 * explicit user action has caused their activity to be moved out of the
5711 * foreground. The callback marks an appropriate point in the activity's
5712 * lifecycle for it to dismiss any notifications that it intends to display
5713 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005714 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005715 * <p>If an activity is ever started via any non-user-driven events such as
5716 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5717 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005718 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005719 */
5720 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005721 /**
5722 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5723 * this flag will cause the launched activity to be brought to the front of its
5724 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005725 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005726 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5727 * If D calls startActivity() with an Intent that resolves to the component
5728 * of activity B, then B will be brought to the front of the history stack,
5729 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005730 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005731 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005732 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005733 */
5734 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005735 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005736 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5737 * this flag will prevent the system from applying an activity transition
5738 * animation to go to the next activity state. This doesn't mean an
5739 * animation will never run -- if another activity change happens that doesn't
5740 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005741 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005742 * when you are going to do a series of activity operations but the
5743 * animation seen by the user shouldn't be driven by the first activity
5744 * change but rather a later one.
5745 */
5746 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5747 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005748 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5749 * this flag will cause any existing task that would be associated with the
5750 * activity to be cleared before the activity is started. That is, the activity
5751 * becomes the new root of an otherwise empty task, and any old activities
5752 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5753 */
5754 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5755 /**
5756 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5757 * this flag will cause a newly launching task to be placed on top of the current
5758 * home activity task (if there is one). That is, pressing back from the task
5759 * will always return the user to home even if that was not the last activity they
5760 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5761 */
5762 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5763 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005764 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5765 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005766 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005767 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005768 * this flag. When set and the task's activity is finished, the recents
5769 * entry will remain in the interface for the user to re-launch it, like a
5770 * recents entry for a top-level application.
5771 * <p>
5772 * The receiving activity can override this request with
5773 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5774 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005775 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005776 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005777 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005778
5779 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005780 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5781 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005782 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5783 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005784 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005785 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005786
Patrick Baumann577d4022018-01-31 16:55:10 +00005787
5788 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07005789 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5790 * this flag will attempt to launch an instant app if no full app on the device can already
5791 * handle the intent.
5792 * <p>
5793 * When attempting to resolve instant apps externally, the following {@link Intent} properties
5794 * are supported:
5795 * <ul>
5796 * <li>{@link Intent#setAction(String)}</li>
5797 * <li>{@link Intent#addCategory(String)}</li>
5798 * <li>{@link Intent#setData(Uri)}</li>
5799 * <li>{@link Intent#setType(String)}</li>
5800 * <li>{@link Intent#setPackage(String)}</li>
5801 * <li>{@link Intent#addFlags(int)}</li>
5802 * </ul>
5803 * <p>
5804 * In the case that no instant app can be found, the installer will be launched to notify the
5805 * user that the intent could not be resolved. On devices that do not support instant apps,
5806 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00005807 */
5808 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5809
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005810 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005811 * If set, when sending a broadcast only registered receivers will be
5812 * called -- no BroadcastReceiver components will be launched.
5813 */
5814 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005815 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005816 * If set, when sending a broadcast the new broadcast will replace
5817 * any existing pending broadcast that matches it. Matching is defined
5818 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5819 * true for the intents of the two broadcasts. When a match is found,
5820 * the new broadcast (and receivers associated with it) will replace the
5821 * existing one in the pending broadcast list, remaining at the same
5822 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005823 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005824 * <p>This flag is most typically used with sticky broadcasts, which
5825 * only care about delivering the most recent values of the broadcast
5826 * to their receivers.
5827 */
5828 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5829 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005830 * If set, when sending a broadcast the recipient is allowed to run at
5831 * foreground priority, with a shorter timeout interval. During normal
5832 * broadcasts the receivers are not automatically hoisted out of the
5833 * background priority class.
5834 */
5835 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5836 /**
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005837 * If set, when sending a broadcast the recipient will be run on the offload queue.
5838 *
5839 * @hide
5840 */
5841 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
5842 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005843 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5844 * They can still propagate results through to later receivers, but they can not prevent
5845 * later receivers from seeing the broadcast.
5846 */
5847 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5848 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005849 * If set, when sending a broadcast <i>before boot has completed</i> only
5850 * registered receivers will be called -- no BroadcastReceiver components
5851 * will be launched. Sticky intent state will be recorded properly even
5852 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5853 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005854 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005855 * <p>This flag is only for use by system sevices as a convenience to
5856 * avoid having to implement a more complex mechanism around detection
5857 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005858 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005859 * @hide
5860 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005861 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07005862 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005863 /**
5864 * Set when this broadcast is for a boot upgrade, a special mode that
5865 * allows the broadcast to be sent before the system is ready and launches
5866 * the app process with no providers running in it.
5867 * @hide
5868 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005869 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005870 /**
5871 * If set, the broadcast will always go to manifest receivers in background (cached
5872 * or not running) apps, regardless of whether that would be done by default. By
5873 * default they will only receive broadcasts if the broadcast has specified an
5874 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005875 *
5876 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5877 * the broadcast code there must also be changed to match.
5878 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005879 * @hide
5880 */
5881 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5882 /**
5883 * If set, the broadcast will never go to manifest receivers in background (cached
5884 * or not running) apps, regardless of whether that would be done by default. By
5885 * default they will receive broadcasts if the broadcast has specified an
5886 * explicit component or package name.
5887 * @hide
5888 */
5889 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005890 /**
5891 * If set, this broadcast is being sent from the shell.
5892 * @hide
5893 */
5894 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005895
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005896 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005897 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5898 * will not receive broadcasts.
5899 *
5900 * <em>This flag has no effect when used by an Instant App.</em>
5901 */
5902 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5903
5904 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005905 * @hide Flags that can't be changed with PendingIntent.
5906 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005907 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5908 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5909 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005910
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005911 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005912 // ---------------------------------------------------------------------
5913 // toUri() and parseUri() options.
5914
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005915 /** @hide */
5916 @IntDef(flag = true, prefix = { "URI_" }, value = {
5917 URI_ALLOW_UNSAFE,
5918 URI_ANDROID_APP_SCHEME,
5919 URI_INTENT_SCHEME,
5920 })
5921 @Retention(RetentionPolicy.SOURCE)
5922 public @interface UriFlags {}
5923
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005924 /**
5925 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5926 * always has the "intent:" scheme. This syntax can be used when you want
5927 * to later disambiguate between URIs that are intended to describe an
5928 * Intent vs. all others that should be treated as raw URIs. When used
5929 * with {@link #parseUri}, any other scheme will result in a generic
5930 * VIEW action for that raw URI.
5931 */
5932 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005933
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005934 /**
5935 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5936 * always has the "android-app:" scheme. This is a variation of
5937 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5938 * http/https URI being delivered to a specific package name. The format
5939 * is:
5940 *
5941 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005942 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005943 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005944 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5945 * you must also include a scheme; including a path also requires both a host and a scheme.
5946 * The final #Intent; fragment can be used without a scheme, host, or path.
5947 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005948 * used with intents that have a {@link #setSelector}, since the base intent
5949 * will always have an explicit package name.</p>
5950 *
5951 * <p>Some examples of how this scheme maps to Intent objects:</p>
5952 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5953 * <colgroup align="left" />
5954 * <colgroup align="left" />
5955 * <thead>
5956 * <tr><th>URI</th> <th>Intent</th></tr>
5957 * </thead>
5958 *
5959 * <tbody>
5960 * <tr><td><code>android-app://com.example.app</code></td>
5961 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5962 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5963 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5964 * </table></td>
5965 * </tr>
5966 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5967 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5968 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5969 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5970 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5971 * </table></td>
5972 * </tr>
5973 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5974 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5975 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5976 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5977 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5978 * </table></td>
5979 * </tr>
5980 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5981 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5982 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5983 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5984 * </table></td>
5985 * </tr>
5986 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5987 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5988 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5989 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5990 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5991 * </table></td>
5992 * </tr>
5993 * <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>
5994 * <td><table border="" style="margin:0" >
5995 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5996 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5997 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5998 * </table></td>
5999 * </tr>
6000 * </tbody>
6001 * </table>
6002 */
6003 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6004
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006005 /**
6006 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6007 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6008 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6009 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6010 * generated Intent can not cause unexpected data access to happen.
6011 *
6012 * <p>If you do not trust the source of the URI being parsed, you should still do further
6013 * processing to protect yourself from it. In particular, when using it to start an
6014 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6015 * that can handle it.</p>
6016 */
6017 public static final int URI_ALLOW_UNSAFE = 1<<2;
6018
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006019 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006020
6021 private String mAction;
6022 private Uri mData;
6023 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006024 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006025 private ComponentName mComponent;
6026 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006027 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006028 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006029 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006030 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006031 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006032 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006033 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07006034 /** Token to track instant app launches. Local only; do not copy cross-process. */
6035 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006036
6037 // ---------------------------------------------------------------------
6038
Makoto Onuki97f82f22017-05-31 16:20:21 -07006039 private static final int COPY_MODE_ALL = 0;
6040 private static final int COPY_MODE_FILTER = 1;
6041 private static final int COPY_MODE_HISTORY = 2;
6042
6043 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07006044 @IntDef(prefix = { "COPY_MODE_" }, value = {
6045 COPY_MODE_ALL,
6046 COPY_MODE_FILTER,
6047 COPY_MODE_HISTORY
6048 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07006049 @Retention(RetentionPolicy.SOURCE)
6050 public @interface CopyMode {}
6051
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006052 /**
6053 * Create an empty intent.
6054 */
6055 public Intent() {
6056 }
6057
6058 /**
6059 * Copy constructor.
6060 */
6061 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006062 this(o, COPY_MODE_ALL);
6063 }
6064
6065 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006066 this.mAction = o.mAction;
6067 this.mData = o.mData;
6068 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006069 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006070 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07006071
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006072 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006073 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006074 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07006075
6076 if (copyMode != COPY_MODE_FILTER) {
6077 this.mFlags = o.mFlags;
6078 this.mContentUserHint = o.mContentUserHint;
6079 this.mLaunchToken = o.mLaunchToken;
6080 if (o.mSourceBounds != null) {
6081 this.mSourceBounds = new Rect(o.mSourceBounds);
6082 }
6083 if (o.mSelector != null) {
6084 this.mSelector = new Intent(o.mSelector);
6085 }
6086
6087 if (copyMode != COPY_MODE_HISTORY) {
6088 if (o.mExtras != null) {
6089 this.mExtras = new Bundle(o.mExtras);
6090 }
6091 if (o.mClipData != null) {
6092 this.mClipData = new ClipData(o.mClipData);
6093 }
6094 } else {
6095 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6096 this.mExtras = Bundle.STRIPPED;
6097 }
6098
6099 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6100 // history.
6101 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006102 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006103 }
6104
6105 @Override
6106 public Object clone() {
6107 return new Intent(this);
6108 }
6109
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006110 /**
6111 * Make a clone of only the parts of the Intent that are relevant for
6112 * filter matching: the action, data, type, component, and categories.
6113 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006114 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006115 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006116 }
6117
6118 /**
6119 * Create an intent with a given action. All other fields (data, type,
6120 * class) are null. Note that the action <em>must</em> be in a
6121 * namespace because Intents are used globally in the system -- for
6122 * example the system VIEW action is android.intent.action.VIEW; an
6123 * application's custom action would be something like
6124 * com.google.app.myapp.CUSTOM_ACTION.
6125 *
6126 * @param action The Intent action, such as ACTION_VIEW.
6127 */
6128 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006129 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006130 }
6131
6132 /**
6133 * Create an intent with a given action and for a given data url. Note
6134 * that the action <em>must</em> be in a namespace because Intents are
6135 * used globally in the system -- for example the system VIEW action is
6136 * android.intent.action.VIEW; an application's custom action would be
6137 * something like com.google.app.myapp.CUSTOM_ACTION.
6138 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006139 * <p><em>Note: scheme and host name matching in the Android framework is
6140 * case-sensitive, unlike the formal RFC. As a result,
6141 * you should always ensure that you write your Uri with these elements
6142 * using lower case letters, and normalize any Uris you receive from
6143 * outside of Android to ensure the scheme and host is lower case.</em></p>
6144 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006145 * @param action The Intent action, such as ACTION_VIEW.
6146 * @param uri The Intent data URI.
6147 */
6148 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006149 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006150 mData = uri;
6151 }
6152
6153 /**
6154 * Create an intent for a specific component. All other fields (action, data,
6155 * type, class) are null, though they can be modified later with explicit
6156 * calls. This provides a convenient way to create an intent that is
6157 * intended to execute a hard-coded class name, rather than relying on the
6158 * system to find an appropriate class for you; see {@link #setComponent}
6159 * for more information on the repercussions of this.
6160 *
6161 * @param packageContext A Context of the application package implementing
6162 * this class.
6163 * @param cls The component class that is to be used for the intent.
6164 *
6165 * @see #setClass
6166 * @see #setComponent
6167 * @see #Intent(String, android.net.Uri , Context, Class)
6168 */
6169 public Intent(Context packageContext, Class<?> cls) {
6170 mComponent = new ComponentName(packageContext, cls);
6171 }
6172
6173 /**
6174 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006175 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006176 * construct the Intent and then calling {@link #setClass} to set its
6177 * class.
6178 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006179 * <p><em>Note: scheme and host name matching in the Android framework is
6180 * case-sensitive, unlike the formal RFC. As a result,
6181 * you should always ensure that you write your Uri with these elements
6182 * using lower case letters, and normalize any Uris you receive from
6183 * outside of Android to ensure the scheme and host is lower case.</em></p>
6184 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006185 * @param action The Intent action, such as ACTION_VIEW.
6186 * @param uri The Intent data URI.
6187 * @param packageContext A Context of the application package implementing
6188 * this class.
6189 * @param cls The component class that is to be used for the intent.
6190 *
6191 * @see #Intent(String, android.net.Uri)
6192 * @see #Intent(Context, Class)
6193 * @see #setClass
6194 * @see #setComponent
6195 */
6196 public Intent(String action, Uri uri,
6197 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006198 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006199 mData = uri;
6200 mComponent = new ComponentName(packageContext, cls);
6201 }
6202
6203 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006204 * Create an intent to launch the main (root) activity of a task. This
6205 * is the Intent that is started when the application's is launched from
6206 * Home. For anything else that wants to launch an application in the
6207 * same way, it is important that they use an Intent structured the same
6208 * way, and can use this function to ensure this is the case.
6209 *
6210 * <p>The returned Intent has the given Activity component as its explicit
6211 * component, {@link #ACTION_MAIN} as its action, and includes the
6212 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6213 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6214 * to do that through {@link #addFlags(int)} on the returned Intent.
6215 *
6216 * @param mainActivity The main activity component that this Intent will
6217 * launch.
6218 * @return Returns a newly created Intent that can be used to launch the
6219 * activity as a main application entry.
6220 *
6221 * @see #setClass
6222 * @see #setComponent
6223 */
6224 public static Intent makeMainActivity(ComponentName mainActivity) {
6225 Intent intent = new Intent(ACTION_MAIN);
6226 intent.setComponent(mainActivity);
6227 intent.addCategory(CATEGORY_LAUNCHER);
6228 return intent;
6229 }
6230
6231 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006232 * Make an Intent for the main activity of an application, without
6233 * specifying a specific activity to run but giving a selector to find
6234 * the activity. This results in a final Intent that is structured
6235 * the same as when the application is launched from
6236 * Home. For anything else that wants to launch an application in the
6237 * same way, it is important that they use an Intent structured the same
6238 * way, and can use this function to ensure this is the case.
6239 *
6240 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6241 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6242 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6243 * to do that through {@link #addFlags(int)} on the returned Intent.
6244 *
6245 * @param selectorAction The action name of the Intent's selector.
6246 * @param selectorCategory The name of a category to add to the Intent's
6247 * selector.
6248 * @return Returns a newly created Intent that can be used to launch the
6249 * activity as a main application entry.
6250 *
6251 * @see #setSelector(Intent)
6252 */
6253 public static Intent makeMainSelectorActivity(String selectorAction,
6254 String selectorCategory) {
6255 Intent intent = new Intent(ACTION_MAIN);
6256 intent.addCategory(CATEGORY_LAUNCHER);
6257 Intent selector = new Intent();
6258 selector.setAction(selectorAction);
6259 selector.addCategory(selectorCategory);
6260 intent.setSelector(selector);
6261 return intent;
6262 }
6263
6264 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006265 * Make an Intent that can be used to re-launch an application's task
6266 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6267 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6268 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6269 *
6270 * @param mainActivity The activity component that is the root of the
6271 * task; this is the activity that has been published in the application's
6272 * manifest as the main launcher icon.
6273 *
6274 * @return Returns a newly created Intent that can be used to relaunch the
6275 * activity's task in its root state.
6276 */
6277 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6278 Intent intent = makeMainActivity(mainActivity);
6279 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6280 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6281 return intent;
6282 }
6283
6284 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006285 * Call {@link #parseUri} with 0 flags.
6286 * @deprecated Use {@link #parseUri} instead.
6287 */
6288 @Deprecated
6289 public static Intent getIntent(String uri) throws URISyntaxException {
6290 return parseUri(uri, 0);
6291 }
Tom Taylord4a47292009-12-21 13:59:18 -08006292
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006293 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006294 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006295 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006296 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006297 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006298 *
6299 * <p>The URI given here must not be relative -- that is, it must include
6300 * the scheme and full path.
6301 *
6302 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006303 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006304 *
6305 * @return Intent The newly created Intent object.
6306 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006307 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6308 * it bad (as parsed by the Uri class) or the Intent data within the
6309 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006310 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006311 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006312 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006313 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006314 int i = 0;
6315 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006316 final boolean androidApp = uri.startsWith("android-app:");
6317
6318 // Validate intent scheme if requested.
6319 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6320 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006321 Intent intent = new Intent(ACTION_VIEW);
6322 try {
6323 intent.setData(Uri.parse(uri));
6324 } catch (IllegalArgumentException e) {
6325 throw new URISyntaxException(uri, e.getMessage());
6326 }
6327 return intent;
6328 }
6329 }
Tom Taylord4a47292009-12-21 13:59:18 -08006330
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006331 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006332 // simple case
6333 if (i == -1) {
6334 if (!androidApp) {
6335 return new Intent(ACTION_VIEW, Uri.parse(uri));
6336 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006337
6338 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006339 } else if (!uri.startsWith("#Intent;", i)) {
6340 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006341 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006342 } else {
6343 i = -1;
6344 }
6345 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006346
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006347 // new format
6348 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006349 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006350 boolean explicitAction = false;
6351 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006352
6353 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006354 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006355 String data;
6356 if (i >= 0) {
6357 data = uri.substring(0, i);
6358 i += 8; // length of "#Intent;"
6359 } else {
6360 data = uri;
6361 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006362
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006363 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006364 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006365 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006366 if (eq < 0) eq = i-1;
6367 int semi = uri.indexOf(';', i);
6368 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006369
6370 // action
6371 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006372 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006373 if (!inSelector) {
6374 explicitAction = true;
6375 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006376 }
6377
6378 // categories
6379 else if (uri.startsWith("category=", i)) {
6380 intent.addCategory(value);
6381 }
6382
6383 // type
6384 else if (uri.startsWith("type=", i)) {
6385 intent.mType = value;
6386 }
6387
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006388 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006389 else if (uri.startsWith("launchFlags=", i)) {
6390 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006391 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6392 intent.mFlags &= ~IMMUTABLE_FLAGS;
6393 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006394 }
6395
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006396 // package
6397 else if (uri.startsWith("package=", i)) {
6398 intent.mPackage = value;
6399 }
6400
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006401 // component
6402 else if (uri.startsWith("component=", i)) {
6403 intent.mComponent = ComponentName.unflattenFromString(value);
6404 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006405
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006406 // scheme
6407 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006408 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006409 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006410 } else {
6411 scheme = value;
6412 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006413 }
6414
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006415 // source bounds
6416 else if (uri.startsWith("sourceBounds=", i)) {
6417 intent.mSourceBounds = Rect.unflattenFromString(value);
6418 }
6419
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006420 // selector
6421 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6422 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006423 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006424 }
6425
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006426 // extra
6427 else {
6428 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006429 // create Bundle if it doesn't already exist
6430 if (intent.mExtras == null) intent.mExtras = new Bundle();
6431 Bundle b = intent.mExtras;
6432 // add EXTRA
6433 if (uri.startsWith("S.", i)) b.putString(key, value);
6434 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6435 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6436 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6437 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6438 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6439 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6440 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6441 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6442 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6443 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006444
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006445 // move to the next item
6446 i = semi + 1;
6447 }
6448
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006449 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006450 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006451 if (baseIntent.mPackage == null) {
6452 baseIntent.setSelector(intent);
6453 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006454 intent = baseIntent;
6455 }
6456
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006457 if (data != null) {
6458 if (data.startsWith("intent:")) {
6459 data = data.substring(7);
6460 if (scheme != null) {
6461 data = scheme + ':' + data;
6462 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006463 } else if (data.startsWith("android-app:")) {
6464 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6465 // Correctly formed android-app, first part is package name.
6466 int end = data.indexOf('/', 14);
6467 if (end < 0) {
6468 // All we have is a package name.
6469 intent.mPackage = data.substring(14);
6470 if (!explicitAction) {
6471 intent.setAction(ACTION_MAIN);
6472 }
6473 data = "";
6474 } else {
6475 // Target the Intent at the given package name always.
6476 String authority = null;
6477 intent.mPackage = data.substring(14, end);
6478 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006479 if ((end+1) < data.length()) {
6480 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6481 // Found a scheme, remember it.
6482 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006483 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006484 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6485 // Found a authority, remember it.
6486 authority = data.substring(end+1, newEnd);
6487 end = newEnd;
6488 }
6489 } else {
6490 // All we have is a scheme.
6491 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006492 }
6493 }
6494 if (scheme == null) {
6495 // If there was no scheme, then this just targets the package.
6496 if (!explicitAction) {
6497 intent.setAction(ACTION_MAIN);
6498 }
6499 data = "";
6500 } else if (authority == null) {
6501 data = scheme + ":";
6502 } else {
6503 data = scheme + "://" + authority + data.substring(end);
6504 }
6505 }
6506 } else {
6507 data = "";
6508 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006509 }
Tom Taylord4a47292009-12-21 13:59:18 -08006510
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006511 if (data.length() > 0) {
6512 try {
6513 intent.mData = Uri.parse(data);
6514 } catch (IllegalArgumentException e) {
6515 throw new URISyntaxException(uri, e.getMessage());
6516 }
6517 }
6518 }
Tom Taylord4a47292009-12-21 13:59:18 -08006519
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006520 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006521
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006522 } catch (IndexOutOfBoundsException e) {
6523 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6524 }
6525 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006526
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006527 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006528 return getIntentOld(uri, 0);
6529 }
6530
6531 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006532 Intent intent;
6533
6534 int i = uri.lastIndexOf('#');
6535 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006536 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006537 final int intentFragmentStart = i;
6538 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006539
6540 i++;
6541
6542 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006543 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006544 i += 7;
6545 int j = uri.indexOf(')', i);
6546 action = uri.substring(i, j);
6547 i = j + 1;
6548 }
6549
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006550 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006551
6552 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006553 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006554 i += 11;
6555 int j = uri.indexOf(')', i);
6556 while (i < j) {
6557 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006558 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006559 if (i < sep) {
6560 intent.addCategory(uri.substring(i, sep));
6561 }
6562 i = sep + 1;
6563 }
6564 i = j + 1;
6565 }
6566
6567 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006568 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006569 i += 5;
6570 int j = uri.indexOf(')', i);
6571 intent.mType = uri.substring(i, j);
6572 i = j + 1;
6573 }
6574
6575 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006576 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006577 i += 12;
6578 int j = uri.indexOf(')', i);
6579 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006580 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6581 intent.mFlags &= ~IMMUTABLE_FLAGS;
6582 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006583 i = j + 1;
6584 }
6585
6586 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006587 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006588 i += 10;
6589 int j = uri.indexOf(')', i);
6590 int sep = uri.indexOf('!', i);
6591 if (sep >= 0 && sep < j) {
6592 String pkg = uri.substring(i, sep);
6593 String cls = uri.substring(sep + 1, j);
6594 intent.mComponent = new ComponentName(pkg, cls);
6595 }
6596 i = j + 1;
6597 }
6598
6599 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006600 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006601 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006602
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006603 final int closeParen = uri.indexOf(')', i);
6604 if (closeParen == -1) throw new URISyntaxException(uri,
6605 "EXTRA missing trailing ')'", i);
6606
6607 while (i < closeParen) {
6608 // fetch the key value
6609 int j = uri.indexOf('=', i);
6610 if (j <= i + 1 || i >= closeParen) {
6611 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6612 }
6613 char type = uri.charAt(i);
6614 i++;
6615 String key = uri.substring(i, j);
6616 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006617
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006618 // get type-value
6619 j = uri.indexOf('!', i);
6620 if (j == -1 || j >= closeParen) j = closeParen;
6621 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6622 String value = uri.substring(i, j);
6623 i = j;
6624
6625 // create Bundle if it doesn't already exist
6626 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006627
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006628 // add item to bundle
6629 try {
6630 switch (type) {
6631 case 'S':
6632 intent.mExtras.putString(key, Uri.decode(value));
6633 break;
6634 case 'B':
6635 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6636 break;
6637 case 'b':
6638 intent.mExtras.putByte(key, Byte.parseByte(value));
6639 break;
6640 case 'c':
6641 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6642 break;
6643 case 'd':
6644 intent.mExtras.putDouble(key, Double.parseDouble(value));
6645 break;
6646 case 'f':
6647 intent.mExtras.putFloat(key, Float.parseFloat(value));
6648 break;
6649 case 'i':
6650 intent.mExtras.putInt(key, Integer.parseInt(value));
6651 break;
6652 case 'l':
6653 intent.mExtras.putLong(key, Long.parseLong(value));
6654 break;
6655 case 's':
6656 intent.mExtras.putShort(key, Short.parseShort(value));
6657 break;
6658 default:
6659 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6660 }
6661 } catch (NumberFormatException e) {
6662 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6663 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006665 char ch = uri.charAt(i);
6666 if (ch == ')') break;
6667 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6668 i++;
6669 }
6670 }
6671
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006672 if (isIntentFragment) {
6673 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6674 } else {
6675 intent.mData = Uri.parse(uri);
6676 }
Tom Taylord4a47292009-12-21 13:59:18 -08006677
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006678 if (intent.mAction == null) {
6679 // By default, if no action is specified, then use VIEW.
6680 intent.mAction = ACTION_VIEW;
6681 }
6682
6683 } else {
6684 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6685 }
6686
6687 return intent;
6688 }
6689
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006690 /** @hide */
6691 public interface CommandOptionHandler {
6692 boolean handleOption(String opt, ShellCommand cmd);
6693 }
6694
6695 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006696 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006697 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6698 throws URISyntaxException {
6699 Intent intent = new Intent();
6700 Intent baseIntent = intent;
6701 boolean hasIntentInfo = false;
6702
6703 Uri data = null;
6704 String type = null;
6705
6706 String opt;
6707 while ((opt=cmd.getNextOption()) != null) {
6708 switch (opt) {
6709 case "-a":
6710 intent.setAction(cmd.getNextArgRequired());
6711 if (intent == baseIntent) {
6712 hasIntentInfo = true;
6713 }
6714 break;
6715 case "-d":
6716 data = Uri.parse(cmd.getNextArgRequired());
6717 if (intent == baseIntent) {
6718 hasIntentInfo = true;
6719 }
6720 break;
6721 case "-t":
6722 type = cmd.getNextArgRequired();
6723 if (intent == baseIntent) {
6724 hasIntentInfo = true;
6725 }
6726 break;
6727 case "-c":
6728 intent.addCategory(cmd.getNextArgRequired());
6729 if (intent == baseIntent) {
6730 hasIntentInfo = true;
6731 }
6732 break;
6733 case "-e":
6734 case "--es": {
6735 String key = cmd.getNextArgRequired();
6736 String value = cmd.getNextArgRequired();
6737 intent.putExtra(key, value);
6738 }
6739 break;
6740 case "--esn": {
6741 String key = cmd.getNextArgRequired();
6742 intent.putExtra(key, (String) null);
6743 }
6744 break;
6745 case "--ei": {
6746 String key = cmd.getNextArgRequired();
6747 String value = cmd.getNextArgRequired();
6748 intent.putExtra(key, Integer.decode(value));
6749 }
6750 break;
6751 case "--eu": {
6752 String key = cmd.getNextArgRequired();
6753 String value = cmd.getNextArgRequired();
6754 intent.putExtra(key, Uri.parse(value));
6755 }
6756 break;
6757 case "--ecn": {
6758 String key = cmd.getNextArgRequired();
6759 String value = cmd.getNextArgRequired();
6760 ComponentName cn = ComponentName.unflattenFromString(value);
6761 if (cn == null)
6762 throw new IllegalArgumentException("Bad component name: " + value);
6763 intent.putExtra(key, cn);
6764 }
6765 break;
6766 case "--eia": {
6767 String key = cmd.getNextArgRequired();
6768 String value = cmd.getNextArgRequired();
6769 String[] strings = value.split(",");
6770 int[] list = new int[strings.length];
6771 for (int i = 0; i < strings.length; i++) {
6772 list[i] = Integer.decode(strings[i]);
6773 }
6774 intent.putExtra(key, list);
6775 }
6776 break;
6777 case "--eial": {
6778 String key = cmd.getNextArgRequired();
6779 String value = cmd.getNextArgRequired();
6780 String[] strings = value.split(",");
6781 ArrayList<Integer> list = new ArrayList<>(strings.length);
6782 for (int i = 0; i < strings.length; i++) {
6783 list.add(Integer.decode(strings[i]));
6784 }
6785 intent.putExtra(key, list);
6786 }
6787 break;
6788 case "--el": {
6789 String key = cmd.getNextArgRequired();
6790 String value = cmd.getNextArgRequired();
6791 intent.putExtra(key, Long.valueOf(value));
6792 }
6793 break;
6794 case "--ela": {
6795 String key = cmd.getNextArgRequired();
6796 String value = cmd.getNextArgRequired();
6797 String[] strings = value.split(",");
6798 long[] list = new long[strings.length];
6799 for (int i = 0; i < strings.length; i++) {
6800 list[i] = Long.valueOf(strings[i]);
6801 }
6802 intent.putExtra(key, list);
6803 hasIntentInfo = true;
6804 }
6805 break;
6806 case "--elal": {
6807 String key = cmd.getNextArgRequired();
6808 String value = cmd.getNextArgRequired();
6809 String[] strings = value.split(",");
6810 ArrayList<Long> list = new ArrayList<>(strings.length);
6811 for (int i = 0; i < strings.length; i++) {
6812 list.add(Long.valueOf(strings[i]));
6813 }
6814 intent.putExtra(key, list);
6815 hasIntentInfo = true;
6816 }
6817 break;
6818 case "--ef": {
6819 String key = cmd.getNextArgRequired();
6820 String value = cmd.getNextArgRequired();
6821 intent.putExtra(key, Float.valueOf(value));
6822 hasIntentInfo = true;
6823 }
6824 break;
6825 case "--efa": {
6826 String key = cmd.getNextArgRequired();
6827 String value = cmd.getNextArgRequired();
6828 String[] strings = value.split(",");
6829 float[] list = new float[strings.length];
6830 for (int i = 0; i < strings.length; i++) {
6831 list[i] = Float.valueOf(strings[i]);
6832 }
6833 intent.putExtra(key, list);
6834 hasIntentInfo = true;
6835 }
6836 break;
6837 case "--efal": {
6838 String key = cmd.getNextArgRequired();
6839 String value = cmd.getNextArgRequired();
6840 String[] strings = value.split(",");
6841 ArrayList<Float> list = new ArrayList<>(strings.length);
6842 for (int i = 0; i < strings.length; i++) {
6843 list.add(Float.valueOf(strings[i]));
6844 }
6845 intent.putExtra(key, list);
6846 hasIntentInfo = true;
6847 }
6848 break;
6849 case "--esa": {
6850 String key = cmd.getNextArgRequired();
6851 String value = cmd.getNextArgRequired();
6852 // Split on commas unless they are preceeded by an escape.
6853 // The escape character must be escaped for the string and
6854 // again for the regex, thus four escape characters become one.
6855 String[] strings = value.split("(?<!\\\\),");
6856 intent.putExtra(key, strings);
6857 hasIntentInfo = true;
6858 }
6859 break;
6860 case "--esal": {
6861 String key = cmd.getNextArgRequired();
6862 String value = cmd.getNextArgRequired();
6863 // Split on commas unless they are preceeded by an escape.
6864 // The escape character must be escaped for the string and
6865 // again for the regex, thus four escape characters become one.
6866 String[] strings = value.split("(?<!\\\\),");
6867 ArrayList<String> list = new ArrayList<>(strings.length);
6868 for (int i = 0; i < strings.length; i++) {
6869 list.add(strings[i]);
6870 }
6871 intent.putExtra(key, list);
6872 hasIntentInfo = true;
6873 }
6874 break;
6875 case "--ez": {
6876 String key = cmd.getNextArgRequired();
6877 String value = cmd.getNextArgRequired().toLowerCase();
6878 // Boolean.valueOf() results in false for anything that is not "true", which is
6879 // error-prone in shell commands
6880 boolean arg;
6881 if ("true".equals(value) || "t".equals(value)) {
6882 arg = true;
6883 } else if ("false".equals(value) || "f".equals(value)) {
6884 arg = false;
6885 } else {
6886 try {
6887 arg = Integer.decode(value) != 0;
6888 } catch (NumberFormatException ex) {
6889 throw new IllegalArgumentException("Invalid boolean value: " + value);
6890 }
6891 }
6892
6893 intent.putExtra(key, arg);
6894 }
6895 break;
6896 case "-n": {
6897 String str = cmd.getNextArgRequired();
6898 ComponentName cn = ComponentName.unflattenFromString(str);
6899 if (cn == null)
6900 throw new IllegalArgumentException("Bad component name: " + str);
6901 intent.setComponent(cn);
6902 if (intent == baseIntent) {
6903 hasIntentInfo = true;
6904 }
6905 }
6906 break;
6907 case "-p": {
6908 String str = cmd.getNextArgRequired();
6909 intent.setPackage(str);
6910 if (intent == baseIntent) {
6911 hasIntentInfo = true;
6912 }
6913 }
6914 break;
6915 case "-f":
6916 String str = cmd.getNextArgRequired();
6917 intent.setFlags(Integer.decode(str).intValue());
6918 break;
6919 case "--grant-read-uri-permission":
6920 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6921 break;
6922 case "--grant-write-uri-permission":
6923 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6924 break;
6925 case "--grant-persistable-uri-permission":
6926 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6927 break;
6928 case "--grant-prefix-uri-permission":
6929 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6930 break;
6931 case "--exclude-stopped-packages":
6932 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6933 break;
6934 case "--include-stopped-packages":
6935 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6936 break;
6937 case "--debug-log-resolution":
6938 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6939 break;
6940 case "--activity-brought-to-front":
6941 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6942 break;
6943 case "--activity-clear-top":
6944 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6945 break;
6946 case "--activity-clear-when-task-reset":
6947 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6948 break;
6949 case "--activity-exclude-from-recents":
6950 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6951 break;
6952 case "--activity-launched-from-history":
6953 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6954 break;
6955 case "--activity-multiple-task":
6956 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6957 break;
6958 case "--activity-no-animation":
6959 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6960 break;
6961 case "--activity-no-history":
6962 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6963 break;
6964 case "--activity-no-user-action":
6965 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6966 break;
6967 case "--activity-previous-is-top":
6968 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6969 break;
6970 case "--activity-reorder-to-front":
6971 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6972 break;
6973 case "--activity-reset-task-if-needed":
6974 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6975 break;
6976 case "--activity-single-top":
6977 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6978 break;
6979 case "--activity-clear-task":
6980 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6981 break;
6982 case "--activity-task-on-home":
6983 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6984 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006985 case "--activity-match-external":
6986 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6987 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006988 case "--receiver-registered-only":
6989 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6990 break;
6991 case "--receiver-replace-pending":
6992 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6993 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006994 case "--receiver-foreground":
6995 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6996 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006997 case "--receiver-no-abort":
6998 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6999 break;
7000 case "--receiver-include-background":
7001 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7002 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007003 case "--selector":
7004 intent.setDataAndType(data, type);
7005 intent = new Intent();
7006 break;
7007 default:
7008 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7009 // Okay, caller handled this option.
7010 } else {
7011 throw new IllegalArgumentException("Unknown option: " + opt);
7012 }
7013 break;
7014 }
7015 }
7016 intent.setDataAndType(data, type);
7017
7018 final boolean hasSelector = intent != baseIntent;
7019 if (hasSelector) {
7020 // A selector was specified; fix up.
7021 baseIntent.setSelector(intent);
7022 intent = baseIntent;
7023 }
7024
7025 String arg = cmd.getNextArg();
7026 baseIntent = null;
7027 if (arg == null) {
7028 if (hasSelector) {
7029 // If a selector has been specified, and no arguments
7030 // have been supplied for the main Intent, then we can
7031 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7032 // need to have a component name specified yet, the
7033 // selector will take care of that.
7034 baseIntent = new Intent(Intent.ACTION_MAIN);
7035 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7036 }
7037 } else if (arg.indexOf(':') >= 0) {
7038 // The argument is a URI. Fully parse it, and use that result
7039 // to fill in any data not specified so far.
7040 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7041 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7042 } else if (arg.indexOf('/') >= 0) {
7043 // The argument is a component name. Build an Intent to launch
7044 // it.
7045 baseIntent = new Intent(Intent.ACTION_MAIN);
7046 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7047 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
7048 } else {
7049 // Assume the argument is a package name.
7050 baseIntent = new Intent(Intent.ACTION_MAIN);
7051 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7052 baseIntent.setPackage(arg);
7053 }
7054 if (baseIntent != null) {
7055 Bundle extras = intent.getExtras();
7056 intent.replaceExtras((Bundle)null);
7057 Bundle uriExtras = baseIntent.getExtras();
7058 baseIntent.replaceExtras((Bundle)null);
7059 if (intent.getAction() != null && baseIntent.getCategories() != null) {
7060 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7061 for (String c : cats) {
7062 baseIntent.removeCategory(c);
7063 }
7064 }
7065 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7066 if (extras == null) {
7067 extras = uriExtras;
7068 } else if (uriExtras != null) {
7069 uriExtras.putAll(extras);
7070 extras = uriExtras;
7071 }
7072 intent.replaceExtras(extras);
7073 hasIntentInfo = true;
7074 }
7075
7076 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7077 return intent;
7078 }
7079
7080 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007081 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007082 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7083 final String[] lines = new String[] {
7084 "<INTENT> specifications include these flags and arguments:",
7085 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
7086 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07007087 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007088 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7089 " [--esn <EXTRA_KEY> ...]",
7090 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7091 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7092 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7093 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7094 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7095 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7096 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7097 " (mutiple extras passed as Integer[])",
7098 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7099 " (mutiple extras passed as List<Integer>)",
7100 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7101 " (mutiple extras passed as Long[])",
7102 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7103 " (mutiple extras passed as List<Long>)",
7104 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7105 " (mutiple extras passed as Float[])",
7106 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7107 " (mutiple extras passed as List<Float>)",
7108 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7109 " (mutiple extras passed as String[]; to embed a comma into a string,",
7110 " escape it using \"\\,\")",
7111 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7112 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7113 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007114 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007115 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7116 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7117 " [--debug-log-resolution] [--exclude-stopped-packages]",
7118 " [--include-stopped-packages]",
7119 " [--activity-brought-to-front] [--activity-clear-top]",
7120 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7121 " [--activity-launched-from-history] [--activity-multiple-task]",
7122 " [--activity-no-animation] [--activity-no-history]",
7123 " [--activity-no-user-action] [--activity-previous-is-top]",
7124 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7125 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007126 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007127 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007128 " [--receiver-foreground] [--receiver-no-abort]",
7129 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007130 " [--selector]",
7131 " [<URI> | <PACKAGE> | <COMPONENT>]"
7132 };
7133 for (String line : lines) {
7134 pw.print(prefix);
7135 pw.println(line);
7136 }
7137 }
7138
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007139 /**
7140 * Retrieve the general action to be performed, such as
7141 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7142 * the information in the intent should be interpreted -- most importantly,
7143 * what to do with the data returned by {@link #getData}.
7144 *
7145 * @return The action of this intent or null if none is specified.
7146 *
7147 * @see #setAction
7148 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007149 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007150 return mAction;
7151 }
7152
7153 /**
7154 * Retrieve data this intent is operating on. This URI specifies the name
7155 * of the data; often it uses the content: scheme, specifying data in a
7156 * content provider. Other schemes may be handled by specific activities,
7157 * such as http: by the web browser.
7158 *
7159 * @return The URI of the data this intent is targeting or null.
7160 *
7161 * @see #getScheme
7162 * @see #setData
7163 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007164 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007165 return mData;
7166 }
7167
7168 /**
7169 * The same as {@link #getData()}, but returns the URI as an encoded
7170 * String.
7171 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007172 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007173 return mData != null ? mData.toString() : null;
7174 }
7175
7176 /**
7177 * Return the scheme portion of the intent's data. If the data is null or
7178 * does not include a scheme, null is returned. Otherwise, the scheme
7179 * prefix without the final ':' is returned, i.e. "http".
7180 *
7181 * <p>This is the same as calling getData().getScheme() (and checking for
7182 * null data).
7183 *
7184 * @return The scheme of this intent.
7185 *
7186 * @see #getData
7187 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007188 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007189 return mData != null ? mData.getScheme() : null;
7190 }
7191
7192 /**
7193 * Retrieve any explicit MIME type included in the intent. This is usually
7194 * null, as the type is determined by the intent data.
7195 *
7196 * @return If a type was manually set, it is returned; else null is
7197 * returned.
7198 *
7199 * @see #resolveType(ContentResolver)
7200 * @see #setType
7201 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007202 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007203 return mType;
7204 }
7205
7206 /**
7207 * Return the MIME data type of this intent. If the type field is
7208 * explicitly set, that is simply returned. Otherwise, if the data is set,
7209 * the type of that data is returned. If neither fields are set, a null is
7210 * returned.
7211 *
7212 * @return The MIME type of this intent.
7213 *
7214 * @see #getType
7215 * @see #resolveType(ContentResolver)
7216 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007217 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007218 return resolveType(context.getContentResolver());
7219 }
7220
7221 /**
7222 * Return the MIME data type of this intent. If the type field is
7223 * explicitly set, that is simply returned. Otherwise, if the data is set,
7224 * the type of that data is returned. If neither fields are set, a null is
7225 * returned.
7226 *
7227 * @param resolver A ContentResolver that can be used to determine the MIME
7228 * type of the intent's data.
7229 *
7230 * @return The MIME type of this intent.
7231 *
7232 * @see #getType
7233 * @see #resolveType(Context)
7234 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007235 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007236 if (mType != null) {
7237 return mType;
7238 }
7239 if (mData != null) {
7240 if ("content".equals(mData.getScheme())) {
7241 return resolver.getType(mData);
7242 }
7243 }
7244 return null;
7245 }
7246
7247 /**
7248 * Return the MIME data type of this intent, only if it will be needed for
7249 * intent resolution. This is not generally useful for application code;
7250 * it is used by the frameworks for communicating with back-end system
7251 * services.
7252 *
7253 * @param resolver A ContentResolver that can be used to determine the MIME
7254 * type of the intent's data.
7255 *
7256 * @return The MIME type of this intent, or null if it is unknown or not
7257 * needed.
7258 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007259 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007260 if (mComponent != null) {
7261 return mType;
7262 }
7263 return resolveType(resolver);
7264 }
7265
7266 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007267 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007268 *
7269 * @param category The category to check.
7270 *
7271 * @return boolean True if the intent contains the category, else false.
7272 *
7273 * @see #getCategories
7274 * @see #addCategory
7275 */
7276 public boolean hasCategory(String category) {
7277 return mCategories != null && mCategories.contains(category);
7278 }
7279
7280 /**
7281 * Return the set of all categories in the intent. If there are no categories,
7282 * returns NULL.
7283 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007284 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007285 *
7286 * @see #hasCategory
7287 * @see #addCategory
7288 */
7289 public Set<String> getCategories() {
7290 return mCategories;
7291 }
7292
7293 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007294 * Return the specific selector associated with this Intent. If there is
7295 * none, returns null. See {@link #setSelector} for more information.
7296 *
7297 * @see #setSelector
7298 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007299 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007300 return mSelector;
7301 }
7302
7303 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007304 * Return the {@link ClipData} associated with this Intent. If there is
7305 * none, returns null. See {@link #setClipData} for more information.
7306 *
John Spurlock125d1332013-11-25 11:58:37 -05007307 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007308 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007309 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007310 return mClipData;
7311 }
7312
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007313 /** @hide */
7314 public int getContentUserHint() {
7315 return mContentUserHint;
7316 }
7317
Todd Kennedyb3b431302017-03-20 16:05:48 -07007318 /** @hide */
7319 public String getLaunchToken() {
7320 return mLaunchToken;
7321 }
7322
7323 /** @hide */
7324 public void setLaunchToken(String launchToken) {
7325 mLaunchToken = launchToken;
7326 }
7327
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007328 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007329 * Sets the ClassLoader that will be used when unmarshalling
7330 * any Parcelable values from the extras of this Intent.
7331 *
7332 * @param loader a ClassLoader, or null to use the default loader
7333 * at the time of unmarshalling.
7334 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007335 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007336 if (mExtras != null) {
7337 mExtras.setClassLoader(loader);
7338 }
7339 }
7340
7341 /**
7342 * Returns true if an extra value is associated with the given name.
7343 * @param name the extra's name
7344 * @return true if the given extra is present.
7345 */
7346 public boolean hasExtra(String name) {
7347 return mExtras != null && mExtras.containsKey(name);
7348 }
7349
7350 /**
7351 * Returns true if the Intent's extras contain a parcelled file descriptor.
7352 * @return true if the Intent contains a parcelled file descriptor.
7353 */
7354 public boolean hasFileDescriptors() {
7355 return mExtras != null && mExtras.hasFileDescriptors();
7356 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007357
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007358 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007359 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007360 public void setAllowFds(boolean allowFds) {
7361 if (mExtras != null) {
7362 mExtras.setAllowFds(allowFds);
7363 }
7364 }
7365
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007366 /** {@hide} */
7367 public void setDefusable(boolean defusable) {
7368 if (mExtras != null) {
7369 mExtras.setDefusable(defusable);
7370 }
7371 }
7372
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007373 /**
7374 * Retrieve extended data from the intent.
7375 *
7376 * @param name The name of the desired item.
7377 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007378 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007379 * or null if none was found.
7380 *
7381 * @deprecated
7382 * @hide
7383 */
7384 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007385 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007386 public Object getExtra(String name) {
7387 return getExtra(name, null);
7388 }
7389
7390 /**
7391 * Retrieve extended data from the intent.
7392 *
7393 * @param name The name of the desired item.
7394 * @param defaultValue the value to be returned if no value of the desired
7395 * type is stored with the given name.
7396 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007397 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007398 * or the default value if none was found.
7399 *
7400 * @see #putExtra(String, boolean)
7401 */
7402 public boolean getBooleanExtra(String name, boolean defaultValue) {
7403 return mExtras == null ? defaultValue :
7404 mExtras.getBoolean(name, defaultValue);
7405 }
7406
7407 /**
7408 * Retrieve extended data from the intent.
7409 *
7410 * @param name The name of the desired item.
7411 * @param defaultValue the value to be returned if no value of the desired
7412 * type is stored with the given name.
7413 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007414 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007415 * or the default value if none was found.
7416 *
7417 * @see #putExtra(String, byte)
7418 */
7419 public byte getByteExtra(String name, byte defaultValue) {
7420 return mExtras == null ? defaultValue :
7421 mExtras.getByte(name, defaultValue);
7422 }
7423
7424 /**
7425 * Retrieve extended data from the intent.
7426 *
7427 * @param name The name of the desired item.
7428 * @param defaultValue the value to be returned if no value of the desired
7429 * type is stored with the given name.
7430 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007431 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007432 * or the default value if none was found.
7433 *
7434 * @see #putExtra(String, short)
7435 */
7436 public short getShortExtra(String name, short defaultValue) {
7437 return mExtras == null ? defaultValue :
7438 mExtras.getShort(name, defaultValue);
7439 }
7440
7441 /**
7442 * Retrieve extended data from the intent.
7443 *
7444 * @param name The name of the desired item.
7445 * @param defaultValue the value to be returned if no value of the desired
7446 * type is stored with the given name.
7447 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007448 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007449 * or the default value if none was found.
7450 *
7451 * @see #putExtra(String, char)
7452 */
7453 public char getCharExtra(String name, char defaultValue) {
7454 return mExtras == null ? defaultValue :
7455 mExtras.getChar(name, defaultValue);
7456 }
7457
7458 /**
7459 * Retrieve extended data from the intent.
7460 *
7461 * @param name The name of the desired item.
7462 * @param defaultValue the value to be returned if no value of the desired
7463 * type is stored with the given name.
7464 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007465 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007466 * or the default value if none was found.
7467 *
7468 * @see #putExtra(String, int)
7469 */
7470 public int getIntExtra(String name, int defaultValue) {
7471 return mExtras == null ? defaultValue :
7472 mExtras.getInt(name, defaultValue);
7473 }
7474
7475 /**
7476 * Retrieve extended data from the intent.
7477 *
7478 * @param name The name of the desired item.
7479 * @param defaultValue the value to be returned if no value of the desired
7480 * type is stored with the given name.
7481 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007482 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007483 * or the default value if none was found.
7484 *
7485 * @see #putExtra(String, long)
7486 */
7487 public long getLongExtra(String name, long defaultValue) {
7488 return mExtras == null ? defaultValue :
7489 mExtras.getLong(name, defaultValue);
7490 }
7491
7492 /**
7493 * Retrieve extended data from the intent.
7494 *
7495 * @param name The name of the desired item.
7496 * @param defaultValue the value to be returned if no value of the desired
7497 * type is stored with the given name.
7498 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007499 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007500 * or the default value if no such item is present
7501 *
7502 * @see #putExtra(String, float)
7503 */
7504 public float getFloatExtra(String name, float defaultValue) {
7505 return mExtras == null ? defaultValue :
7506 mExtras.getFloat(name, defaultValue);
7507 }
7508
7509 /**
7510 * Retrieve extended data from the intent.
7511 *
7512 * @param name The name of the desired item.
7513 * @param defaultValue the value to be returned if no value of the desired
7514 * type is stored with the given name.
7515 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007516 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007517 * or the default value if none was found.
7518 *
7519 * @see #putExtra(String, double)
7520 */
7521 public double getDoubleExtra(String name, double defaultValue) {
7522 return mExtras == null ? defaultValue :
7523 mExtras.getDouble(name, defaultValue);
7524 }
7525
7526 /**
7527 * Retrieve extended data from the intent.
7528 *
7529 * @param name The name of the desired item.
7530 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007531 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007532 * or null if no String value was found.
7533 *
7534 * @see #putExtra(String, String)
7535 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007536 public @Nullable String getStringExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007537 return mExtras == null ? null : mExtras.getString(name);
7538 }
7539
7540 /**
7541 * Retrieve extended data from the intent.
7542 *
7543 * @param name The name of the desired item.
7544 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007545 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007546 * or null if no CharSequence value was found.
7547 *
7548 * @see #putExtra(String, CharSequence)
7549 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007550 public @Nullable CharSequence getCharSequenceExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007551 return mExtras == null ? null : mExtras.getCharSequence(name);
7552 }
7553
7554 /**
7555 * Retrieve extended data from the intent.
7556 *
7557 * @param name The name of the desired item.
7558 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007559 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007560 * or null if no Parcelable value was found.
7561 *
7562 * @see #putExtra(String, Parcelable)
7563 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007564 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007565 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7566 }
7567
7568 /**
7569 * Retrieve extended data from the intent.
7570 *
7571 * @param name The name of the desired item.
7572 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007573 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007574 * or null if no Parcelable[] value was found.
7575 *
7576 * @see #putExtra(String, Parcelable[])
7577 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007578 public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007579 return mExtras == null ? null : mExtras.getParcelableArray(name);
7580 }
7581
7582 /**
7583 * Retrieve extended data from the intent.
7584 *
7585 * @param name The name of the desired item.
7586 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007587 * @return the value of an item previously added with
7588 * putParcelableArrayListExtra(), or null if no
7589 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007590 *
7591 * @see #putParcelableArrayListExtra(String, ArrayList)
7592 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007593 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007594 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7595 }
7596
7597 /**
7598 * Retrieve extended data from the intent.
7599 *
7600 * @param name The name of the desired item.
7601 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007602 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007603 * or null if no Serializable value was found.
7604 *
7605 * @see #putExtra(String, Serializable)
7606 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007607 public @Nullable Serializable getSerializableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007608 return mExtras == null ? null : mExtras.getSerializable(name);
7609 }
7610
7611 /**
7612 * Retrieve extended data from the intent.
7613 *
7614 * @param name The name of the desired item.
7615 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007616 * @return the value of an item previously added with
7617 * putIntegerArrayListExtra(), or null if no
7618 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007619 *
7620 * @see #putIntegerArrayListExtra(String, ArrayList)
7621 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007622 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007623 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7624 }
7625
7626 /**
7627 * Retrieve extended data from the intent.
7628 *
7629 * @param name The name of the desired item.
7630 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007631 * @return the value of an item previously added with
7632 * putStringArrayListExtra(), or null if no
7633 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007634 *
7635 * @see #putStringArrayListExtra(String, ArrayList)
7636 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007637 public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007638 return mExtras == null ? null : mExtras.getStringArrayList(name);
7639 }
7640
7641 /**
7642 * Retrieve extended data from the intent.
7643 *
7644 * @param name The name of the desired item.
7645 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007646 * @return the value of an item previously added with
7647 * putCharSequenceArrayListExtra, or null if no
7648 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007649 *
7650 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7651 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007652 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007653 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7654 }
7655
7656 /**
7657 * Retrieve extended data from the intent.
7658 *
7659 * @param name The name of the desired item.
7660 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007661 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007662 * or null if no boolean array value was found.
7663 *
7664 * @see #putExtra(String, boolean[])
7665 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007666 public @Nullable boolean[] getBooleanArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007667 return mExtras == null ? null : mExtras.getBooleanArray(name);
7668 }
7669
7670 /**
7671 * Retrieve extended data from the intent.
7672 *
7673 * @param name The name of the desired item.
7674 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007675 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007676 * or null if no byte array value was found.
7677 *
7678 * @see #putExtra(String, byte[])
7679 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007680 public @Nullable byte[] getByteArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007681 return mExtras == null ? null : mExtras.getByteArray(name);
7682 }
7683
7684 /**
7685 * Retrieve extended data from the intent.
7686 *
7687 * @param name The name of the desired item.
7688 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007689 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007690 * or null if no short array value was found.
7691 *
7692 * @see #putExtra(String, short[])
7693 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007694 public @Nullable short[] getShortArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007695 return mExtras == null ? null : mExtras.getShortArray(name);
7696 }
7697
7698 /**
7699 * Retrieve extended data from the intent.
7700 *
7701 * @param name The name of the desired item.
7702 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007703 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007704 * or null if no char array value was found.
7705 *
7706 * @see #putExtra(String, char[])
7707 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007708 public @Nullable char[] getCharArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007709 return mExtras == null ? null : mExtras.getCharArray(name);
7710 }
7711
7712 /**
7713 * Retrieve extended data from the intent.
7714 *
7715 * @param name The name of the desired item.
7716 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007717 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007718 * or null if no int array value was found.
7719 *
7720 * @see #putExtra(String, int[])
7721 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007722 public @Nullable int[] getIntArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007723 return mExtras == null ? null : mExtras.getIntArray(name);
7724 }
7725
7726 /**
7727 * Retrieve extended data from the intent.
7728 *
7729 * @param name The name of the desired item.
7730 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007731 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007732 * or null if no long array value was found.
7733 *
7734 * @see #putExtra(String, long[])
7735 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007736 public @Nullable long[] getLongArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007737 return mExtras == null ? null : mExtras.getLongArray(name);
7738 }
7739
7740 /**
7741 * Retrieve extended data from the intent.
7742 *
7743 * @param name The name of the desired item.
7744 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007745 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007746 * or null if no float array value was found.
7747 *
7748 * @see #putExtra(String, float[])
7749 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007750 public @Nullable float[] getFloatArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007751 return mExtras == null ? null : mExtras.getFloatArray(name);
7752 }
7753
7754 /**
7755 * Retrieve extended data from the intent.
7756 *
7757 * @param name The name of the desired item.
7758 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007759 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007760 * or null if no double array value was found.
7761 *
7762 * @see #putExtra(String, double[])
7763 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007764 public @Nullable double[] getDoubleArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007765 return mExtras == null ? null : mExtras.getDoubleArray(name);
7766 }
7767
7768 /**
7769 * Retrieve extended data from the intent.
7770 *
7771 * @param name The name of the desired item.
7772 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007773 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007774 * or null if no String array value was found.
7775 *
7776 * @see #putExtra(String, String[])
7777 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007778 public @Nullable String[] getStringArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007779 return mExtras == null ? null : mExtras.getStringArray(name);
7780 }
7781
7782 /**
7783 * Retrieve extended data from the intent.
7784 *
7785 * @param name The name of the desired item.
7786 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007787 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007788 * or null if no CharSequence array value was found.
7789 *
7790 * @see #putExtra(String, CharSequence[])
7791 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007792 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007793 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7794 }
7795
7796 /**
7797 * Retrieve extended data from the intent.
7798 *
7799 * @param name The name of the desired item.
7800 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007801 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007802 * or null if no Bundle value was found.
7803 *
7804 * @see #putExtra(String, Bundle)
7805 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007806 public @Nullable Bundle getBundleExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007807 return mExtras == null ? null : mExtras.getBundle(name);
7808 }
7809
7810 /**
7811 * Retrieve extended data from the intent.
7812 *
7813 * @param name The name of the desired item.
7814 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007815 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007816 * or null if no IBinder value was found.
7817 *
7818 * @see #putExtra(String, IBinder)
7819 *
7820 * @deprecated
7821 * @hide
7822 */
7823 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007824 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007825 public IBinder getIBinderExtra(String name) {
7826 return mExtras == null ? null : mExtras.getIBinder(name);
7827 }
7828
7829 /**
7830 * Retrieve extended data from the intent.
7831 *
7832 * @param name The name of the desired item.
7833 * @param defaultValue The default value to return in case no item is
7834 * associated with the key 'name'
7835 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007836 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007837 * or defaultValue if none was found.
7838 *
7839 * @see #putExtra
7840 *
7841 * @deprecated
7842 * @hide
7843 */
7844 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007845 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007846 public Object getExtra(String name, Object defaultValue) {
7847 Object result = defaultValue;
7848 if (mExtras != null) {
7849 Object result2 = mExtras.get(name);
7850 if (result2 != null) {
7851 result = result2;
7852 }
7853 }
7854
7855 return result;
7856 }
7857
7858 /**
7859 * Retrieves a map of extended data from the intent.
7860 *
7861 * @return the map of all extras previously added with putExtra(),
7862 * or null if none have been added.
7863 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007864 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007865 return (mExtras != null)
7866 ? new Bundle(mExtras)
7867 : null;
7868 }
7869
7870 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007871 * Filter extras to only basic types.
7872 * @hide
7873 */
7874 public void removeUnsafeExtras() {
7875 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007876 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007877 }
7878 }
7879
7880 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007881 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7882 * return itself as-is.
7883 * @hide
7884 */
7885 public boolean canStripForHistory() {
7886 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7887 }
7888
7889 /**
7890 * Call it when the system needs to keep an intent for logging purposes to remove fields
7891 * that are not needed for logging.
7892 * @hide
7893 */
7894 public Intent maybeStripForHistory() {
7895 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7896
7897 if (!canStripForHistory()) {
7898 return this;
7899 }
7900 return new Intent(this, COPY_MODE_HISTORY);
7901 }
7902
7903 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007904 * Retrieve any special flags associated with this intent. You will
7905 * normally just set them with {@link #setFlags} and let the system
7906 * take the appropriate action with them.
7907 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007908 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007909 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007910 * @see #addFlags
7911 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007912 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007913 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007914 return mFlags;
7915 }
7916
Dianne Hackborne7f97212011-02-24 14:40:20 -08007917 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007918 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08007919 public boolean isExcludingStopped() {
7920 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7921 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7922 }
7923
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007924 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007925 * Retrieve the application package name this Intent is limited to. When
7926 * resolving an Intent, if non-null this limits the resolution to only
7927 * components in the given application package.
7928 *
7929 * @return The name of the application package for the Intent.
7930 *
7931 * @see #resolveActivity
7932 * @see #setPackage
7933 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007934 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007935 return mPackage;
7936 }
7937
7938 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007939 * Retrieve the concrete component associated with the intent. When receiving
7940 * an intent, this is the component that was found to best handle it (that is,
7941 * yourself) and will always be non-null; in all other cases it will be
7942 * null unless explicitly set.
7943 *
7944 * @return The name of the application component to handle the intent.
7945 *
7946 * @see #resolveActivity
7947 * @see #setComponent
7948 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007949 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007950 return mComponent;
7951 }
7952
7953 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007954 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7955 * used as a hint to the receiver for animations and the like. Null means that there
7956 * is no source bounds.
7957 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007958 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007959 return mSourceBounds;
7960 }
7961
7962 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007963 * Return the Activity component that should be used to handle this intent.
7964 * The appropriate component is determined based on the information in the
7965 * intent, evaluated as follows:
7966 *
7967 * <p>If {@link #getComponent} returns an explicit class, that is returned
7968 * without any further consideration.
7969 *
7970 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7971 * category to be considered.
7972 *
7973 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7974 * action.
7975 *
7976 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7977 * this type.
7978 *
7979 * <p>If {@link #addCategory} has added any categories, the activity must
7980 * handle ALL of the categories specified.
7981 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007982 * <p>If {@link #getPackage} is non-NULL, only activity components in
7983 * that application package will be considered.
7984 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007985 * <p>If there are no activities that satisfy all of these conditions, a
7986 * null string is returned.
7987 *
7988 * <p>If multiple activities are found to satisfy the intent, the one with
7989 * the highest priority will be used. If there are multiple activities
7990 * with the same priority, the system will either pick the best activity
7991 * based on user preference, or resolve to a system class that will allow
7992 * the user to pick an activity and forward from there.
7993 *
7994 * <p>This method is implemented simply by calling
7995 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7996 * true.</p>
7997 * <p> This API is called for you as part of starting an activity from an
7998 * intent. You do not normally need to call it yourself.</p>
7999 *
8000 * @param pm The package manager with which to resolve the Intent.
8001 *
8002 * @return Name of the component implementing an activity that can
8003 * display the intent.
8004 *
8005 * @see #setComponent
8006 * @see #getComponent
8007 * @see #resolveActivityInfo
8008 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008009 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008010 if (mComponent != null) {
8011 return mComponent;
8012 }
8013
8014 ResolveInfo info = pm.resolveActivity(
8015 this, PackageManager.MATCH_DEFAULT_ONLY);
8016 if (info != null) {
8017 return new ComponentName(
8018 info.activityInfo.applicationInfo.packageName,
8019 info.activityInfo.name);
8020 }
8021
8022 return null;
8023 }
8024
8025 /**
8026 * Resolve the Intent into an {@link ActivityInfo}
8027 * describing the activity that should execute the intent. Resolution
8028 * follows the same rules as described for {@link #resolveActivity}, but
8029 * you get back the completely information about the resolved activity
8030 * instead of just its class name.
8031 *
8032 * @param pm The package manager with which to resolve the Intent.
8033 * @param flags Addition information to retrieve as per
8034 * {@link PackageManager#getActivityInfo(ComponentName, int)
8035 * PackageManager.getActivityInfo()}.
8036 *
8037 * @return PackageManager.ActivityInfo
8038 *
8039 * @see #resolveActivity
8040 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008041 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
8042 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008043 ActivityInfo ai = null;
8044 if (mComponent != null) {
8045 try {
8046 ai = pm.getActivityInfo(mComponent, flags);
8047 } catch (PackageManager.NameNotFoundException e) {
8048 // ignore
8049 }
8050 } else {
8051 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07008052 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008053 if (info != null) {
8054 ai = info.activityInfo;
8055 }
8056 }
8057
8058 return ai;
8059 }
8060
8061 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07008062 * Special function for use by the system to resolve service
8063 * intents to system apps. Throws an exception if there are
8064 * multiple potential matches to the Intent. Returns null if
8065 * there are no matches.
8066 * @hide
8067 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008068 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008069 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8070 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07008071 if (mComponent != null) {
8072 return mComponent;
8073 }
8074
8075 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8076 if (results == null) {
8077 return null;
8078 }
8079 ComponentName comp = null;
8080 for (int i=0; i<results.size(); i++) {
8081 ResolveInfo ri = results.get(i);
8082 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8083 continue;
8084 }
8085 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8086 ri.serviceInfo.name);
8087 if (comp != null) {
8088 throw new IllegalStateException("Multiple system services handle " + this
8089 + ": " + comp + ", " + foundComp);
8090 }
8091 comp = foundComp;
8092 }
8093 return comp;
8094 }
8095
8096 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008097 * Set the general action to be performed.
8098 *
8099 * @param action An action name, such as ACTION_VIEW. Application-specific
8100 * actions should be prefixed with the vendor's package name.
8101 *
8102 * @return Returns the same Intent object, for chaining multiple calls
8103 * into a single statement.
8104 *
8105 * @see #getAction
8106 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008107 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008108 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008109 return this;
8110 }
8111
8112 /**
8113 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008114 * clears any type that was previously set by {@link #setType} or
8115 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008116 *
Nick Pellyccae4122012-01-09 14:12:58 -08008117 * <p><em>Note: scheme matching in the Android framework is
8118 * case-sensitive, unlike the formal RFC. As a result,
8119 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008120 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008121 * {@link #setDataAndNormalize}
8122 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008123 *
Nick Pellyccae4122012-01-09 14:12:58 -08008124 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008125 *
8126 * @return Returns the same Intent object, for chaining multiple calls
8127 * into a single statement.
8128 *
8129 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008130 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008131 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008132 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008133 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008134 mData = data;
8135 mType = null;
8136 return this;
8137 }
8138
8139 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008140 * Normalize and set the data this intent is operating on.
8141 *
8142 * <p>This method automatically clears any type that was
8143 * previously set (for example, by {@link #setType}).
8144 *
8145 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008146 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008147 * so really this is just a convenience method for
8148 * <pre>
8149 * setData(data.normalize())
8150 * </pre>
8151 *
8152 * @param data The Uri of the data this intent is now targeting.
8153 *
8154 * @return Returns the same Intent object, for chaining multiple calls
8155 * into a single statement.
8156 *
8157 * @see #getData
8158 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008159 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008160 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008161 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008162 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008163 }
8164
8165 /**
8166 * Set an explicit MIME data type.
8167 *
8168 * <p>This is used to create intents that only specify a type and not data,
8169 * for example to indicate the type of data to return.
8170 *
8171 * <p>This method automatically clears any data that was
8172 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008173 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008174 * <p><em>Note: MIME type matching in the Android framework is
8175 * case-sensitive, unlike formal RFC MIME types. As a result,
8176 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008177 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8178 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008179 *
8180 * @param type The MIME type of the data being handled by this intent.
8181 *
8182 * @return Returns the same Intent object, for chaining multiple calls
8183 * into a single statement.
8184 *
8185 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008186 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008187 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008188 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008189 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008190 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008191 mData = null;
8192 mType = type;
8193 return this;
8194 }
8195
8196 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008197 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008198 *
Nick Pellyccae4122012-01-09 14:12:58 -08008199 * <p>This is used to create intents that only specify a type and not data,
8200 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008201 *
Nick Pellyccae4122012-01-09 14:12:58 -08008202 * <p>This method automatically clears any data that was
8203 * previously set (for example by {@link #setData}).
8204 *
8205 * <p>The MIME type is normalized using
8206 * {@link #normalizeMimeType} before it is set,
8207 * so really this is just a convenience method for
8208 * <pre>
8209 * setType(Intent.normalizeMimeType(type))
8210 * </pre>
8211 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008212 * @param type The MIME type of the data being handled by this intent.
8213 *
8214 * @return Returns the same Intent object, for chaining multiple calls
8215 * into a single statement.
8216 *
Nick Pellyccae4122012-01-09 14:12:58 -08008217 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008218 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008219 * @see #normalizeMimeType
8220 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008221 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008222 return setType(normalizeMimeType(type));
8223 }
8224
8225 /**
8226 * (Usually optional) Set the data for the intent along with an explicit
8227 * MIME data type. This method should very rarely be used -- it allows you
8228 * to override the MIME type that would ordinarily be inferred from the
8229 * data with your own type given here.
8230 *
8231 * <p><em>Note: MIME type and Uri scheme matching in the
8232 * Android framework is case-sensitive, unlike the formal RFC definitions.
8233 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008234 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008235 * {@link #setDataAndTypeAndNormalize}
8236 * to ensure that they are converted to lower case.</em>
8237 *
8238 * @param data The Uri of the data this intent is now targeting.
8239 * @param type The MIME type of the data being handled by this intent.
8240 *
8241 * @return Returns the same Intent object, for chaining multiple calls
8242 * into a single statement.
8243 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008244 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008245 * @see #setData
8246 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008247 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008248 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008249 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008250 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008251 mData = data;
8252 mType = type;
8253 return this;
8254 }
8255
8256 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008257 * (Usually optional) Normalize and set both the data Uri and an explicit
8258 * MIME data type. This method should very rarely be used -- it allows you
8259 * to override the MIME type that would ordinarily be inferred from the
8260 * data with your own type given here.
8261 *
8262 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008263 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008264 * before they are set, so really this is just a convenience method for
8265 * <pre>
8266 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8267 * </pre>
8268 *
8269 * @param data The Uri of the data this intent is now targeting.
8270 * @param type The MIME type of the data being handled by this intent.
8271 *
8272 * @return Returns the same Intent object, for chaining multiple calls
8273 * into a single statement.
8274 *
8275 * @see #setType
8276 * @see #setData
8277 * @see #setDataAndType
8278 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008279 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008280 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008281 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008282 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008283 }
8284
8285 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008286 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008287 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008288 * activities that provide <em>all</em> of the requested categories will be
8289 * used.
8290 *
8291 * @param category The desired category. This can be either one of the
8292 * predefined Intent categories, or a custom category in your own
8293 * namespace.
8294 *
8295 * @return Returns the same Intent object, for chaining multiple calls
8296 * into a single statement.
8297 *
8298 * @see #hasCategory
8299 * @see #removeCategory
8300 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008301 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008302 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008303 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008304 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008305 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008306 return this;
8307 }
8308
8309 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008310 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008311 *
8312 * @param category The category to remove.
8313 *
8314 * @see #addCategory
8315 */
8316 public void removeCategory(String category) {
8317 if (mCategories != null) {
8318 mCategories.remove(category);
8319 if (mCategories.size() == 0) {
8320 mCategories = null;
8321 }
8322 }
8323 }
8324
8325 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008326 * Set a selector for this Intent. This is a modification to the kinds of
8327 * things the Intent will match. If the selector is set, it will be used
8328 * when trying to find entities that can handle the Intent, instead of the
8329 * main contents of the Intent. This allows you build an Intent containing
8330 * a generic protocol while targeting it more specifically.
8331 *
8332 * <p>An example of where this may be used is with things like
8333 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8334 * Intent that will launch the Browser application. However, the correct
8335 * main entry point of an application is actually {@link #ACTION_MAIN}
8336 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8337 * used to specify the actual Activity to launch. If you launch the browser
8338 * with something different, undesired behavior may happen if the user has
8339 * previously or later launches it the normal way, since they do not match.
8340 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8341 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8342 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8343 *
8344 * <p>Setting a selector does not impact the behavior of
8345 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8346 * desired behavior of a selector -- it does not impact the base meaning
8347 * of the Intent, just what kinds of things will be matched against it
8348 * when determining who can handle it.</p>
8349 *
8350 * <p>You can not use both a selector and {@link #setPackage(String)} on
8351 * the same base Intent.</p>
8352 *
8353 * @param selector The desired selector Intent; set to null to not use
8354 * a special selector.
8355 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008356 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008357 if (selector == this) {
8358 throw new IllegalArgumentException(
8359 "Intent being set as a selector of itself");
8360 }
8361 if (selector != null && mPackage != null) {
8362 throw new IllegalArgumentException(
8363 "Can't set selector when package name is already set");
8364 }
8365 mSelector = selector;
8366 }
8367
8368 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008369 * Set a {@link ClipData} associated with this Intent. This replaces any
8370 * previously set ClipData.
8371 *
8372 * <p>The ClipData in an intent is not used for Intent matching or other
8373 * such operations. Semantically it is like extras, used to transmit
8374 * additional data with the Intent. The main feature of using this over
8375 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8376 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8377 * items included in the clip data. This is useful, in particular, if
8378 * you want to transmit an Intent containing multiple <code>content:</code>
8379 * URIs for which the recipient may not have global permission to access the
8380 * content provider.
8381 *
8382 * <p>If the ClipData contains items that are themselves Intents, any
8383 * grant flags in those Intents will be ignored. Only the top-level flags
8384 * of the main Intent are respected, and will be applied to all Uri or
8385 * Intent items in the clip (or sub-items of the clip).
8386 *
8387 * <p>The MIME type, label, and icon in the ClipData object are not
8388 * directly used by Intent. Applications should generally rely on the
8389 * MIME type of the Intent itself, not what it may find in the ClipData.
8390 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008391 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008392 *
8393 * @param clip The new clip to set. May be null to clear the current clip.
8394 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008395 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008396 mClipData = clip;
8397 }
8398
8399 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008400 * This is NOT a secure mechanism to identify the user who sent the intent.
8401 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8402 * who sent the intent.
8403 * @hide
8404 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008405 public void prepareToLeaveUser(int userId) {
8406 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8407 // We want mContentUserHint to refer to the original user, so don't do anything.
8408 if (mContentUserHint == UserHandle.USER_CURRENT) {
8409 mContentUserHint = userId;
8410 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008411 }
8412
8413 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008414 * Add extended data to the intent. The name must include a package
8415 * prefix, for example the app com.android.contacts would use names
8416 * like "com.android.contacts.ShowAll".
8417 *
8418 * @param name The name of the extra data, with package prefix.
8419 * @param value The boolean data value.
8420 *
8421 * @return Returns the same Intent object, for chaining multiple calls
8422 * into a single statement.
8423 *
8424 * @see #putExtras
8425 * @see #removeExtra
8426 * @see #getBooleanExtra(String, boolean)
8427 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008428 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008429 if (mExtras == null) {
8430 mExtras = new Bundle();
8431 }
8432 mExtras.putBoolean(name, value);
8433 return this;
8434 }
8435
8436 /**
8437 * Add extended data to the intent. The name must include a package
8438 * prefix, for example the app com.android.contacts would use names
8439 * like "com.android.contacts.ShowAll".
8440 *
8441 * @param name The name of the extra data, with package prefix.
8442 * @param value The byte data value.
8443 *
8444 * @return Returns the same Intent object, for chaining multiple calls
8445 * into a single statement.
8446 *
8447 * @see #putExtras
8448 * @see #removeExtra
8449 * @see #getByteExtra(String, byte)
8450 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008451 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008452 if (mExtras == null) {
8453 mExtras = new Bundle();
8454 }
8455 mExtras.putByte(name, value);
8456 return this;
8457 }
8458
8459 /**
8460 * Add extended data to the intent. The name must include a package
8461 * prefix, for example the app com.android.contacts would use names
8462 * like "com.android.contacts.ShowAll".
8463 *
8464 * @param name The name of the extra data, with package prefix.
8465 * @param value The char data value.
8466 *
8467 * @return Returns the same Intent object, for chaining multiple calls
8468 * into a single statement.
8469 *
8470 * @see #putExtras
8471 * @see #removeExtra
8472 * @see #getCharExtra(String, char)
8473 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008474 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008475 if (mExtras == null) {
8476 mExtras = new Bundle();
8477 }
8478 mExtras.putChar(name, value);
8479 return this;
8480 }
8481
8482 /**
8483 * Add extended data to the intent. The name must include a package
8484 * prefix, for example the app com.android.contacts would use names
8485 * like "com.android.contacts.ShowAll".
8486 *
8487 * @param name The name of the extra data, with package prefix.
8488 * @param value The short data value.
8489 *
8490 * @return Returns the same Intent object, for chaining multiple calls
8491 * into a single statement.
8492 *
8493 * @see #putExtras
8494 * @see #removeExtra
8495 * @see #getShortExtra(String, short)
8496 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008497 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008498 if (mExtras == null) {
8499 mExtras = new Bundle();
8500 }
8501 mExtras.putShort(name, value);
8502 return this;
8503 }
8504
8505 /**
8506 * Add extended data to the intent. The name must include a package
8507 * prefix, for example the app com.android.contacts would use names
8508 * like "com.android.contacts.ShowAll".
8509 *
8510 * @param name The name of the extra data, with package prefix.
8511 * @param value The integer data value.
8512 *
8513 * @return Returns the same Intent object, for chaining multiple calls
8514 * into a single statement.
8515 *
8516 * @see #putExtras
8517 * @see #removeExtra
8518 * @see #getIntExtra(String, int)
8519 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008520 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008521 if (mExtras == null) {
8522 mExtras = new Bundle();
8523 }
8524 mExtras.putInt(name, value);
8525 return this;
8526 }
8527
8528 /**
8529 * Add extended data to the intent. The name must include a package
8530 * prefix, for example the app com.android.contacts would use names
8531 * like "com.android.contacts.ShowAll".
8532 *
8533 * @param name The name of the extra data, with package prefix.
8534 * @param value The long data value.
8535 *
8536 * @return Returns the same Intent object, for chaining multiple calls
8537 * into a single statement.
8538 *
8539 * @see #putExtras
8540 * @see #removeExtra
8541 * @see #getLongExtra(String, long)
8542 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008543 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008544 if (mExtras == null) {
8545 mExtras = new Bundle();
8546 }
8547 mExtras.putLong(name, value);
8548 return this;
8549 }
8550
8551 /**
8552 * Add extended data to the intent. The name must include a package
8553 * prefix, for example the app com.android.contacts would use names
8554 * like "com.android.contacts.ShowAll".
8555 *
8556 * @param name The name of the extra data, with package prefix.
8557 * @param value The float data value.
8558 *
8559 * @return Returns the same Intent object, for chaining multiple calls
8560 * into a single statement.
8561 *
8562 * @see #putExtras
8563 * @see #removeExtra
8564 * @see #getFloatExtra(String, float)
8565 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008566 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008567 if (mExtras == null) {
8568 mExtras = new Bundle();
8569 }
8570 mExtras.putFloat(name, value);
8571 return this;
8572 }
8573
8574 /**
8575 * Add extended data to the intent. The name must include a package
8576 * prefix, for example the app com.android.contacts would use names
8577 * like "com.android.contacts.ShowAll".
8578 *
8579 * @param name The name of the extra data, with package prefix.
8580 * @param value The double data value.
8581 *
8582 * @return Returns the same Intent object, for chaining multiple calls
8583 * into a single statement.
8584 *
8585 * @see #putExtras
8586 * @see #removeExtra
8587 * @see #getDoubleExtra(String, double)
8588 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008589 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008590 if (mExtras == null) {
8591 mExtras = new Bundle();
8592 }
8593 mExtras.putDouble(name, value);
8594 return this;
8595 }
8596
8597 /**
8598 * Add extended data to the intent. The name must include a package
8599 * prefix, for example the app com.android.contacts would use names
8600 * like "com.android.contacts.ShowAll".
8601 *
8602 * @param name The name of the extra data, with package prefix.
8603 * @param value The String data value.
8604 *
8605 * @return Returns the same Intent object, for chaining multiple calls
8606 * into a single statement.
8607 *
8608 * @see #putExtras
8609 * @see #removeExtra
8610 * @see #getStringExtra(String)
8611 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008612 public @NonNull Intent putExtra(String name, @Nullable String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008613 if (mExtras == null) {
8614 mExtras = new Bundle();
8615 }
8616 mExtras.putString(name, value);
8617 return this;
8618 }
8619
8620 /**
8621 * Add extended data to the intent. The name must include a package
8622 * prefix, for example the app com.android.contacts would use names
8623 * like "com.android.contacts.ShowAll".
8624 *
8625 * @param name The name of the extra data, with package prefix.
8626 * @param value The CharSequence data value.
8627 *
8628 * @return Returns the same Intent object, for chaining multiple calls
8629 * into a single statement.
8630 *
8631 * @see #putExtras
8632 * @see #removeExtra
8633 * @see #getCharSequenceExtra(String)
8634 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008635 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008636 if (mExtras == null) {
8637 mExtras = new Bundle();
8638 }
8639 mExtras.putCharSequence(name, value);
8640 return this;
8641 }
8642
8643 /**
8644 * Add extended data to the intent. The name must include a package
8645 * prefix, for example the app com.android.contacts would use names
8646 * like "com.android.contacts.ShowAll".
8647 *
8648 * @param name The name of the extra data, with package prefix.
8649 * @param value The Parcelable data value.
8650 *
8651 * @return Returns the same Intent object, for chaining multiple calls
8652 * into a single statement.
8653 *
8654 * @see #putExtras
8655 * @see #removeExtra
8656 * @see #getParcelableExtra(String)
8657 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008658 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008659 if (mExtras == null) {
8660 mExtras = new Bundle();
8661 }
8662 mExtras.putParcelable(name, value);
8663 return this;
8664 }
8665
8666 /**
8667 * Add extended data to the intent. The name must include a package
8668 * prefix, for example the app com.android.contacts would use names
8669 * like "com.android.contacts.ShowAll".
8670 *
8671 * @param name The name of the extra data, with package prefix.
8672 * @param value The Parcelable[] data value.
8673 *
8674 * @return Returns the same Intent object, for chaining multiple calls
8675 * into a single statement.
8676 *
8677 * @see #putExtras
8678 * @see #removeExtra
8679 * @see #getParcelableArrayExtra(String)
8680 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008681 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008682 if (mExtras == null) {
8683 mExtras = new Bundle();
8684 }
8685 mExtras.putParcelableArray(name, value);
8686 return this;
8687 }
8688
8689 /**
8690 * Add extended data to the intent. The name must include a package
8691 * prefix, for example the app com.android.contacts would use names
8692 * like "com.android.contacts.ShowAll".
8693 *
8694 * @param name The name of the extra data, with package prefix.
8695 * @param value The ArrayList<Parcelable> data value.
8696 *
8697 * @return Returns the same Intent object, for chaining multiple calls
8698 * into a single statement.
8699 *
8700 * @see #putExtras
8701 * @see #removeExtra
8702 * @see #getParcelableArrayListExtra(String)
8703 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008704 public @NonNull Intent putParcelableArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008705 @Nullable ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008706 if (mExtras == null) {
8707 mExtras = new Bundle();
8708 }
8709 mExtras.putParcelableArrayList(name, value);
8710 return this;
8711 }
8712
8713 /**
8714 * Add extended data to the intent. The name must include a package
8715 * prefix, for example the app com.android.contacts would use names
8716 * like "com.android.contacts.ShowAll".
8717 *
8718 * @param name The name of the extra data, with package prefix.
8719 * @param value The ArrayList<Integer> data value.
8720 *
8721 * @return Returns the same Intent object, for chaining multiple calls
8722 * into a single statement.
8723 *
8724 * @see #putExtras
8725 * @see #removeExtra
8726 * @see #getIntegerArrayListExtra(String)
8727 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008728 public @NonNull Intent putIntegerArrayListExtra(String name,
8729 @Nullable ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008730 if (mExtras == null) {
8731 mExtras = new Bundle();
8732 }
8733 mExtras.putIntegerArrayList(name, value);
8734 return this;
8735 }
8736
8737 /**
8738 * Add extended data to the intent. The name must include a package
8739 * prefix, for example the app com.android.contacts would use names
8740 * like "com.android.contacts.ShowAll".
8741 *
8742 * @param name The name of the extra data, with package prefix.
8743 * @param value The ArrayList<String> data value.
8744 *
8745 * @return Returns the same Intent object, for chaining multiple calls
8746 * into a single statement.
8747 *
8748 * @see #putExtras
8749 * @see #removeExtra
8750 * @see #getStringArrayListExtra(String)
8751 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008752 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008753 if (mExtras == null) {
8754 mExtras = new Bundle();
8755 }
8756 mExtras.putStringArrayList(name, value);
8757 return this;
8758 }
8759
8760 /**
8761 * Add extended data to the intent. The name must include a package
8762 * prefix, for example the app com.android.contacts would use names
8763 * like "com.android.contacts.ShowAll".
8764 *
8765 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008766 * @param value The ArrayList<CharSequence> data value.
8767 *
8768 * @return Returns the same Intent object, for chaining multiple calls
8769 * into a single statement.
8770 *
8771 * @see #putExtras
8772 * @see #removeExtra
8773 * @see #getCharSequenceArrayListExtra(String)
8774 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008775 public @NonNull Intent putCharSequenceArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008776 @Nullable ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008777 if (mExtras == null) {
8778 mExtras = new Bundle();
8779 }
8780 mExtras.putCharSequenceArrayList(name, value);
8781 return this;
8782 }
8783
8784 /**
8785 * Add extended data to the intent. The name must include a package
8786 * prefix, for example the app com.android.contacts would use names
8787 * like "com.android.contacts.ShowAll".
8788 *
8789 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008790 * @param value The Serializable data value.
8791 *
8792 * @return Returns the same Intent object, for chaining multiple calls
8793 * into a single statement.
8794 *
8795 * @see #putExtras
8796 * @see #removeExtra
8797 * @see #getSerializableExtra(String)
8798 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008799 public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008800 if (mExtras == null) {
8801 mExtras = new Bundle();
8802 }
8803 mExtras.putSerializable(name, value);
8804 return this;
8805 }
8806
8807 /**
8808 * Add extended data to the intent. The name must include a package
8809 * prefix, for example the app com.android.contacts would use names
8810 * like "com.android.contacts.ShowAll".
8811 *
8812 * @param name The name of the extra data, with package prefix.
8813 * @param value The boolean array data value.
8814 *
8815 * @return Returns the same Intent object, for chaining multiple calls
8816 * into a single statement.
8817 *
8818 * @see #putExtras
8819 * @see #removeExtra
8820 * @see #getBooleanArrayExtra(String)
8821 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008822 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008823 if (mExtras == null) {
8824 mExtras = new Bundle();
8825 }
8826 mExtras.putBooleanArray(name, value);
8827 return this;
8828 }
8829
8830 /**
8831 * Add extended data to the intent. The name must include a package
8832 * prefix, for example the app com.android.contacts would use names
8833 * like "com.android.contacts.ShowAll".
8834 *
8835 * @param name The name of the extra data, with package prefix.
8836 * @param value The byte array data value.
8837 *
8838 * @return Returns the same Intent object, for chaining multiple calls
8839 * into a single statement.
8840 *
8841 * @see #putExtras
8842 * @see #removeExtra
8843 * @see #getByteArrayExtra(String)
8844 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008845 public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008846 if (mExtras == null) {
8847 mExtras = new Bundle();
8848 }
8849 mExtras.putByteArray(name, value);
8850 return this;
8851 }
8852
8853 /**
8854 * Add extended data to the intent. The name must include a package
8855 * prefix, for example the app com.android.contacts would use names
8856 * like "com.android.contacts.ShowAll".
8857 *
8858 * @param name The name of the extra data, with package prefix.
8859 * @param value The short array data value.
8860 *
8861 * @return Returns the same Intent object, for chaining multiple calls
8862 * into a single statement.
8863 *
8864 * @see #putExtras
8865 * @see #removeExtra
8866 * @see #getShortArrayExtra(String)
8867 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008868 public @NonNull Intent putExtra(String name, @Nullable short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008869 if (mExtras == null) {
8870 mExtras = new Bundle();
8871 }
8872 mExtras.putShortArray(name, value);
8873 return this;
8874 }
8875
8876 /**
8877 * Add extended data to the intent. The name must include a package
8878 * prefix, for example the app com.android.contacts would use names
8879 * like "com.android.contacts.ShowAll".
8880 *
8881 * @param name The name of the extra data, with package prefix.
8882 * @param value The char array data value.
8883 *
8884 * @return Returns the same Intent object, for chaining multiple calls
8885 * into a single statement.
8886 *
8887 * @see #putExtras
8888 * @see #removeExtra
8889 * @see #getCharArrayExtra(String)
8890 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008891 public @NonNull Intent putExtra(String name, @Nullable char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008892 if (mExtras == null) {
8893 mExtras = new Bundle();
8894 }
8895 mExtras.putCharArray(name, value);
8896 return this;
8897 }
8898
8899 /**
8900 * Add extended data to the intent. The name must include a package
8901 * prefix, for example the app com.android.contacts would use names
8902 * like "com.android.contacts.ShowAll".
8903 *
8904 * @param name The name of the extra data, with package prefix.
8905 * @param value The int array data value.
8906 *
8907 * @return Returns the same Intent object, for chaining multiple calls
8908 * into a single statement.
8909 *
8910 * @see #putExtras
8911 * @see #removeExtra
8912 * @see #getIntArrayExtra(String)
8913 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008914 public @NonNull Intent putExtra(String name, @Nullable int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008915 if (mExtras == null) {
8916 mExtras = new Bundle();
8917 }
8918 mExtras.putIntArray(name, value);
8919 return this;
8920 }
8921
8922 /**
8923 * Add extended data to the intent. The name must include a package
8924 * prefix, for example the app com.android.contacts would use names
8925 * like "com.android.contacts.ShowAll".
8926 *
8927 * @param name The name of the extra data, with package prefix.
8928 * @param value The byte array data value.
8929 *
8930 * @return Returns the same Intent object, for chaining multiple calls
8931 * into a single statement.
8932 *
8933 * @see #putExtras
8934 * @see #removeExtra
8935 * @see #getLongArrayExtra(String)
8936 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008937 public @NonNull Intent putExtra(String name, @Nullable long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008938 if (mExtras == null) {
8939 mExtras = new Bundle();
8940 }
8941 mExtras.putLongArray(name, value);
8942 return this;
8943 }
8944
8945 /**
8946 * Add extended data to the intent. The name must include a package
8947 * prefix, for example the app com.android.contacts would use names
8948 * like "com.android.contacts.ShowAll".
8949 *
8950 * @param name The name of the extra data, with package prefix.
8951 * @param value The float array data value.
8952 *
8953 * @return Returns the same Intent object, for chaining multiple calls
8954 * into a single statement.
8955 *
8956 * @see #putExtras
8957 * @see #removeExtra
8958 * @see #getFloatArrayExtra(String)
8959 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008960 public @NonNull Intent putExtra(String name, @Nullable float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008961 if (mExtras == null) {
8962 mExtras = new Bundle();
8963 }
8964 mExtras.putFloatArray(name, value);
8965 return this;
8966 }
8967
8968 /**
8969 * Add extended data to the intent. The name must include a package
8970 * prefix, for example the app com.android.contacts would use names
8971 * like "com.android.contacts.ShowAll".
8972 *
8973 * @param name The name of the extra data, with package prefix.
8974 * @param value The double array data value.
8975 *
8976 * @return Returns the same Intent object, for chaining multiple calls
8977 * into a single statement.
8978 *
8979 * @see #putExtras
8980 * @see #removeExtra
8981 * @see #getDoubleArrayExtra(String)
8982 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008983 public @NonNull Intent putExtra(String name, @Nullable double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008984 if (mExtras == null) {
8985 mExtras = new Bundle();
8986 }
8987 mExtras.putDoubleArray(name, value);
8988 return this;
8989 }
8990
8991 /**
8992 * Add extended data to the intent. The name must include a package
8993 * prefix, for example the app com.android.contacts would use names
8994 * like "com.android.contacts.ShowAll".
8995 *
8996 * @param name The name of the extra data, with package prefix.
8997 * @param value The String array data value.
8998 *
8999 * @return Returns the same Intent object, for chaining multiple calls
9000 * into a single statement.
9001 *
9002 * @see #putExtras
9003 * @see #removeExtra
9004 * @see #getStringArrayExtra(String)
9005 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009006 public @NonNull Intent putExtra(String name, @Nullable String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009007 if (mExtras == null) {
9008 mExtras = new Bundle();
9009 }
9010 mExtras.putStringArray(name, value);
9011 return this;
9012 }
9013
9014 /**
9015 * Add extended data to the intent. The name must include a package
9016 * prefix, for example the app com.android.contacts would use names
9017 * like "com.android.contacts.ShowAll".
9018 *
9019 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009020 * @param value The CharSequence array data value.
9021 *
9022 * @return Returns the same Intent object, for chaining multiple calls
9023 * into a single statement.
9024 *
9025 * @see #putExtras
9026 * @see #removeExtra
9027 * @see #getCharSequenceArrayExtra(String)
9028 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009029 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009030 if (mExtras == null) {
9031 mExtras = new Bundle();
9032 }
9033 mExtras.putCharSequenceArray(name, value);
9034 return this;
9035 }
9036
9037 /**
9038 * Add extended data to the intent. The name must include a package
9039 * prefix, for example the app com.android.contacts would use names
9040 * like "com.android.contacts.ShowAll".
9041 *
9042 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009043 * @param value The Bundle data value.
9044 *
9045 * @return Returns the same Intent object, for chaining multiple calls
9046 * into a single statement.
9047 *
9048 * @see #putExtras
9049 * @see #removeExtra
9050 * @see #getBundleExtra(String)
9051 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009052 public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009053 if (mExtras == null) {
9054 mExtras = new Bundle();
9055 }
9056 mExtras.putBundle(name, value);
9057 return this;
9058 }
9059
9060 /**
9061 * Add extended data to the intent. The name must include a package
9062 * prefix, for example the app com.android.contacts would use names
9063 * like "com.android.contacts.ShowAll".
9064 *
9065 * @param name The name of the extra data, with package prefix.
9066 * @param value The IBinder data value.
9067 *
9068 * @return Returns the same Intent object, for chaining multiple calls
9069 * into a single statement.
9070 *
9071 * @see #putExtras
9072 * @see #removeExtra
9073 * @see #getIBinderExtra(String)
9074 *
9075 * @deprecated
9076 * @hide
9077 */
9078 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009079 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009080 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009081 if (mExtras == null) {
9082 mExtras = new Bundle();
9083 }
9084 mExtras.putIBinder(name, value);
9085 return this;
9086 }
9087
9088 /**
9089 * Copy all extras in 'src' in to this intent.
9090 *
9091 * @param src Contains the extras to copy.
9092 *
9093 * @see #putExtra
9094 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009095 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009096 if (src.mExtras != null) {
9097 if (mExtras == null) {
9098 mExtras = new Bundle(src.mExtras);
9099 } else {
9100 mExtras.putAll(src.mExtras);
9101 }
9102 }
9103 return this;
9104 }
9105
9106 /**
9107 * Add a set of extended data to the intent. The keys must include a package
9108 * prefix, for example the app com.android.contacts would use names
9109 * like "com.android.contacts.ShowAll".
9110 *
9111 * @param extras The Bundle of extras to add to this intent.
9112 *
9113 * @see #putExtra
9114 * @see #removeExtra
9115 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009116 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009117 if (mExtras == null) {
9118 mExtras = new Bundle();
9119 }
9120 mExtras.putAll(extras);
9121 return this;
9122 }
9123
9124 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009125 * Completely replace the extras in the Intent with the extras in the
9126 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009127 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009128 * @param src The exact extras contained in this Intent are copied
9129 * into the target intent, replacing any that were previously there.
9130 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009131 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009132 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9133 return this;
9134 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009135
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009136 /**
9137 * Completely replace the extras in the Intent with the given Bundle of
9138 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009139 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009140 * @param extras The new set of extras in the Intent, or null to erase
9141 * all extras.
9142 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009143 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009144 mExtras = extras != null ? new Bundle(extras) : null;
9145 return this;
9146 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009147
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009148 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009149 * Remove extended data from the intent.
9150 *
9151 * @see #putExtra
9152 */
9153 public void removeExtra(String name) {
9154 if (mExtras != null) {
9155 mExtras.remove(name);
9156 if (mExtras.size() == 0) {
9157 mExtras = null;
9158 }
9159 }
9160 }
9161
9162 /**
9163 * Set special flags controlling how this intent is handled. Most values
9164 * here depend on the type of component being executed by the Intent,
9165 * specifically the FLAG_ACTIVITY_* flags are all for use with
9166 * {@link Context#startActivity Context.startActivity()} and the
9167 * FLAG_RECEIVER_* flags are all for use with
9168 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9169 *
Scott Main7aee61f2011-02-08 11:25:01 -08009170 * <p>See the
9171 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9172 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009173 * the behavior of your application.
9174 *
9175 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009176 * @return Returns the same Intent object, for chaining multiple calls
9177 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009178 * @see #getFlags
9179 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009180 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009181 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009182 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009183 mFlags = flags;
9184 return this;
9185 }
9186
9187 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009188 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009189 *
9190 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009191 * @return Returns the same Intent object, for chaining multiple calls into
9192 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009193 * @see #setFlags
9194 * @see #getFlags
9195 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009196 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009197 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009198 mFlags |= flags;
9199 return this;
9200 }
9201
9202 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009203 * Remove these flags from the intent.
9204 *
9205 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009206 * @see #setFlags
9207 * @see #getFlags
9208 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009209 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009210 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009211 mFlags &= ~flags;
9212 }
9213
9214 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009215 * (Usually optional) Set an explicit application package name that limits
9216 * the components this Intent will resolve to. If left to the default
9217 * value of null, all components in all applications will considered.
9218 * If non-null, the Intent can only match the components in the given
9219 * application package.
9220 *
9221 * @param packageName The name of the application package to handle the
9222 * intent, or null to allow any application package.
9223 *
9224 * @return Returns the same Intent object, for chaining multiple calls
9225 * into a single statement.
9226 *
9227 * @see #getPackage
9228 * @see #resolveActivity
9229 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009230 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009231 if (packageName != null && mSelector != null) {
9232 throw new IllegalArgumentException(
9233 "Can't set package name when selector is already set");
9234 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009235 mPackage = packageName;
9236 return this;
9237 }
9238
9239 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009240 * (Usually optional) Explicitly set the component to handle the intent.
9241 * If left with the default value of null, the system will determine the
9242 * appropriate class to use based on the other fields (action, data,
9243 * type, categories) in the Intent. If this class is defined, the
9244 * specified class will always be used regardless of the other fields. You
9245 * should only set this value when you know you absolutely want a specific
9246 * class to be used; otherwise it is better to let the system find the
9247 * appropriate class so that you will respect the installed applications
9248 * and user preferences.
9249 *
9250 * @param component The name of the application component to handle the
9251 * intent, or null to let the system find one for you.
9252 *
9253 * @return Returns the same Intent object, for chaining multiple calls
9254 * into a single statement.
9255 *
9256 * @see #setClass
9257 * @see #setClassName(Context, String)
9258 * @see #setClassName(String, String)
9259 * @see #getComponent
9260 * @see #resolveActivity
9261 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009262 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009263 mComponent = component;
9264 return this;
9265 }
9266
9267 /**
9268 * Convenience for calling {@link #setComponent} with an
9269 * explicit class name.
9270 *
9271 * @param packageContext A Context of the application package implementing
9272 * this class.
9273 * @param className The name of a class inside of the application package
9274 * that will be used as the component for this Intent.
9275 *
9276 * @return Returns the same Intent object, for chaining multiple calls
9277 * into a single statement.
9278 *
9279 * @see #setComponent
9280 * @see #setClass
9281 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009282 public @NonNull Intent setClassName(@NonNull Context packageContext,
9283 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009284 mComponent = new ComponentName(packageContext, className);
9285 return this;
9286 }
9287
9288 /**
9289 * Convenience for calling {@link #setComponent} with an
9290 * explicit application package name and class name.
9291 *
9292 * @param packageName The name of the package implementing the desired
9293 * component.
9294 * @param className The name of a class inside of the application package
9295 * that will be used as the component for this Intent.
9296 *
9297 * @return Returns the same Intent object, for chaining multiple calls
9298 * into a single statement.
9299 *
9300 * @see #setComponent
9301 * @see #setClass
9302 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009303 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009304 mComponent = new ComponentName(packageName, className);
9305 return this;
9306 }
9307
9308 /**
9309 * Convenience for calling {@link #setComponent(ComponentName)} with the
9310 * name returned by a {@link Class} object.
9311 *
9312 * @param packageContext A Context of the application package implementing
9313 * this class.
9314 * @param cls The class name to set, equivalent to
9315 * <code>setClassName(context, cls.getName())</code>.
9316 *
9317 * @return Returns the same Intent object, for chaining multiple calls
9318 * into a single statement.
9319 *
9320 * @see #setComponent
9321 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009322 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009323 mComponent = new ComponentName(packageContext, cls);
9324 return this;
9325 }
9326
9327 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009328 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9329 * used as a hint to the receiver for animations and the like. Null means that there
9330 * is no source bounds.
9331 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009332 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009333 if (r != null) {
9334 mSourceBounds = new Rect(r);
9335 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009336 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009337 }
9338 }
9339
Tor Norbyed9273d62013-05-30 15:59:53 -07009340 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009341 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9342 FILL_IN_ACTION,
9343 FILL_IN_DATA,
9344 FILL_IN_CATEGORIES,
9345 FILL_IN_COMPONENT,
9346 FILL_IN_PACKAGE,
9347 FILL_IN_SOURCE_BOUNDS,
9348 FILL_IN_SELECTOR,
9349 FILL_IN_CLIP_DATA
9350 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009351 @Retention(RetentionPolicy.SOURCE)
9352 public @interface FillInFlags {}
9353
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009354 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009355 * Use with {@link #fillIn} to allow the current action value to be
9356 * overwritten, even if it is already set.
9357 */
9358 public static final int FILL_IN_ACTION = 1<<0;
9359
9360 /**
9361 * Use with {@link #fillIn} to allow the current data or type value
9362 * overwritten, even if it is already set.
9363 */
9364 public static final int FILL_IN_DATA = 1<<1;
9365
9366 /**
9367 * Use with {@link #fillIn} to allow the current categories to be
9368 * overwritten, even if they are already set.
9369 */
9370 public static final int FILL_IN_CATEGORIES = 1<<2;
9371
9372 /**
9373 * Use with {@link #fillIn} to allow the current component value to be
9374 * overwritten, even if it is already set.
9375 */
9376 public static final int FILL_IN_COMPONENT = 1<<3;
9377
9378 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009379 * Use with {@link #fillIn} to allow the current package value to be
9380 * overwritten, even if it is already set.
9381 */
9382 public static final int FILL_IN_PACKAGE = 1<<4;
9383
9384 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009385 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009386 * overwritten, even if it is already set.
9387 */
9388 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9389
9390 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009391 * Use with {@link #fillIn} to allow the current selector to be
9392 * overwritten, even if it is already set.
9393 */
9394 public static final int FILL_IN_SELECTOR = 1<<6;
9395
9396 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009397 * Use with {@link #fillIn} to allow the current ClipData to be
9398 * overwritten, even if it is already set.
9399 */
9400 public static final int FILL_IN_CLIP_DATA = 1<<7;
9401
9402 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009403 * Copy the contents of <var>other</var> in to this object, but only
9404 * where fields are not defined by this object. For purposes of a field
9405 * being defined, the following pieces of data in the Intent are
9406 * considered to be separate fields:
9407 *
9408 * <ul>
9409 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009410 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009411 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9412 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009413 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009414 * <li> component, as set by {@link #setComponent(ComponentName)} or
9415 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009416 * <li> source bounds, as set by {@link #setSourceBounds}.
9417 * <li> selector, as set by {@link #setSelector(Intent)}.
9418 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009419 * <li> each top-level name in the associated extras.
9420 * </ul>
9421 *
9422 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009423 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009424 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9425 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9426 * the restriction where the corresponding field will not be replaced if
9427 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009428 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009429 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9430 * is explicitly specified. The selector will only be copied if
9431 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009432 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009433 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9434 * and Intent B with {action="gotit", data-type="some/thing",
9435 * categories="one","two"}.
9436 *
9437 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9438 * containing: {action="gotit", data-type="some/thing",
9439 * categories="bar"}.
9440 *
9441 * @param other Another Intent whose values are to be used to fill in
9442 * the current one.
9443 * @param flags Options to control which fields can be filled in.
9444 *
9445 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009446 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009447 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009448 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009449 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009450 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009451 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009452 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009453 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009454 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009455 if (other.mAction != null
9456 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009457 mAction = other.mAction;
9458 changes |= FILL_IN_ACTION;
9459 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009460 if ((other.mData != null || other.mType != null)
9461 && ((mData == null && mType == null)
9462 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009463 mData = other.mData;
9464 mType = other.mType;
9465 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009466 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009467 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009468 if (other.mCategories != null
9469 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009470 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009471 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009472 }
9473 changes |= FILL_IN_CATEGORIES;
9474 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009475 if (other.mPackage != null
9476 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009477 // Only do this if mSelector is not set.
9478 if (mSelector == null) {
9479 mPackage = other.mPackage;
9480 changes |= FILL_IN_PACKAGE;
9481 }
9482 }
9483 // Selector is special: it can only be set if explicitly allowed,
9484 // for the same reason as the component name.
9485 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9486 if (mPackage == null) {
9487 mSelector = new Intent(other.mSelector);
9488 mPackage = null;
9489 changes |= FILL_IN_SELECTOR;
9490 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009491 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009492 if (other.mClipData != null
9493 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9494 mClipData = other.mClipData;
9495 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009496 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009497 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009498 // Component is special: it can -only- be set if explicitly allowed,
9499 // since otherwise the sender could force the intent somewhere the
9500 // originator didn't intend.
9501 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009502 mComponent = other.mComponent;
9503 changes |= FILL_IN_COMPONENT;
9504 }
9505 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009506 if (other.mSourceBounds != null
9507 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9508 mSourceBounds = new Rect(other.mSourceBounds);
9509 changes |= FILL_IN_SOURCE_BOUNDS;
9510 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009511 if (mExtras == null) {
9512 if (other.mExtras != null) {
9513 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009514 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009515 }
9516 } else if (other.mExtras != null) {
9517 try {
9518 Bundle newb = new Bundle(other.mExtras);
9519 newb.putAll(mExtras);
9520 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009521 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009522 } catch (RuntimeException e) {
9523 // Modifying the extras can cause us to unparcel the contents
9524 // of the bundle, and if we do this in the system process that
9525 // may fail. We really should handle this (i.e., the Bundle
9526 // impl shouldn't be on top of a plain map), but for now just
9527 // ignore it and keep the original contents. :(
9528 Log.w("Intent", "Failure filling in extras", e);
9529 }
9530 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009531 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9532 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9533 mContentUserHint = other.mContentUserHint;
9534 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009535 return changes;
9536 }
9537
9538 /**
9539 * Wrapper class holding an Intent and implementing comparisons on it for
9540 * the purpose of filtering. The class implements its
9541 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9542 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9543 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9544 * on the wrapped Intent.
9545 */
9546 public static final class FilterComparison {
9547 private final Intent mIntent;
9548 private final int mHashCode;
9549
9550 public FilterComparison(Intent intent) {
9551 mIntent = intent;
9552 mHashCode = intent.filterHashCode();
9553 }
9554
9555 /**
9556 * Return the Intent that this FilterComparison represents.
9557 * @return Returns the Intent held by the FilterComparison. Do
9558 * not modify!
9559 */
9560 public Intent getIntent() {
9561 return mIntent;
9562 }
9563
9564 @Override
9565 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009566 if (obj instanceof FilterComparison) {
9567 Intent other = ((FilterComparison)obj).mIntent;
9568 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009569 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009570 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009571 }
9572
9573 @Override
9574 public int hashCode() {
9575 return mHashCode;
9576 }
9577 }
9578
9579 /**
9580 * Determine if two intents are the same for the purposes of intent
9581 * resolution (filtering). That is, if their action, data, type,
9582 * class, and categories are the same. This does <em>not</em> compare
9583 * any extra data included in the intents.
9584 *
9585 * @param other The other Intent to compare against.
9586 *
9587 * @return Returns true if action, data, type, class, and categories
9588 * are the same.
9589 */
9590 public boolean filterEquals(Intent other) {
9591 if (other == null) {
9592 return false;
9593 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009594 if (!Objects.equals(this.mAction, other.mAction)) return false;
9595 if (!Objects.equals(this.mData, other.mData)) return false;
9596 if (!Objects.equals(this.mType, other.mType)) return false;
9597 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9598 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9599 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009600
9601 return true;
9602 }
9603
9604 /**
9605 * Generate hash code that matches semantics of filterEquals().
9606 *
9607 * @return Returns the hash value of the action, data, type, class, and
9608 * categories.
9609 *
9610 * @see #filterEquals
9611 */
9612 public int filterHashCode() {
9613 int code = 0;
9614 if (mAction != null) {
9615 code += mAction.hashCode();
9616 }
9617 if (mData != null) {
9618 code += mData.hashCode();
9619 }
9620 if (mType != null) {
9621 code += mType.hashCode();
9622 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009623 if (mPackage != null) {
9624 code += mPackage.hashCode();
9625 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009626 if (mComponent != null) {
9627 code += mComponent.hashCode();
9628 }
9629 if (mCategories != null) {
9630 code += mCategories.hashCode();
9631 }
9632 return code;
9633 }
9634
9635 @Override
9636 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009637 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009638
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009639 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009640 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009641 b.append(" }");
9642
9643 return b.toString();
9644 }
9645
9646 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009647 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009648 public String toInsecureString() {
9649 StringBuilder b = new StringBuilder(128);
9650
9651 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009652 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009653 b.append(" }");
9654
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009655 return b.toString();
9656 }
Romain Guy4969af72009-06-17 10:53:19 -07009657
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009658 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009659 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009660 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009661
9662 b.append("Intent { ");
9663 toShortString(b, false, true, true, true);
9664 b.append(" }");
9665
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009666 return b.toString();
9667 }
9668
9669 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009670 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9671 StringBuilder b = new StringBuilder(128);
9672 toShortString(b, secure, comp, extras, clip);
9673 return b.toString();
9674 }
9675
9676 /** @hide */
9677 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9678 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009679 boolean first = true;
9680 if (mAction != null) {
9681 b.append("act=").append(mAction);
9682 first = false;
9683 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009684 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009685 if (!first) {
9686 b.append(' ');
9687 }
9688 first = false;
9689 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009690 for (int i=0; i<mCategories.size(); i++) {
9691 if (i > 0) b.append(',');
9692 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009693 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009694 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009695 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009696 if (mData != null) {
9697 if (!first) {
9698 b.append(' ');
9699 }
9700 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009701 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009702 if (secure) {
9703 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009704 } else {
9705 b.append(mData);
9706 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009707 }
9708 if (mType != null) {
9709 if (!first) {
9710 b.append(' ');
9711 }
9712 first = false;
9713 b.append("typ=").append(mType);
9714 }
9715 if (mFlags != 0) {
9716 if (!first) {
9717 b.append(' ');
9718 }
9719 first = false;
9720 b.append("flg=0x").append(Integer.toHexString(mFlags));
9721 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009722 if (mPackage != null) {
9723 if (!first) {
9724 b.append(' ');
9725 }
9726 first = false;
9727 b.append("pkg=").append(mPackage);
9728 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009729 if (comp && mComponent != null) {
9730 if (!first) {
9731 b.append(' ');
9732 }
9733 first = false;
9734 b.append("cmp=").append(mComponent.flattenToShortString());
9735 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009736 if (mSourceBounds != null) {
9737 if (!first) {
9738 b.append(' ');
9739 }
9740 first = false;
9741 b.append("bnds=").append(mSourceBounds.toShortString());
9742 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009743 if (mClipData != null) {
9744 if (!first) {
9745 b.append(' ');
9746 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009747 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009748 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009749 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009750 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009751 if (mClipData.getDescription() != null) {
9752 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9753 } else {
9754 first = true;
9755 }
9756 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009757 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009758 first = false;
9759 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009760 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009761 if (extras && mExtras != null) {
9762 if (!first) {
9763 b.append(' ');
9764 }
9765 first = false;
9766 b.append("(has extras)");
9767 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009768 if (mContentUserHint != UserHandle.USER_CURRENT) {
9769 if (!first) {
9770 b.append(' ');
9771 }
9772 first = false;
9773 b.append("u=").append(mContentUserHint);
9774 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009775 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009776 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009777 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009778 b.append("}");
9779 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009780 }
9781
Yi Jin129fc6c2017-09-28 15:48:38 -07009782 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009783 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9784 // Same input parameters that toString() gives to toShortString().
9785 writeToProto(proto, fieldId, true, true, true, false);
9786 }
9787
9788 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009789 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9790 boolean extras, boolean clip) {
9791 long token = proto.start(fieldId);
9792 if (mAction != null) {
9793 proto.write(IntentProto.ACTION, mAction);
9794 }
9795 if (mCategories != null) {
9796 for (String category : mCategories) {
9797 proto.write(IntentProto.CATEGORIES, category);
9798 }
9799 }
9800 if (mData != null) {
9801 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9802 }
9803 if (mType != null) {
9804 proto.write(IntentProto.TYPE, mType);
9805 }
9806 if (mFlags != 0) {
9807 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9808 }
9809 if (mPackage != null) {
9810 proto.write(IntentProto.PACKAGE, mPackage);
9811 }
9812 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009813 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009814 }
9815 if (mSourceBounds != null) {
9816 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9817 }
9818 if (mClipData != null) {
9819 StringBuilder b = new StringBuilder();
9820 if (clip) {
9821 mClipData.toShortString(b);
9822 } else {
9823 mClipData.toShortStringShortItems(b, false);
9824 }
9825 proto.write(IntentProto.CLIP_DATA, b.toString());
9826 }
9827 if (extras && mExtras != null) {
9828 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9829 }
9830 if (mContentUserHint != 0) {
9831 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9832 }
9833 if (mSelector != null) {
9834 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9835 }
9836 proto.end(token);
9837 }
9838
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009839 /**
9840 * Call {@link #toUri} with 0 flags.
9841 * @deprecated Use {@link #toUri} instead.
9842 */
9843 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009844 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009845 return toUri(0);
9846 }
9847
9848 /**
9849 * Convert this Intent into a String holding a URI representation of it.
9850 * The returned URI string has been properly URI encoded, so it can be
9851 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9852 * Intent's data as the base URI, with an additional fragment describing
9853 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009854 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009855 * <p>You can convert the returned string back to an Intent with
9856 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009857 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009858 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009859 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009860 * @return Returns a URI encoding URI string describing the entire contents
9861 * of the Intent.
9862 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009863 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009864 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009865 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9866 if (mPackage == null) {
9867 throw new IllegalArgumentException(
9868 "Intent must include an explicit package name to build an android-app: "
9869 + this);
9870 }
9871 uri.append("android-app://");
9872 uri.append(mPackage);
9873 String scheme = null;
9874 if (mData != null) {
9875 scheme = mData.getScheme();
9876 if (scheme != null) {
9877 uri.append('/');
9878 uri.append(scheme);
9879 String authority = mData.getEncodedAuthority();
9880 if (authority != null) {
9881 uri.append('/');
9882 uri.append(authority);
9883 String path = mData.getEncodedPath();
9884 if (path != null) {
9885 uri.append(path);
9886 }
9887 String queryParams = mData.getEncodedQuery();
9888 if (queryParams != null) {
9889 uri.append('?');
9890 uri.append(queryParams);
9891 }
9892 String fragment = mData.getEncodedFragment();
9893 if (fragment != null) {
9894 uri.append('#');
9895 uri.append(fragment);
9896 }
9897 }
9898 }
9899 }
9900 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9901 mPackage, flags);
9902 return uri.toString();
9903 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009904 String scheme = null;
9905 if (mData != null) {
9906 String data = mData.toString();
9907 if ((flags&URI_INTENT_SCHEME) != 0) {
9908 final int N = data.length();
9909 for (int i=0; i<N; i++) {
9910 char c = data.charAt(i);
9911 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009912 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009913 continue;
9914 }
9915 if (c == ':' && i > 0) {
9916 // Valid scheme.
9917 scheme = data.substring(0, i);
9918 uri.append("intent:");
9919 data = data.substring(i+1);
9920 break;
9921 }
Tom Taylord4a47292009-12-21 13:59:18 -08009922
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009923 // No scheme.
9924 break;
9925 }
9926 }
9927 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009928
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009929 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9930 uri.append("intent:");
9931 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009932
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009933 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009934
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009935 return uri.toString();
9936 }
9937
9938 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9939 String defPackage, int flags) {
9940 StringBuilder frag = new StringBuilder(128);
9941
9942 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009943 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009944 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009945 // Note that for now we are not going to try to handle the
9946 // data part; not clear how to represent this as a URI, and
9947 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009948 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9949 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009950 }
9951
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009952 if (frag.length() > 0) {
9953 uri.append("#Intent;");
9954 uri.append(frag);
9955 uri.append("end");
9956 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009957 }
9958
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009959 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9960 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009961 if (scheme != null) {
9962 uri.append("scheme=").append(scheme).append(';');
9963 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009964 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009965 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009966 }
9967 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009968 for (int i=0; i<mCategories.size(); i++) {
9969 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009970 }
9971 }
9972 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009973 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009974 }
9975 if (mFlags != 0) {
9976 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9977 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009978 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009979 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9980 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009981 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009982 uri.append("component=").append(Uri.encode(
9983 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009984 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009985 if (mSourceBounds != null) {
9986 uri.append("sourceBounds=")
9987 .append(Uri.encode(mSourceBounds.flattenToString()))
9988 .append(';');
9989 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009990 if (mExtras != null) {
9991 for (String key : mExtras.keySet()) {
9992 final Object value = mExtras.get(key);
9993 char entryType =
9994 value instanceof String ? 'S' :
9995 value instanceof Boolean ? 'B' :
9996 value instanceof Byte ? 'b' :
9997 value instanceof Character ? 'c' :
9998 value instanceof Double ? 'd' :
9999 value instanceof Float ? 'f' :
10000 value instanceof Integer ? 'i' :
10001 value instanceof Long ? 'l' :
10002 value instanceof Short ? 's' :
10003 '\0';
10004
10005 if (entryType != '\0') {
10006 uri.append(entryType);
10007 uri.append('.');
10008 uri.append(Uri.encode(key));
10009 uri.append('=');
10010 uri.append(Uri.encode(value.toString()));
10011 uri.append(';');
10012 }
10013 }
10014 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010015 }
The Android Open Source Project10592532009-03-18 17:39:46 -070010016
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010017 public int describeContents() {
10018 return (mExtras != null) ? mExtras.describeContents() : 0;
10019 }
10020
10021 public void writeToParcel(Parcel out, int flags) {
10022 out.writeString(mAction);
10023 Uri.writeToParcel(out, mData);
10024 out.writeString(mType);
10025 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010026 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010027 ComponentName.writeToParcel(mComponent, out);
10028
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010029 if (mSourceBounds != null) {
10030 out.writeInt(1);
10031 mSourceBounds.writeToParcel(out, flags);
10032 } else {
10033 out.writeInt(0);
10034 }
10035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010036 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010037 final int N = mCategories.size();
10038 out.writeInt(N);
10039 for (int i=0; i<N; i++) {
10040 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010041 }
10042 } else {
10043 out.writeInt(0);
10044 }
10045
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010046 if (mSelector != null) {
10047 out.writeInt(1);
10048 mSelector.writeToParcel(out, flags);
10049 } else {
10050 out.writeInt(0);
10051 }
10052
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010053 if (mClipData != null) {
10054 out.writeInt(1);
10055 mClipData.writeToParcel(out, flags);
10056 } else {
10057 out.writeInt(0);
10058 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010059 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010060 out.writeBundle(mExtras);
10061 }
10062
10063 public static final Parcelable.Creator<Intent> CREATOR
10064 = new Parcelable.Creator<Intent>() {
10065 public Intent createFromParcel(Parcel in) {
10066 return new Intent(in);
10067 }
10068 public Intent[] newArray(int size) {
10069 return new Intent[size];
10070 }
10071 };
10072
Dianne Hackborneb034652009-09-07 00:49:58 -070010073 /** @hide */
10074 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010075 readFromParcel(in);
10076 }
10077
10078 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010079 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010080 mData = Uri.CREATOR.createFromParcel(in);
10081 mType = in.readString();
10082 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010083 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010084 mComponent = ComponentName.readFromParcel(in);
10085
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010086 if (in.readInt() != 0) {
10087 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10088 }
10089
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010090 int N = in.readInt();
10091 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010092 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010093 int i;
10094 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010095 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010096 }
10097 } else {
10098 mCategories = null;
10099 }
10100
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010101 if (in.readInt() != 0) {
10102 mSelector = new Intent(in);
10103 }
10104
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010105 if (in.readInt() != 0) {
10106 mClipData = new ClipData(in);
10107 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010108 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010109 mExtras = in.readBundle();
10110 }
10111
10112 /**
10113 * Parses the "intent" element (and its children) from XML and instantiates
10114 * an Intent object. The given XML parser should be located at the tag
10115 * where parsing should start (often named "intent"), from which the
10116 * basic action, data, type, and package and class name will be
10117 * retrieved. The function will then parse in to any child elements,
10118 * looking for <category android:name="xxx"> tags to add categories and
10119 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10120 * to the intent.
10121 *
10122 * @param resources The Resources to use when inflating resources.
10123 * @param parser The XML parser pointing at an "intent" tag.
10124 * @param attrs The AttributeSet interface for retrieving extended
10125 * attribute data at the current <var>parser</var> location.
10126 * @return An Intent object matching the XML data.
10127 * @throws XmlPullParserException If there was an XML parsing error.
10128 * @throws IOException If there was an I/O error.
10129 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010130 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10131 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010132 throws XmlPullParserException, IOException {
10133 Intent intent = new Intent();
10134
10135 TypedArray sa = resources.obtainAttributes(attrs,
10136 com.android.internal.R.styleable.Intent);
10137
10138 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10139
10140 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10141 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10142 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10143
10144 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10145 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10146 if (packageName != null && className != null) {
10147 intent.setComponent(new ComponentName(packageName, className));
10148 }
10149
10150 sa.recycle();
10151
10152 int outerDepth = parser.getDepth();
10153 int type;
10154 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10155 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10156 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10157 continue;
10158 }
10159
10160 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010161 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010162 sa = resources.obtainAttributes(attrs,
10163 com.android.internal.R.styleable.IntentCategory);
10164 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10165 sa.recycle();
10166
10167 if (cat != null) {
10168 intent.addCategory(cat);
10169 }
10170 XmlUtils.skipCurrentTag(parser);
10171
Craig Mautner21d24a22014-04-23 11:45:37 -070010172 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010173 if (intent.mExtras == null) {
10174 intent.mExtras = new Bundle();
10175 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010176 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010177 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010178
10179 } else {
10180 XmlUtils.skipCurrentTag(parser);
10181 }
10182 }
10183
10184 return intent;
10185 }
Nick Pellyccae4122012-01-09 14:12:58 -080010186
Craig Mautner21d24a22014-04-23 11:45:37 -070010187 /** @hide */
10188 public void saveToXml(XmlSerializer out) throws IOException {
10189 if (mAction != null) {
10190 out.attribute(null, ATTR_ACTION, mAction);
10191 }
10192 if (mData != null) {
10193 out.attribute(null, ATTR_DATA, mData.toString());
10194 }
10195 if (mType != null) {
10196 out.attribute(null, ATTR_TYPE, mType);
10197 }
10198 if (mComponent != null) {
10199 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10200 }
10201 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10202
10203 if (mCategories != null) {
10204 out.startTag(null, TAG_CATEGORIES);
10205 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10206 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10207 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010208 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010209 }
10210 }
10211
10212 /** @hide */
10213 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10214 XmlPullParserException {
10215 Intent intent = new Intent();
10216 final int outerDepth = in.getDepth();
10217
10218 int attrCount = in.getAttributeCount();
10219 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10220 final String attrName = in.getAttributeName(attrNdx);
10221 final String attrValue = in.getAttributeValue(attrNdx);
10222 if (ATTR_ACTION.equals(attrName)) {
10223 intent.setAction(attrValue);
10224 } else if (ATTR_DATA.equals(attrName)) {
10225 intent.setData(Uri.parse(attrValue));
10226 } else if (ATTR_TYPE.equals(attrName)) {
10227 intent.setType(attrValue);
10228 } else if (ATTR_COMPONENT.equals(attrName)) {
10229 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10230 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010231 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010232 } else {
10233 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10234 }
10235 }
10236
10237 int event;
10238 String name;
10239 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10240 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10241 if (event == XmlPullParser.START_TAG) {
10242 name = in.getName();
10243 if (TAG_CATEGORIES.equals(name)) {
10244 attrCount = in.getAttributeCount();
10245 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10246 intent.addCategory(in.getAttributeValue(attrNdx));
10247 }
10248 } else {
10249 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10250 XmlUtils.skipCurrentTag(in);
10251 }
10252 }
10253 }
10254
10255 return intent;
10256 }
10257
Nick Pellyccae4122012-01-09 14:12:58 -080010258 /**
10259 * Normalize a MIME data type.
10260 *
10261 * <p>A normalized MIME type has white-space trimmed,
10262 * content-type parameters removed, and is lower-case.
10263 * This aligns the type with Android best practices for
10264 * intent filtering.
10265 *
10266 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10267 * "text/x-vCard" becomes "text/x-vcard".
10268 *
10269 * <p>All MIME types received from outside Android (such as user input,
10270 * or external sources like Bluetooth, NFC, or the Internet) should
10271 * be normalized before they are used to create an Intent.
10272 *
10273 * @param type MIME data type to normalize
10274 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010275 * @see #setType
10276 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010277 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010278 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010279 if (type == null) {
10280 return null;
10281 }
10282
Elliott Hughescb64d432013-08-02 10:00:44 -070010283 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010284
10285 final int semicolonIndex = type.indexOf(';');
10286 if (semicolonIndex != -1) {
10287 type = type.substring(0, semicolonIndex);
10288 }
10289 return type;
10290 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010291
10292 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010293 * Prepare this {@link Intent} to leave an app process.
10294 *
10295 * @hide
10296 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010297 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010298 public void prepareToLeaveProcess(Context context) {
10299 final boolean leavingPackage = (mComponent == null)
10300 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10301 prepareToLeaveProcess(leavingPackage);
10302 }
10303
10304 /**
10305 * Prepare this {@link Intent} to leave an app process.
10306 *
10307 * @hide
10308 */
10309 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010310 setAllowFds(false);
10311
10312 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010313 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010314 }
10315 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010316 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010317 }
10318
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010319 if (mExtras != null && !mExtras.isParcelled()) {
10320 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10321 if (intent instanceof Intent) {
10322 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10323 }
10324 }
10325
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010326 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10327 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010328 switch (mAction) {
10329 case ACTION_MEDIA_REMOVED:
10330 case ACTION_MEDIA_UNMOUNTED:
10331 case ACTION_MEDIA_CHECKING:
10332 case ACTION_MEDIA_NOFS:
10333 case ACTION_MEDIA_MOUNTED:
10334 case ACTION_MEDIA_SHARED:
10335 case ACTION_MEDIA_UNSHARED:
10336 case ACTION_MEDIA_BAD_REMOVAL:
10337 case ACTION_MEDIA_UNMOUNTABLE:
10338 case ACTION_MEDIA_EJECT:
10339 case ACTION_MEDIA_SCANNER_STARTED:
10340 case ACTION_MEDIA_SCANNER_FINISHED:
10341 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010342 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10343 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010344 // Ignore legacy actions
10345 break;
10346 default:
10347 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010348 }
10349 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010350
10351 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10352 && leavingPackage) {
10353 switch (mAction) {
10354 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010355 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010356 // Ignore actions that don't need to grant
10357 break;
10358 default:
10359 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10360 }
10361 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010362 }
10363
10364 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010365 * @hide
10366 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010367 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010368 // We just entered destination process, so we should be able to read all
10369 // parcelables inside.
10370 setDefusable(true);
10371
10372 if (mSelector != null) {
10373 mSelector.prepareToEnterProcess();
10374 }
10375 if (mClipData != null) {
10376 mClipData.prepareToEnterProcess();
10377 }
10378
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010379 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010380 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10381 fixUris(mContentUserHint);
10382 mContentUserHint = UserHandle.USER_CURRENT;
10383 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010384 }
10385 }
10386
Patrick Baumann577d4022018-01-31 16:55:10 +000010387 /** @hide */
10388 public boolean hasWebURI() {
10389 if (getData() == null) {
10390 return false;
10391 }
10392 final String scheme = getScheme();
10393 if (TextUtils.isEmpty(scheme)) {
10394 return false;
10395 }
10396 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10397 }
10398
10399 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010400 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010401 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010402 && hasWebURI();
10403 }
10404
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010405 /**
10406 * @hide
10407 */
10408 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010409 Uri data = getData();
10410 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010411 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010412 }
10413 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010414 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010415 }
10416 String action = getAction();
10417 if (ACTION_SEND.equals(action)) {
10418 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10419 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010420 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010421 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010422 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010423 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10424 if (streams != null) {
10425 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10426 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010427 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010428 }
10429 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10430 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010431 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10432 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10433 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10434 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10435 if (output != null) {
10436 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10437 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010438 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010439 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010440
10441 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010442 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010443 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10444 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010445 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010446 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010447 * @hide
10448 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010449 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010450 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010451 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010452
10453 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010454 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010455
10456 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010457 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010458 // Inspect contained intents to see if we need to migrate extras. We
10459 // don't promote ClipData to the parent, since ChooserActivity will
10460 // already start the picked item as the caller, and we can't combine
10461 // the flags in a safe way.
10462
10463 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010464 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010465 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10466 if (intent != null) {
10467 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010468 }
10469 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010470 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010471 try {
10472 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10473 if (intents != null) {
10474 for (int i = 0; i < intents.length; i++) {
10475 final Intent intent = (Intent) intents[i];
10476 if (intent != null) {
10477 migrated |= intent.migrateExtraStreamToClipData();
10478 }
10479 }
10480 }
10481 } catch (ClassCastException e) {
10482 }
10483 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010484
10485 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010486 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010487 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10488 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10489 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10490 if (stream != null || text != null || htmlText != null) {
10491 final ClipData clipData = new ClipData(
10492 null, new String[] { getType() },
10493 new ClipData.Item(text, htmlText, null, stream));
10494 setClipData(clipData);
10495 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010496 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010497 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010498 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010499 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010500
10501 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010502 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010503 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10504 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10505 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10506 int num = -1;
10507 if (streams != null) {
10508 num = streams.size();
10509 }
10510 if (texts != null) {
10511 if (num >= 0 && num != texts.size()) {
10512 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010513 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010514 }
10515 num = texts.size();
10516 }
10517 if (htmlTexts != null) {
10518 if (num >= 0 && num != htmlTexts.size()) {
10519 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010520 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010521 }
10522 num = htmlTexts.size();
10523 }
10524 if (num > 0) {
10525 final ClipData clipData = new ClipData(
10526 null, new String[] { getType() },
10527 makeClipItem(streams, texts, htmlTexts, 0));
10528
10529 for (int i = 1; i < num; i++) {
10530 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10531 }
10532
10533 setClipData(clipData);
10534 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010535 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010536 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010537 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010538 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010539 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10540 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10541 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10542 final Uri output;
10543 try {
10544 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10545 } catch (ClassCastException e) {
10546 return false;
10547 }
10548 if (output != null) {
10549 setClipData(ClipData.newRawUri("", output));
10550 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10551 return true;
10552 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010553 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010554
10555 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010556 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010557
Michael Wright19859762017-09-18 20:57:58 +010010558 /**
10559 * Convert the dock state to a human readable format.
10560 * @hide
10561 */
10562 public static String dockStateToString(int dock) {
10563 switch (dock) {
10564 case EXTRA_DOCK_STATE_HE_DESK:
10565 return "EXTRA_DOCK_STATE_HE_DESK";
10566 case EXTRA_DOCK_STATE_LE_DESK:
10567 return "EXTRA_DOCK_STATE_LE_DESK";
10568 case EXTRA_DOCK_STATE_CAR:
10569 return "EXTRA_DOCK_STATE_CAR";
10570 case EXTRA_DOCK_STATE_DESK:
10571 return "EXTRA_DOCK_STATE_DESK";
10572 case EXTRA_DOCK_STATE_UNDOCKED:
10573 return "EXTRA_DOCK_STATE_UNDOCKED";
10574 default:
10575 return Integer.toString(dock);
10576 }
10577 }
10578
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010579 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10580 ArrayList<String> htmlTexts, int which) {
10581 Uri uri = streams != null ? streams.get(which) : null;
10582 CharSequence text = texts != null ? texts.get(which) : null;
10583 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10584 return new ClipData.Item(text, htmlText, null, uri);
10585 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010586
10587 /** @hide */
10588 public boolean isDocument() {
10589 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10590 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010591}