Debian Codegraph @

core/java/android/content/Intent.java

raw symbols SCIP
1 /*
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
17 package android.content;
18
19 import static android.content.ContentProvider.maybeAddUserId;
20
21 import android.Manifest;
22 import android.accessibilityservice.AccessibilityService;
23 import android.annotation.AnyRes;
24 import android.annotation.BroadcastBehavior;
25 import android.annotation.IntDef;
26 import android.annotation.NonNull;
27 import android.annotation.Nullable;
28 import android.annotation.RequiresPermission;
29 import android.annotation.SdkConstant;
30 import android.annotation.SdkConstant.SdkConstantType;
31 import android.annotation.SuppressLint;
32 import android.annotation.SystemApi;
33 import android.annotation.TestApi;
34 import android.app.ActivityThread;
35 import android.app.AppGlobals;
36 import android.bluetooth.BluetoothDevice;
37 import android.compat.annotation.UnsupportedAppUsage;
38 import android.content.pm.ActivityInfo;
39 import android.content.pm.ApplicationInfo;
40 import android.content.pm.ComponentInfo;
41 import android.content.pm.PackageManager;
42 import android.content.pm.ResolveInfo;
43 import android.content.pm.ShortcutInfo;
44 import android.content.pm.SuspendDialogInfo;
45 import android.content.pm.verify.domain.DomainVerificationManager;
46 import android.content.res.Resources;
47 import android.content.res.TypedArray;
48 import android.graphics.Rect;
49 import android.net.Uri;
50 import android.os.Build;
51 import android.os.Bundle;
52 import android.os.IBinder;
53 import android.os.IncidentManager;
54 import android.os.Parcel;
55 import android.os.Parcelable;
56 import android.os.PersistableBundle;
57 import android.os.Process;
58 import android.os.ResultReceiver;
59 import android.os.ShellCommand;
60 import android.os.StrictMode;
61 import android.os.UserHandle;
62 import android.os.storage.StorageManager;
63 import android.provider.ContactsContract.QuickContact;
64 import android.provider.DocumentsContract;
65 import android.provider.DocumentsProvider;
66 import android.provider.MediaStore;
67 import android.provider.OpenableColumns;
68 import android.service.chooser.ChooserAction;
69 import android.telecom.PhoneAccount;
70 import android.telecom.TelecomManager;
71 import android.text.TextUtils;
72 import android.util.ArraySet;
73 import android.util.AttributeSet;
74 import android.util.Log;
75 import android.util.proto.ProtoOutputStream;
76
77 import com.android.internal.util.XmlUtils;
78
79 import org.xmlpull.v1.XmlPullParser;
80 import org.xmlpull.v1.XmlPullParserException;
81 import org.xmlpull.v1.XmlSerializer;
82
83 import java.io.File;
84 import java.io.IOException;
85 import java.io.PrintWriter;
86 import java.io.Serializable;
87 import java.lang.annotation.Retention;
88 import java.lang.annotation.RetentionPolicy;
89 import java.net.URISyntaxException;
90 import java.util.ArrayList;
91 import java.util.HashSet;
92 import java.util.List;
93 import java.util.Locale;
94 import java.util.Objects;
95 import java.util.Set;
96 import java.util.TimeZone;
97
98 /**
99 * An intent is an abstract description of an operation to be performed. It
100 * can be used with {@link Context#startActivity(Intent) startActivity} to
101 * launch an {@link android.app.Activity},
102 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
103 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
104 * and {@link android.content.Context#startService} or
105 * {@link android.content.Context#bindService} to communicate with a
106 * background {@link android.app.Service}.
107 *
108 * <p>An Intent provides a facility for performing late runtime binding between the code in
109 * different applications. Its most significant use is in the launching of activities, where it
110 * can be thought of as the glue between activities. It is basically a passive data structure
111 * holding an abstract description of an action to be performed.</p>
112 *
113 * <div class="special reference">
114 * <h3>Developer Guides</h3>
115 * <p>For information about how to create and resolve intents, read the
116 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
117 * developer guide.</p>
118 * </div>
119 *
120 * <a name="IntentStructure"></a>
121 * <h3>Intent Structure</h3>
122 * <p>The primary pieces of information in an intent are:</p>
123 *
124 * <ul>
125 * <li> <p><b>action</b> -- The general action to be performed, such as
126 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
127 * etc.</p>
128 * </li>
129 * <li> <p><b>data</b> -- The data to operate on, such as a person record
130 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
131 * </li>
132 * </ul>
133 *
134 *
135 * <p>Some examples of action/data pairs are:</p>
136 *
137 * <ul>
138 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
139 * information about the person whose identifier is "1".</p>
140 * </li>
141 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
142 * the phone dialer with the person filled in.</p>
143 * </li>
144 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
145 * the phone dialer with the given number filled in. Note how the
146 * VIEW action does what is considered the most reasonable thing for
147 * a particular URI.</p>
148 * </li>
149 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
150 * the phone dialer with the given number filled in.</p>
151 * </li>
152 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
153 * information about the person whose identifier is "1".</p>
154 * </li>
155 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
156 * a list of people, which the user can browse through. This example is a
157 * typical top-level entry into the Contacts application, showing you the
158 * list of people. Selecting a particular person to view would result in a
159 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
160 * being used to start an activity to display that person.</p>
161 * </li>
162 * </ul>
163 *
164 * <p>In addition to these primary attributes, there are a number of secondary
165 * attributes that you can also include with an intent:</p>
166 *
167 * <ul>
168 * <li> <p><b>category</b> -- Gives additional information about the action
169 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
170 * appear in the Launcher as a top-level application, while
171 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
172 * of alternative actions the user can perform on a piece of data.</p>
173 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
174 * intent data. Normally the type is inferred from the data itself.
175 * By setting this attribute, you disable that evaluation and force
176 * an explicit type.</p>
177 * <li> <p><b>component</b> -- Specifies an explicit name of a component
178 * class to use for the intent. Normally this is determined by looking
179 * at the other information in the intent (the action, data/type, and
180 * categories) and matching that with a component that can handle it.
181 * If this attribute is set then none of the evaluation is performed,
182 * and this component is used exactly as is. By specifying this attribute,
183 * all of the other Intent attributes become optional.</p>
184 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
185 * This can be used to provide extended information to the component.
186 * For example, if we have a action to send an e-mail message, we could
187 * also include extra pieces of data here to supply a subject, body,
188 * etc.</p>
189 * </ul>
190 *
191 * <p>Here are some examples of other operations you can specify as intents
192 * using these additional parameters:</p>
193 *
194 * <ul>
195 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
196 * Launch the home screen.</p>
197 * </li>
198 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
199 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
200 * vnd.android.cursor.item/phone}</i></b>
201 * -- Display the list of people's phone numbers, allowing the user to
202 * browse through them and pick one and return it to the parent activity.</p>
203 * </li>
204 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
205 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
206 * -- Display all pickers for data that can be opened with
207 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
208 * allowing the user to pick one of them and then some data inside of it
209 * and returning the resulting URI to the caller. This can be used,
210 * for example, in an e-mail application to allow the user to pick some
211 * data to include as an attachment.</p>
212 * </li>
213 * </ul>
214 *
215 * <p>There are a variety of standard Intent action and category constants
216 * defined in the Intent class, but applications can also define their own.
217 * These strings use Java-style scoping, to ensure they are unique -- for
218 * example, the standard {@link #ACTION_VIEW} is called
219 * "android.intent.action.VIEW".</p>
220 *
221 * <p>Put together, the set of actions, data types, categories, and extra data
222 * defines a language for the system allowing for the expression of phrases
223 * such as "call john smith's cell". As applications are added to the system,
224 * they can extend this language by adding new actions, types, and categories, or
225 * they can modify the behavior of existing phrases by supplying their own
226 * activities that handle them.</p>
227 *
228 * <a name="IntentResolution"></a>
229 * <h3>Intent Resolution</h3>
230 *
231 * <p>There are two primary forms of intents you will use.
232 *
233 * <ul>
234 * <li> <p><b>Explicit Intents</b> have specified a component (via
235 * {@link #setComponent} or {@link #setClass}), which provides the exact
236 * class to be run. Often these will not include any other information,
237 * simply being a way for an application to launch various internal
238 * activities it has as the user interacts with the application.
239 *
240 * <li> <p><b>Implicit Intents</b> have not specified a component;
241 * instead, they must include enough information for the system to
242 * determine which of the available components is best to run for that
243 * intent.
244 * </ul>
245 *
246 * <p>When using implicit intents, given such an arbitrary intent we need to
247 * know what to do with it. This is handled by the process of <em>Intent
248 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
249 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
250 * more activities/receivers) that can handle it.</p>
251 *
252 * <p>The intent resolution mechanism basically revolves around matching an
253 * Intent against all of the &lt;intent-filter&gt; descriptions in the
254 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
255 * objects explicitly registered with {@link Context#registerReceiver}.) More
256 * details on this can be found in the documentation on the {@link
257 * IntentFilter} class.</p>
258 *
259 * <p>There are three pieces of information in the Intent that are used for
260 * resolution: the action, type, and category. Using this information, a query
261 * is done on the {@link PackageManager} for a component that can handle the
262 * intent. The appropriate component is determined based on the intent
263 * information supplied in the <code>AndroidManifest.xml</code> file as
264 * follows:</p>
265 *
266 * <ul>
267 * <li> <p>The <b>action</b>, if given, must be listed by the component as
268 * one it handles.</p>
269 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
270 * already supplied in the Intent. Like the action, if a type is
271 * included in the intent (either explicitly or implicitly in its
272 * data), then this must be listed by the component as one it handles.</p>
273 * <li> For data that is not a <code>content:</code> URI and where no explicit
274 * type is included in the Intent, instead the <b>scheme</b> of the
275 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
276 * considered. Again like the action, if we are matching a scheme it
277 * must be listed by the component as one it can handle.
278 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
279 * by the activity as categories it handles. That is, if you include
280 * the categories {@link #CATEGORY_LAUNCHER} and
281 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
282 * with an intent that lists <em>both</em> of those categories.
283 * Activities will very often need to support the
284 * {@link #CATEGORY_DEFAULT} so that they can be found by
285 * {@link Context#startActivity Context.startActivity()}.</p>
286 * </ul>
287 *
288 * <p>For example, consider the Note Pad sample application that
289 * allows a user to browse through a list of notes data and view details about
290 * individual items. Text in italics indicates places where you would replace a
291 * name with one specific to your own package.</p>
292 *
293 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
294 * package="<i>com.android.notepad</i>"&gt;
295 * &lt;application android:icon="@drawable/app_notes"
296 * android:label="@string/app_name"&gt;
297 *
298 * &lt;provider class=".NotePadProvider"
299 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
300 *
301 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
302 * &lt;intent-filter&gt;
303 * &lt;action android:name="android.intent.action.MAIN" /&gt;
304 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
305 * &lt;/intent-filter&gt;
306 * &lt;intent-filter&gt;
307 * &lt;action android:name="android.intent.action.VIEW" /&gt;
308 * &lt;action android:name="android.intent.action.EDIT" /&gt;
309 * &lt;action android:name="android.intent.action.PICK" /&gt;
310 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
311 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
312 * &lt;/intent-filter&gt;
313 * &lt;intent-filter&gt;
314 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
315 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
317 * &lt;/intent-filter&gt;
318 * &lt;/activity&gt;
319 *
320 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
321 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
322 * &lt;action android:name="android.intent.action.VIEW" /&gt;
323 * &lt;action android:name="android.intent.action.EDIT" /&gt;
324 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
325 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
326 * &lt;/intent-filter&gt;
327 *
328 * &lt;intent-filter&gt;
329 * &lt;action android:name="android.intent.action.INSERT" /&gt;
330 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
331 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
332 * &lt;/intent-filter&gt;
333 *
334 * &lt;/activity&gt;
335 *
336 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
337 * android:theme="@android:style/Theme.Dialog"&gt;
338 * &lt;intent-filter android:label="@string/resolve_title"&gt;
339 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
340 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
341 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
342 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
343 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
344 * &lt;/intent-filter&gt;
345 * &lt;/activity&gt;
346 *
347 * &lt;/application&gt;
348 * &lt;/manifest&gt;</pre>
349 *
350 * <p>The first activity,
351 * <code>com.android.notepad.NotesList</code>, serves as our main
352 * entry into the app. It can do three things as described by its three intent
353 * templates:
354 * <ol>
355 * <li><pre>
356 * &lt;intent-filter&gt;
357 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
358 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
359 * &lt;/intent-filter&gt;</pre>
360 * <p>This provides a top-level entry into the NotePad application: the standard
361 * MAIN action is a main entry point (not requiring any other information in
362 * the Intent), and the LAUNCHER category says that this entry point should be
363 * listed in the application launcher.</p>
364 * <li><pre>
365 * &lt;intent-filter&gt;
366 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
367 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
368 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
369 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
370 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
371 * &lt;/intent-filter&gt;</pre>
372 * <p>This declares the things that the activity can do on a directory of
373 * notes. The type being supported is given with the &lt;type&gt; tag, where
374 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
375 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
376 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
377 * The activity allows the user to view or edit the directory of data (via
378 * the VIEW and EDIT actions), or to pick a particular note and return it
379 * to the caller (via the PICK action). Note also the DEFAULT category
380 * supplied here: this is <em>required</em> for the
381 * {@link Context#startActivity Context.startActivity} method to resolve your
382 * activity when its component name is not explicitly specified.</p>
383 * <li><pre>
384 * &lt;intent-filter&gt;
385 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
386 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
387 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
388 * &lt;/intent-filter&gt;</pre>
389 * <p>This filter describes the ability to return to the caller a note selected by
390 * the user without needing to know where it came from. The data type
391 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
392 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
393 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
394 * The GET_CONTENT action is similar to the PICK action, where the activity
395 * will return to its caller a piece of data selected by the user. Here,
396 * however, the caller specifies the type of data they desire instead of
397 * the type of data the user will be picking from.</p>
398 * </ol>
399 *
400 * <p>Given these capabilities, the following intents will resolve to the
401 * NotesList activity:</p>
402 *
403 * <ul>
404 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
405 * activities that can be used as top-level entry points into an
406 * application.</p>
407 * <li> <p><b>{ action=android.app.action.MAIN,
408 * category=android.app.category.LAUNCHER }</b> is the actual intent
409 * used by the Launcher to populate its top-level list.</p>
410 * <li> <p><b>{ action=android.intent.action.VIEW
411 * data=content://com.google.provider.NotePad/notes }</b>
412 * displays a list of all the notes under
413 * "content://com.google.provider.NotePad/notes", which
414 * the user can browse through and see the details on.</p>
415 * <li> <p><b>{ action=android.app.action.PICK
416 * data=content://com.google.provider.NotePad/notes }</b>
417 * provides a list of the notes under
418 * "content://com.google.provider.NotePad/notes", from which
419 * the user can pick a note whose data URL is returned back to the caller.</p>
420 * <li> <p><b>{ action=android.app.action.GET_CONTENT
421 * type=vnd.android.cursor.item/vnd.google.note }</b>
422 * is similar to the pick action, but allows the caller to specify the
423 * kind of data they want back so that the system can find the appropriate
424 * activity to pick something of that data type.</p>
425 * </ul>
426 *
427 * <p>The second activity,
428 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
429 * note entry and allows them to edit it. It can do two things as described
430 * by its two intent templates:
431 * <ol>
432 * <li><pre>
433 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
434 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
435 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
436 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
437 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
438 * &lt;/intent-filter&gt;</pre>
439 * <p>The first, primary, purpose of this activity is to let the user interact
440 * with a single note, as decribed by the MIME type
441 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
442 * either VIEW a note or allow the user to EDIT it. Again we support the
443 * DEFAULT category to allow the activity to be launched without explicitly
444 * specifying its component.</p>
445 * <li><pre>
446 * &lt;intent-filter&gt;
447 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
448 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
449 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
450 * &lt;/intent-filter&gt;</pre>
451 * <p>The secondary use of this activity is to insert a new note entry into
452 * an existing directory of notes. This is used when the user creates a new
453 * note: the INSERT action is executed on the directory of notes, causing
454 * this activity to run and have the user create the new note data which
455 * it then adds to the content provider.</p>
456 * </ol>
457 *
458 * <p>Given these capabilities, the following intents will resolve to the
459 * NoteEditor activity:</p>
460 *
461 * <ul>
462 * <li> <p><b>{ action=android.intent.action.VIEW
463 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
464 * shows the user the content of note <var>{ID}</var>.</p>
465 * <li> <p><b>{ action=android.app.action.EDIT
466 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
467 * allows the user to edit the content of note <var>{ID}</var>.</p>
468 * <li> <p><b>{ action=android.app.action.INSERT
469 * data=content://com.google.provider.NotePad/notes }</b>
470 * creates a new, empty note in the notes list at
471 * "content://com.google.provider.NotePad/notes"
472 * and allows the user to edit it. If they keep their changes, the URI
473 * of the newly created note is returned to the caller.</p>
474 * </ul>
475 *
476 * <p>The last activity,
477 * <code>com.android.notepad.TitleEditor</code>, allows the user to
478 * edit the title of a note. This could be implemented as a class that the
479 * application directly invokes (by explicitly setting its component in
480 * the Intent), but here we show a way you can publish alternative
481 * operations on existing data:</p>
482 *
483 * <pre>
484 * &lt;intent-filter android:label="@string/resolve_title"&gt;
485 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
486 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
487 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
488 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
489 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
490 * &lt;/intent-filter&gt;</pre>
491 *
492 * <p>In the single intent template here, we
493 * have created our own private action called
494 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
495 * edit the title of a note. It must be invoked on a specific note
496 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
497 * view and edit actions, but here displays and edits the title contained
498 * in the note data.
499 *
500 * <p>In addition to supporting the default category as usual, our title editor
501 * also supports two other standard categories: ALTERNATIVE and
502 * SELECTED_ALTERNATIVE. Implementing
503 * these categories allows others to find the special action it provides
504 * without directly knowing about it, through the
505 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
506 * more often to build dynamic menu items with
507 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
508 * template here was also supply an explicit name for the template
509 * (via <code>android:label="@string/resolve_title"</code>) to better control
510 * what the user sees when presented with this activity as an alternative
511 * action to the data they are viewing.
512 *
513 * <p>Given these capabilities, the following intent will resolve to the
514 * TitleEditor activity:</p>
515 *
516 * <ul>
517 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
518 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
519 * displays and allows the user to edit the title associated
520 * with note <var>{ID}</var>.</p>
521 * </ul>
522 *
523 * <h3>Standard Activity Actions</h3>
524 *
525 * <p>These are the current standard actions that Intent defines for launching
526 * activities (usually through {@link Context#startActivity}. The most
527 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
528 * {@link #ACTION_EDIT}.
529 *
530 * <ul>
531 * <li> {@link #ACTION_MAIN}
532 * <li> {@link #ACTION_VIEW}
533 * <li> {@link #ACTION_ATTACH_DATA}
534 * <li> {@link #ACTION_EDIT}
535 * <li> {@link #ACTION_PICK}
536 * <li> {@link #ACTION_CHOOSER}
537 * <li> {@link #ACTION_GET_CONTENT}
538 * <li> {@link #ACTION_DIAL}
539 * <li> {@link #ACTION_CALL}
540 * <li> {@link #ACTION_SEND}
541 * <li> {@link #ACTION_SENDTO}
542 * <li> {@link #ACTION_ANSWER}
543 * <li> {@link #ACTION_INSERT}
544 * <li> {@link #ACTION_DELETE}
545 * <li> {@link #ACTION_RUN}
546 * <li> {@link #ACTION_SYNC}
547 * <li> {@link #ACTION_PICK_ACTIVITY}
548 * <li> {@link #ACTION_SEARCH}
549 * <li> {@link #ACTION_WEB_SEARCH}
550 * <li> {@link #ACTION_FACTORY_TEST}
551 * </ul>
552 *
553 * <h3>Standard Broadcast Actions</h3>
554 *
555 * <p>These are the current standard actions that Intent defines for receiving
556 * broadcasts (usually through {@link Context#registerReceiver} or a
557 * &lt;receiver&gt; tag in a manifest).
558 *
559 * <ul>
560 * <li> {@link #ACTION_TIME_TICK}
561 * <li> {@link #ACTION_TIME_CHANGED}
562 * <li> {@link #ACTION_TIMEZONE_CHANGED}
563 * <li> {@link #ACTION_BOOT_COMPLETED}
564 * <li> {@link #ACTION_PACKAGE_ADDED}
565 * <li> {@link #ACTION_PACKAGE_CHANGED}
566 * <li> {@link #ACTION_PACKAGE_REMOVED}
567 * <li> {@link #ACTION_PACKAGE_RESTARTED}
568 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
569 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
570 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
571 * <li> {@link #ACTION_UID_REMOVED}
572 * <li> {@link #ACTION_BATTERY_CHANGED}
573 * <li> {@link #ACTION_POWER_CONNECTED}
574 * <li> {@link #ACTION_POWER_DISCONNECTED}
575 * <li> {@link #ACTION_SHUTDOWN}
576 * </ul>
577 *
578 * <h3>Standard Categories</h3>
579 *
580 * <p>These are the current standard categories that can be used to further
581 * clarify an Intent via {@link #addCategory}.
582 *
583 * <ul>
584 * <li> {@link #CATEGORY_DEFAULT}
585 * <li> {@link #CATEGORY_BROWSABLE}
586 * <li> {@link #CATEGORY_TAB}
587 * <li> {@link #CATEGORY_ALTERNATIVE}
588 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
589 * <li> {@link #CATEGORY_LAUNCHER}
590 * <li> {@link #CATEGORY_INFO}
591 * <li> {@link #CATEGORY_HOME}
592 * <li> {@link #CATEGORY_PREFERENCE}
593 * <li> {@link #CATEGORY_TEST}
594 * <li> {@link #CATEGORY_CAR_DOCK}
595 * <li> {@link #CATEGORY_DESK_DOCK}
596 * <li> {@link #CATEGORY_LE_DESK_DOCK}
597 * <li> {@link #CATEGORY_HE_DESK_DOCK}
598 * <li> {@link #CATEGORY_CAR_MODE}
599 * <li> {@link #CATEGORY_APP_MARKET}
600 * <li> {@link #CATEGORY_VR_HOME}
601 * </ul>
602 *
603 * <h3>Standard Extra Data</h3>
604 *
605 * <p>These are the current standard fields that can be used as extra data via
606 * {@link #putExtra}.
607 *
608 * <ul>
609 * <li> {@link #EXTRA_ALARM_COUNT}
610 * <li> {@link #EXTRA_BCC}
611 * <li> {@link #EXTRA_CC}
612 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
613 * <li> {@link #EXTRA_DATA_REMOVED}
614 * <li> {@link #EXTRA_DOCK_STATE}
615 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
616 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
617 * <li> {@link #EXTRA_DOCK_STATE_CAR}
618 * <li> {@link #EXTRA_DOCK_STATE_DESK}
619 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
620 * <li> {@link #EXTRA_DONT_KILL_APP}
621 * <li> {@link #EXTRA_EMAIL}
622 * <li> {@link #EXTRA_INITIAL_INTENTS}
623 * <li> {@link #EXTRA_INTENT}
624 * <li> {@link #EXTRA_KEY_EVENT}
625 * <li> {@link #EXTRA_ORIGINATING_URI}
626 * <li> {@link #EXTRA_PHONE_NUMBER}
627 * <li> {@link #EXTRA_REFERRER}
628 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
629 * <li> {@link #EXTRA_REPLACING}
630 * <li> {@link #EXTRA_SHORTCUT_ICON}
631 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
632 * <li> {@link #EXTRA_SHORTCUT_INTENT}
633 * <li> {@link #EXTRA_STREAM}
634 * <li> {@link #EXTRA_SHORTCUT_NAME}
635 * <li> {@link #EXTRA_SUBJECT}
636 * <li> {@link #EXTRA_TEMPLATE}
637 * <li> {@link #EXTRA_TEXT}
638 * <li> {@link #EXTRA_TITLE}
639 * <li> {@link #EXTRA_UID}
640 * <li> {@link #EXTRA_USER_INITIATED}
641 * </ul>
642 *
643 * <h3>Flags</h3>
644 *
645 * <p>These are the possible flags that can be used in the Intent via
646 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
647 * of all possible flags.
648 */
649 public class Intent implements Parcelable, Cloneable {
650 private static final String TAG = "Intent";
651
652 private static final String ATTR_ACTION = "action";
653 private static final String TAG_CATEGORIES = "categories";
654 private static final String ATTR_CATEGORY = "category";
655 private static final String TAG_EXTRA = "extra";
656 private static final String ATTR_TYPE = "type";
657 private static final String ATTR_IDENTIFIER = "ident";
658 private static final String ATTR_COMPONENT = "component";
659 private static final String ATTR_DATA = "data";
660 private static final String ATTR_FLAGS = "flags";
661
662 // ---------------------------------------------------------------------
663 // ---------------------------------------------------------------------
664 // Standard intent activity actions (see action variable).
665
666 /**
667 * Activity Action: Start as a main entry point, does not expect to
668 * receive data.
669 * <p>Input: nothing
670 * <p>Output: nothing
671 */
672 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
673 public static final String ACTION_MAIN = "android.intent.action.MAIN";
674
675 /**
676 * Activity Action: Display the data to the user. This is the most common
677 * action performed on data -- it is the generic action you can use on
678 * a piece of data to get the most reasonable thing to occur. For example,
679 * when used on a contacts entry it will view the entry; when used on a
680 * mailto: URI it will bring up a compose window filled with the information
681 * supplied by the URI; when used with a tel: URI it will invoke the
682 * dialer.
683 * <p>Input: {@link #getData} is URI from which to retrieve data.
684 * <p>Output: nothing.
685 */
686 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
687 public static final String ACTION_VIEW = "android.intent.action.VIEW";
688
689 /**
690 * Extra that can be included on activity intents coming from the storage UI
691 * when it launches sub-activities to manage various types of storage. For example,
692 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
693 * the images on the device, and in that case also include this extra to tell the
694 * app it is coming from the storage UI so should help the user manage storage of
695 * this type.
696 */
697 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
698
699 /**
700 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
701 * performed on a piece of data.
702 */
703 public static final String ACTION_DEFAULT = ACTION_VIEW;
704
705 /**
706 * Activity Action: Quick view the data. Launches a quick viewer for
707 * a URI or a list of URIs.
708 * <p>Activities handling this intent action should handle the vast majority of
709 * MIME types rather than only specific ones.
710 * <p>Quick viewers must render the quick view image locally, and must not send
711 * file content outside current device.
712 * <p>Input: {@link #getData} is a mandatory content URI of the item to
713 * preview. {@link #getClipData} contains an optional list of content URIs
714 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
715 * optional index of the URI in the clip data to show first.
716 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
717 * that can be shown in the quick view UI.
718 * <p>Output: nothing.
719 * @see #EXTRA_INDEX
720 * @see #EXTRA_QUICK_VIEW_FEATURES
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
724
725 /**
726 * Used to indicate that some piece of data should be attached to some other
727 * place. For example, image data could be attached to a contact. It is up
728 * to the recipient to decide where the data should be attached; the intent
729 * does not specify the ultimate destination.
730 * <p>Input: {@link #getData} is URI of data to be attached.
731 * <p>Output: nothing.
732 */
733 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
734 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
735
736 /**
737 * Activity Action: Provide explicit editable access to the given data.
738 * <p>Input: {@link #getData} is URI of data to be edited.
739 * <p>Output: nothing.
740 */
741 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
742 public static final String ACTION_EDIT = "android.intent.action.EDIT";
743
744 /**
745 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
746 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
747 * The extras can contain type specific data to pass through to the editing/creating
748 * activity.
749 * <p>Output: The URI of the item that was picked. This must be a content:
750 * URI so that any receiver can access it.
751 */
752 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
753 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
754
755 /**
756 * Activity Action: Pick an item from the data, returning what was selected.
757 * <p>Input: {@link #getData} is URI containing a directory of data
758 * (vnd.android.cursor.dir/*) from which to pick an item.
759 * <p>Output: The URI of the item that was picked.
760 */
761 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
762 public static final String ACTION_PICK = "android.intent.action.PICK";
763
764 /**
765 * Activity Action: Creates a reminder.
766 * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user.
767 * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at
768 * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will
769 * be shown to the user. The time is specified in milliseconds since the Epoch (optional).
770 * </p>
771 * <p>Output: Nothing.</p>
772 *
773 * @see #EXTRA_TITLE
774 * @see #EXTRA_TEXT
775 * @see #EXTRA_TIME
776 */
777 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
778 public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER";
779
780 /**
781 * Activity Action: Creates a shortcut.
782 * <p>Input: Nothing.</p>
783 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
784 * <p>For compatibility with older versions of android the intent may also contain three
785 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
786 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
787 * (value: ShortcutIconResource).</p>
788 *
789 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
790 * @see #EXTRA_SHORTCUT_INTENT
791 * @see #EXTRA_SHORTCUT_NAME
792 * @see #EXTRA_SHORTCUT_ICON
793 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
794 * @see android.content.Intent.ShortcutIconResource
795 */
796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
797 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
798
799 /**
800 * The name of the extra used to define the Intent of a shortcut.
801 *
802 * @see #ACTION_CREATE_SHORTCUT
803 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
804 */
805 @Deprecated
806 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
807 /**
808 * The name of the extra used to define the name of a shortcut.
809 *
810 * @see #ACTION_CREATE_SHORTCUT
811 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
812 */
813 @Deprecated
814 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
815 /**
816 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
817 *
818 * @see #ACTION_CREATE_SHORTCUT
819 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
820 */
821 @Deprecated
822 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
823 /**
824 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
825 *
826 * @see #ACTION_CREATE_SHORTCUT
827 * @see android.content.Intent.ShortcutIconResource
828 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
829 */
830 @Deprecated
831 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
832 "android.intent.extra.shortcut.ICON_RESOURCE";
833
834 /**
835 * An activity that provides a user interface for adjusting application preferences.
836 * Optional but recommended settings for all applications which have settings.
837 */
838 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
839 public static final String ACTION_APPLICATION_PREFERENCES
840 = "android.intent.action.APPLICATION_PREFERENCES";
841
842 /**
843 * Activity Action: Launch an activity showing the app information.
844 * For applications which install other applications (such as app stores), it is recommended
845 * to handle this action for providing the app information to the user.
846 *
847 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
848 * to be displayed.
849 * <p>Output: Nothing.
850 */
851 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
852 public static final String ACTION_SHOW_APP_INFO
853 = "android.intent.action.SHOW_APP_INFO";
854
855 /**
856 * Activity Action: Placeholder that the component handling it can do activity
857 * recognition. Can be placed on a service. Only one service per package is
858 * supported.
859 *
860 * <p>Input: Nothing.</p>
861 * <p>Output: Nothing </p>
862 *
863 * @hide
864 */
865 @SystemApi
866 @SdkConstant(SdkConstantType.SERVICE_ACTION)
867 public static final String ACTION_ACTIVITY_RECOGNIZER =
868 "android.intent.action.ACTIVITY_RECOGNIZER";
869
870 /**
871 * Represents a shortcut/live folder icon resource.
872 *
873 * @see Intent#ACTION_CREATE_SHORTCUT
874 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
875 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
876 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
877 */
878 public static class ShortcutIconResource implements Parcelable {
879 /**
880 * The package name of the application containing the icon.
881 */
882 public String packageName;
883
884 /**
885 * The resource name of the icon, including package, name and type.
886 */
887 public String resourceName;
888
889 /**
890 * Creates a new ShortcutIconResource for the specified context and resource
891 * identifier.
892 *
893 * @param context The context of the application.
894 * @param resourceId The resource identifier for the icon.
895 * @return A new ShortcutIconResource with the specified's context package name
896 * and icon resource identifier.``
897 */
898 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
899 ShortcutIconResource icon = new ShortcutIconResource();
900 icon.packageName = context.getPackageName();
901 icon.resourceName = context.getResources().getResourceName(resourceId);
902 return icon;
903 }
904
905 /**
906 * Used to read a ShortcutIconResource from a Parcel.
907 */
908 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR =
909 new Parcelable.Creator<ShortcutIconResource>() {
910
911 public ShortcutIconResource createFromParcel(Parcel source) {
912 ShortcutIconResource icon = new ShortcutIconResource();
913 icon.packageName = source.readString8();
914 icon.resourceName = source.readString8();
915 return icon;
916 }
917
918 public ShortcutIconResource[] newArray(int size) {
919 return new ShortcutIconResource[size];
920 }
921 };
922
923 /**
924 * No special parcel contents.
925 */
926 public int describeContents() {
927 return 0;
928 }
929
930 public void writeToParcel(Parcel dest, int flags) {
931 dest.writeString8(packageName);
932 dest.writeString8(resourceName);
933 }
934
935 @Override
936 public String toString() {
937 return resourceName;
938 }
939 }
940
941 /**
942 * Activity Action: Display an activity chooser, allowing the user to pick
943 * what they want to before proceeding. This can be used as an alternative
944 * to the standard activity picker that is displayed by the system when
945 * you try to start an activity with multiple possible matches, with these
946 * differences in behavior:
947 * <ul>
948 * <li>You can specify the title that will appear in the activity chooser.
949 * <li>The user does not have the option to make one of the matching
950 * activities a preferred activity, and all possible activities will
951 * always be shown even if one of them is currently marked as the
952 * preferred activity.
953 * </ul>
954 * <p>
955 * This action should be used when the user will naturally expect to
956 * select an activity in order to proceed. An example if when not to use
957 * it is when the user clicks on a "mailto:" link. They would naturally
958 * expect to go directly to their mail app, so startActivity() should be
959 * called directly: it will
960 * either launch the current preferred app, or put up a dialog allowing the
961 * user to pick an app to use and optionally marking that as preferred.
962 * <p>
963 * In contrast, if the user is selecting a menu item to send a picture
964 * they are viewing to someone else, there are many different things they
965 * may want to do at this point: send it through e-mail, upload it to a
966 * web service, etc. In this case the CHOOSER action should be used, to
967 * always present to the user a list of the things they can do, with a
968 * nice title given by the caller such as "Send this photo with:".
969 * <p>
970 * If you need to grant URI permissions through a chooser, you must specify
971 * the permissions to be granted on the ACTION_CHOOSER Intent
972 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
973 * {@link #setClipData} to specify the URIs to be granted as well as
974 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
975 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
976 * <p>
977 * As a convenience, an Intent of this form can be created with the
978 * {@link #createChooser} function.
979 * <p>
980 * Input: No data should be specified. get*Extra must have
981 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
982 * and can optionally have a {@link #EXTRA_TITLE} field containing the
983 * title text to display in the chooser.
984 * <p>
985 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
986 */
987 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
988 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
989
990 /**
991 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
992 *
993 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
994 * target intent, also optionally supplying a title. If the target
995 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
996 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
997 * set in the returned chooser intent, with its ClipData set appropriately:
998 * either a direct reflection of {@link #getClipData()} if that is non-null,
999 * or a new ClipData built from {@link #getData()}.
1000 *
1001 * @param target The Intent that the user will be selecting an activity
1002 * to perform.
1003 * @param title Optional title that will be displayed in the chooser,
1004 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1005 * @return Return a new Intent object that you can hand to
1006 * {@link Context#startActivity(Intent) Context.startActivity()} and
1007 * related methods.
1008 */
1009 public static Intent createChooser(Intent target, CharSequence title) {
1010 return createChooser(target, title, null);
1011 }
1012
1013 /**
1014 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
1015 *
1016 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
1017 * target intent, also optionally supplying a title. If the target
1018 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
1019 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
1020 * set in the returned chooser intent, with its ClipData set appropriately:
1021 * either a direct reflection of {@link #getClipData()} if that is non-null,
1022 * or a new ClipData built from {@link #getData()}.</p>
1023 *
1024 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
1025 * when the user makes a choice. This can be useful if the calling application wants
1026 * to remember the last chosen target and surface it as a more prominent or one-touch
1027 * affordance elsewhere in the UI for next time.</p>
1028 *
1029 * @param target The Intent that the user will be selecting an activity
1030 * to perform.
1031 * @param title Optional title that will be displayed in the chooser,
1032 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1033 * @param sender Optional IntentSender to be called when a choice is made.
1034 * @return Return a new Intent object that you can hand to
1035 * {@link Context#startActivity(Intent) Context.startActivity()} and
1036 * related methods.
1037 */
1038 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
1039 Intent intent = new Intent(ACTION_CHOOSER);
1040 intent.putExtra(EXTRA_INTENT, target);
1041 if (title != null) {
1042 intent.putExtra(EXTRA_TITLE, title);
1043 }
1044
1045 if (sender != null) {
1046 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
1047 }
1048
1049 // Migrate any clip data and flags from target.
1050 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1051 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1052 | FLAG_GRANT_PREFIX_URI_PERMISSION);
1053 if (permFlags != 0) {
1054 ClipData targetClipData = target.getClipData();
1055 if (targetClipData == null && target.getData() != null) {
1056 ClipData.Item item = new ClipData.Item(target.getData());
1057 String[] mimeTypes;
1058 if (target.getType() != null) {
1059 mimeTypes = new String[] { target.getType() };
1060 } else {
1061 mimeTypes = new String[] { };
1062 }
1063 targetClipData = new ClipData(null, mimeTypes, item);
1064 }
1065 if (targetClipData != null) {
1066 intent.setClipData(targetClipData);
1067 intent.addFlags(permFlags);
1068 }
1069 }
1070
1071 return intent;
1072 }
1073
1074 /**
1075 * Activity Action: Allow the user to select a particular kind of data and
1076 * return it. This is different than {@link #ACTION_PICK} in that here we
1077 * just say what kind of data is desired, not a URI of existing data from
1078 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
1079 * create the data as it runs (for example taking a picture or recording a
1080 * sound), let them browse over the web and download the desired data,
1081 * etc.
1082 * <p>
1083 * There are two main ways to use this action: if you want a specific kind
1084 * of data, such as a person contact, you set the MIME type to the kind of
1085 * data you want and launch it with {@link Context#startActivity(Intent)}.
1086 * The system will then launch the best application to select that kind
1087 * of data for you.
1088 * <p>
1089 * You may also be interested in any of a set of types of content the user
1090 * can pick. For example, an e-mail application that wants to allow the
1091 * user to add an attachment to an e-mail message can use this action to
1092 * bring up a list of all of the types of content the user can attach.
1093 * <p>
1094 * In this case, you should wrap the GET_CONTENT intent with a chooser
1095 * (through {@link #createChooser}), which will give the proper interface
1096 * for the user to pick how to send your data and allow you to specify
1097 * a prompt indicating what they are doing. You will usually specify a
1098 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1099 * broad range of content types the user can select from.
1100 * <p>
1101 * When using such a broad GET_CONTENT action, it is often desirable to
1102 * only pick from data that can be represented as a stream. This is
1103 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1104 * <p>
1105 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
1106 * the launched content chooser only returns results representing data that
1107 * is locally available on the device. For example, if this extra is set
1108 * to true then an image picker should not show any pictures that are available
1109 * from a remote server but not already on the local device (thus requiring
1110 * they be downloaded when opened).
1111 * <p>
1112 * If the caller can handle multiple returned items (the user performing
1113 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1114 * to indicate this.
1115 * <p>
1116 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1117 * that no URI is supplied in the intent, as there are no constraints on
1118 * where the returned data originally comes from. You may also include the
1119 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
1120 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
1121 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1122 * allow the user to select multiple items.
1123 * <p>
1124 * Output: The URI of the item that was picked. This must be a content:
1125 * URI so that any receiver can access it.
1126 */
1127 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1128 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1129 /**
1130 * Activity Action: Dial a number as specified by the data. This shows a
1131 * UI with the number being dialed, allowing the user to explicitly
1132 * initiate the call.
1133 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1134 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1135 * number.
1136 * <p>Output: nothing.
1137 */
1138 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1139 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1140 /**
1141 * Activity Action: Perform a call to someone specified by the data.
1142 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1143 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1144 * number.
1145 * <p>Output: nothing.
1146 *
1147 * <p>Note: there will be restrictions on which applications can initiate a
1148 * call; most applications should use the {@link #ACTION_DIAL}.
1149 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1150 * numbers. Applications can <strong>dial</strong> emergency numbers using
1151 * {@link #ACTION_DIAL}, however.
1152 *
1153 * <p>Note: An app filling the {@link android.app.role.RoleManager#ROLE_DIALER} role should use
1154 * {@link android.telecom.TelecomManager#placeCall(Uri, Bundle)} to place calls rather than
1155 * relying on this intent.
1156 *
1157 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
1158 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
1159 * permission which is not granted, then attempting to use this action will
1160 * result in a {@link java.lang.SecurityException}.
1161 */
1162 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1163 public static final String ACTION_CALL = "android.intent.action.CALL";
1164 /**
1165 * Activity Action: Perform a call to an emergency number specified by the
1166 * data.
1167 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1168 * tel: URI of an explicit phone number.
1169 * <p>Output: nothing.
1170 *
1171 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on
1172 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
1173 * extra (if specified) and may be placed on another {@link PhoneAccount} with the
1174 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external
1175 * factors, such as network conditions and Modem/SIM status.
1176 * @hide
1177 */
1178 @SystemApi
1179 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1180 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1181 /**
1182 * Activity Action: Dial a emergency number specified by the data. This shows a
1183 * UI with the number being dialed, allowing the user to explicitly
1184 * initiate the call.
1185 * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData}
1186 * is a tel: URI of an explicit emergency phone number.
1187 * <p>Output: nothing.
1188 * @hide
1189 */
1190 @SystemApi
1191 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1192 public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY";
1193 /**
1194 * Activity action: Perform a call to any number (emergency or not)
1195 * specified by the data.
1196 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1197 * tel: URI of an explicit phone number.
1198 * <p>Output: nothing.
1199 * @hide
1200 */
1201 @SystemApi
1202 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1203 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1204
1205 /**
1206 * Activity Action: Main entry point for carrier setup apps.
1207 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1208 * carrier service and typically require
1209 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1210 * fulfill their duties.
1211 */
1212 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1213 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1214 /**
1215 * Activity Action: Send a message to someone specified by the data.
1216 * <p>Input: {@link #getData} is URI describing the target.
1217 * <p>Output: nothing.
1218 */
1219 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1220 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1221 /**
1222 * Activity Action: Deliver some data to someone else. Who the data is
1223 * being delivered to is not specified; it is up to the receiver of this
1224 * action to ask the user where the data should be sent.
1225 * <p>
1226 * When launching a SEND intent, you should usually wrap it in a chooser
1227 * (through {@link #createChooser}), which will give the proper interface
1228 * for the user to pick how to send your data and allow you to specify
1229 * a prompt indicating what they are doing.
1230 * <p>
1231 * Input: {@link #getType} is the MIME type of the data being sent.
1232 * get*Extra can have either a {@link #EXTRA_TEXT}
1233 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1234 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1235 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1236 * if the MIME type is unknown (this will only allow senders that can
1237 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1238 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1239 * your text with HTML formatting.
1240 * <p>
1241 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1242 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1243 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1244 * content: URIs and other advanced features of {@link ClipData}. If
1245 * using this approach, you still must supply the same data through the
1246 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1247 * for compatibility with old applications. If you don't set a ClipData,
1248 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1249 * <p>
1250 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1251 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1252 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1253 * be openable only as asset typed files using
1254 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1255 * <p>
1256 * Optional standard extras, which may be interpreted by some recipients as
1257 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1258 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1259 * <p>
1260 * Output: nothing.
1261 */
1262 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1263 public static final String ACTION_SEND = "android.intent.action.SEND";
1264 /**
1265 * Activity Action: Deliver multiple data to someone else.
1266 * <p>
1267 * Like {@link #ACTION_SEND}, except the data is multiple.
1268 * <p>
1269 * Input: {@link #getType} is the MIME type of the data being sent.
1270 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
1271 * #EXTRA_STREAM} field, containing the data to be sent. If using
1272 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1273 * for clients to retrieve your text with HTML formatting.
1274 * <p>
1275 * Multiple types are supported, and receivers should handle mixed types
1276 * whenever possible. The right way for the receiver to check them is to
1277 * use the content resolver on each URI. The intent sender should try to
1278 * put the most concrete mime type in the intent type, but it can fall
1279 * back to {@literal <type>/*} or {@literal *}/* as needed.
1280 * <p>
1281 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1282 * be image/jpg, but if you are sending image/jpg and image/png, then the
1283 * intent's type should be image/*.
1284 * <p>
1285 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1286 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1287 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1288 * content: URIs and other advanced features of {@link ClipData}. If
1289 * using this approach, you still must supply the same data through the
1290 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1291 * for compatibility with old applications. If you don't set a ClipData,
1292 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1293 * <p>
1294 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1295 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1296 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1297 * be openable only as asset typed files using
1298 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1299 * <p>
1300 * Optional standard extras, which may be interpreted by some recipients as
1301 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1302 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1303 * <p>
1304 * Output: nothing.
1305 */
1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1307 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1308 /**
1309 * Activity Action: Handle an incoming phone call.
1310 * <p>Input: nothing.
1311 * <p>Output: nothing.
1312 */
1313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1314 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1315 /**
1316 * Activity Action: Insert an empty item into the given container.
1317 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1318 * in which to place the data.
1319 * <p>Output: URI of the new data that was created.
1320 */
1321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1323 /**
1324 * Activity Action: Create a new item in the given container, initializing it
1325 * from the current contents of the clipboard.
1326 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1327 * in which to place the data.
1328 * <p>Output: URI of the new data that was created.
1329 */
1330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1331 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1332 /**
1333 * Activity Action: Delete the given data from its container.
1334 * <p>Input: {@link #getData} is URI of data to be deleted.
1335 * <p>Output: nothing.
1336 */
1337 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1338 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1339 /**
1340 * Activity Action: Run the data, whatever that means.
1341 * <p>Input: ? (Note: this is currently specific to the test harness.)
1342 * <p>Output: nothing.
1343 */
1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345 public static final String ACTION_RUN = "android.intent.action.RUN";
1346 /**
1347 * Activity Action: Perform a data synchronization.
1348 * <p>Input: ?
1349 * <p>Output: ?
1350 */
1351 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1352 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1353 /**
1354 * Activity Action: Pick an activity given an intent, returning the class
1355 * selected.
1356 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1357 * used with {@link PackageManager#queryIntentActivities} to determine the
1358 * set of activities from which to pick.
1359 * <p>Output: Class name of the activity that was selected.
1360 */
1361 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1362 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1363 /**
1364 * Activity Action: Perform a search.
1365 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1366 * is the text to search for. If empty, simply
1367 * enter your search results Activity with the search UI activated.
1368 * <p>Output: nothing.
1369 */
1370 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1371 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1372 /**
1373 * Activity Action: Start the platform-defined tutorial
1374 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1375 * is the text to search for. If empty, simply
1376 * enter your search results Activity with the search UI activated.
1377 * <p>Output: nothing.
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1381 /**
1382 * Activity Action: Perform a web search.
1383 * <p>
1384 * Input: {@link android.app.SearchManager#QUERY
1385 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1386 * a url starts with http or https, the site will be opened. If it is plain
1387 * text, Google search will be applied.
1388 * <p>
1389 * Output: nothing.
1390 */
1391 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1392 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1393
1394 /**
1395 * Activity Action: Perform assist action.
1396 * <p>
1397 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1398 * additional optional contextual information about where the user was when they
1399 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1400 * information.
1401 * Output: nothing.
1402 */
1403 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1404 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1405
1406 /**
1407 * Activity Action: Perform voice assist action.
1408 * <p>
1409 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1410 * additional optional contextual information about where the user was when they
1411 * requested the voice assist.
1412 * Output: nothing.
1413 * @hide
1414 */
1415 @SystemApi
1416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1417 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1418
1419 /**
1420 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1421 * application package at the time the assist was invoked.
1422 */
1423 public static final String EXTRA_ASSIST_PACKAGE
1424 = "android.intent.extra.ASSIST_PACKAGE";
1425
1426 /**
1427 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1428 * application package at the time the assist was invoked.
1429 */
1430 public static final String EXTRA_ASSIST_UID
1431 = "android.intent.extra.ASSIST_UID";
1432
1433 /**
1434 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1435 * information supplied by the current foreground app at the time of the assist request.
1436 * This is a {@link Bundle} of additional data.
1437 */
1438 public static final String EXTRA_ASSIST_CONTEXT
1439 = "android.intent.extra.ASSIST_CONTEXT";
1440
1441 /**
1442 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1443 * keyboard as the primary input device for assistance.
1444 */
1445 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1446 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1447
1448 /**
1449 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1450 * that was used to invoke the assist.
1451 */
1452 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1453 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1454
1455 /**
1456 * Activity Action: List all available applications.
1457 * <p>Input: Nothing.
1458 * <p>Output: nothing.
1459 */
1460 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1461 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1462
1463 /**
1464 * Activity Action: Action to show the list of all work apps in the launcher. For example,
1465 * shows the work apps folder or tab.
1466 *
1467 * <p>Input: Nothing.
1468 * <p>Output: nothing.
1469 */
1470 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1471 public static final String ACTION_SHOW_WORK_APPS =
1472 "android.intent.action.SHOW_WORK_APPS";
1473
1474 /**
1475 * Activity Action: Show settings for choosing wallpaper.
1476 * <p>Input: Nothing.
1477 * <p>Output: Nothing.
1478 */
1479 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1480 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1481
1482 /**
1483 * Activity Action: Show activity for reporting a bug.
1484 * <p>Input: Nothing.
1485 * <p>Output: Nothing.
1486 */
1487 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1488 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1489
1490 /**
1491 * Activity Action: Main entry point for factory tests. Only used when
1492 * the device is booting in factory test node. The implementing package
1493 * must be installed in the system image.
1494 * <p>Input: nothing
1495 * <p>Output: nothing
1496 */
1497 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1498 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1499
1500 /**
1501 * Activity Action: The user pressed the "call" button to go to the dialer
1502 * or other appropriate UI for placing a call.
1503 * <p>Input: Nothing.
1504 * <p>Output: Nothing.
1505 */
1506 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1507 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1508
1509 /**
1510 * Activity Action: Start Voice Command.
1511 * <p>Input: Nothing.
1512 * <p>Output: Nothing.
1513 * <p class="note">
1514 * In some cases, a matching Activity may not exist, so ensure you
1515 * safeguard against this.
1516 */
1517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1518 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1519
1520 /**
1521 * Activity Action: Start action associated with long pressing on the
1522 * search key.
1523 * <p>Input: Nothing.
1524 * <p>Output: Nothing.
1525 */
1526 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1527 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1528
1529 /**
1530 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1531 * This intent is delivered to the package which installed the application, usually
1532 * Google Play.
1533 * <p>Input: No data is specified. The bug report is passed in using
1534 * an {@link #EXTRA_BUG_REPORT} field.
1535 * <p>Output: Nothing.
1536 *
1537 * @see #EXTRA_BUG_REPORT
1538 */
1539 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1540 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1541
1542 /**
1543 * An incident or bug report has been taken, and a system app has requested it to be shared,
1544 * so trigger the confirmation screen.
1545 *
1546 * This will be sent directly to the registered receiver with the
1547 * android.permission.APPROVE_INCIDENT_REPORTS permission.
1548 * @hide
1549 */
1550 @SystemApi
1551 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1552 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1553
1554 /**
1555 * An incident report has been taken, and the user has approved it for sharing.
1556 * <p>
1557 * This will be sent directly to the registered receiver, which must have
1558 * both the DUMP and USAGE_STATS permissions.
1559 * <p>
1560 * After receiving this, the application should wait until a suitable time
1561 * (e.g. network available), get the list of available reports with
1562 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1563 * and then when the reports have been successfully uploaded, call
1564 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1565 *
1566 * @hide
1567 */
1568 @SystemApi
1569 public static final String ACTION_INCIDENT_REPORT_READY =
1570 "android.intent.action.INCIDENT_REPORT_READY";
1571
1572 /**
1573 * Activity Action: Show power usage information to the user.
1574 * <p>Input: Nothing.
1575 * <p>Output: Nothing.
1576 */
1577 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1578 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1579
1580 /**
1581 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1582 * to run.
1583 * <p>Input: Nothing.
1584 * <p>Output: Nothing.
1585 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1586 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1587 * @hide
1588 * @removed
1589 */
1590 @Deprecated
1591 @SystemApi
1592 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1593 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1594
1595 /**
1596 * Activity Action: Setup wizard to launch after a platform update. This
1597 * activity should have a string meta-data field associated with it,
1598 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1599 * the platform for setup. The activity will be launched only if
1600 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1601 * same value.
1602 * <p>Input: Nothing.
1603 * <p>Output: Nothing.
1604 * @hide
1605 */
1606 @SystemApi
1607 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1608 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1609
1610 /**
1611 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1612 * <p>Input: Nothing.
1613 * <p>Output: Nothing.
1614 * @hide
1615 */
1616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1617 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1618 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1619
1620 /**
1621 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1622 * <p>Input: Nothing.
1623 * <p>Output: Nothing.
1624 * @hide
1625 */
1626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1627 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1628 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1629
1630 /**
1631 * Activity Action: Show settings for managing network data usage of a
1632 * specific application. Applications should define an activity that offers
1633 * options to control data usage.
1634 */
1635 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1636 public static final String ACTION_MANAGE_NETWORK_USAGE =
1637 "android.intent.action.MANAGE_NETWORK_USAGE";
1638
1639 /**
1640 * Activity Action: Launch application installer.
1641 * <p>
1642 * Input: The data must be a content: URI at which the application
1643 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1644 * you can also use "package:<package-name>" to install an application for the
1645 * current user that is already installed for another user. You can optionally supply
1646 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1647 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1648 * <p>
1649 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1650 * succeeded.
1651 * <p>
1652 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
1653 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1654 * in order to launch the application installer.
1655 * </p>
1656 *
1657 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1658 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1659 * @see #EXTRA_RETURN_RESULT
1660 *
1661 * @deprecated use {@link android.content.pm.PackageInstaller} instead
1662 */
1663 @Deprecated
1664 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1665 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1666
1667 /**
1668 * Activity Action: Activity to handle split installation failures.
1669 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1670 * but the split that contains the application isn't installed. When a split is
1671 * installed in this manner, the containing package usually doesn't know this is
1672 * happening. However, if an error occurs during installation, the containing
1673 * package can define a single activity handling this action to deal with such
1674 * failures.
1675 * <p>The activity handling this action must be in the base package.
1676 * <p>
1677 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1678 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1679 */
1680 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1681 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1682
1683 /**
1684 * Activity Action: Launch instant application installer.
1685 * <p class="note">
1686 * This is a protected intent that can only be sent by the system.
1687 * </p>
1688 *
1689 * @hide
1690 */
1691 @SystemApi
1692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1693 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1694 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
1695
1696 /**
1697 * Service Action: Resolve instant application.
1698 * <p>
1699 * The system will have a persistent connection to this service.
1700 * This is a protected intent that can only be sent by the system.
1701 * </p>
1702 *
1703 * @hide
1704 */
1705 @SystemApi
1706 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1707 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1708 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
1709
1710 /**
1711 * Activity Action: Launch instant app settings.
1712 *
1713 * <p class="note">
1714 * This is a protected intent that can only be sent by the system.
1715 * </p>
1716 *
1717 * @hide
1718 */
1719 @SystemApi
1720 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1721 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1722 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
1723
1724 /**
1725 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1726 * package. Specifies the installer package name; this package will receive the
1727 * {@link #ACTION_APP_ERROR} intent.
1728 */
1729 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1730 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1731
1732 /**
1733 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1734 * package. Specifies that the application being installed should not be
1735 * treated as coming from an unknown source, but as coming from the app
1736 * invoking the Intent. For this to work you must start the installer with
1737 * startActivityForResult().
1738 */
1739 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1740 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1741
1742 /**
1743 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1744 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
1745 * data field originated from.
1746 */
1747 public static final String EXTRA_ORIGINATING_URI
1748 = "android.intent.extra.ORIGINATING_URI";
1749
1750 /**
1751 * This extra can be used with any Intent used to launch an activity, supplying information
1752 * about who is launching that activity. This field contains a {@link android.net.Uri}
1753 * object, typically an http: or https: URI of the web site that the referral came from;
1754 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1755 * a native application that it came from.
1756 *
1757 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1758 * instead of directly retrieving the extra. It is also valid for applications to
1759 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1760 * a string, not a Uri; the field here, if supplied, will always take precedence,
1761 * however.</p>
1762 *
1763 * @see #EXTRA_REFERRER_NAME
1764 */
1765 public static final String EXTRA_REFERRER
1766 = "android.intent.extra.REFERRER";
1767
1768 /**
1769 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1770 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1771 * not be created, in particular when Intent extras are supplied through the
1772 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1773 * schemes.
1774 *
1775 * @see #EXTRA_REFERRER
1776 */
1777 public static final String EXTRA_REFERRER_NAME
1778 = "android.intent.extra.REFERRER_NAME";
1779
1780 /**
1781 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1782 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
1783 * Currently only a system app that hosts the provider authority "downloads" or holds the
1784 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
1785 * @hide
1786 */
1787 @SystemApi
1788 public static final String EXTRA_ORIGINATING_UID
1789 = "android.intent.extra.ORIGINATING_UID";
1790
1791 /**
1792 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1793 * package. Tells the installer UI to skip the confirmation with the user
1794 * if the .apk is replacing an existing one.
1795 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1796 * will no longer show an interstitial message about updating existing
1797 * applications so this is no longer needed.
1798 */
1799 @Deprecated
1800 public static final String EXTRA_ALLOW_REPLACE
1801 = "android.intent.extra.ALLOW_REPLACE";
1802
1803 /**
1804 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1805 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1806 * return to the application the result code of the install/uninstall. The returned result
1807 * code will be {@link android.app.Activity#RESULT_OK} on success or
1808 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1809 */
1810 public static final String EXTRA_RETURN_RESULT
1811 = "android.intent.extra.RETURN_RESULT";
1812
1813 /**
1814 * Package manager install result code. @hide because result codes are not
1815 * yet ready to be exposed.
1816 */
1817 public static final String EXTRA_INSTALL_RESULT
1818 = "android.intent.extra.INSTALL_RESULT";
1819
1820 /**
1821 * Activity Action: Launch application uninstaller.
1822 * <p>
1823 * Input: The data must be a package: URI whose scheme specific part is
1824 * the package name of the current installed package to be uninstalled.
1825 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1826 * <p>
1827 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the uninstall
1828 * succeeded.
1829 * <p>
1830 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1831 * since {@link Build.VERSION_CODES#P}.
1832 *
1833 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1834 * instead
1835 */
1836 @Deprecated
1837 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1838 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1839
1840 /**
1841 * Specify whether the package should be uninstalled for all users.
1842 * @hide because these should not be part of normal application flow.
1843 */
1844 public static final String EXTRA_UNINSTALL_ALL_USERS
1845 = "android.intent.extra.UNINSTALL_ALL_USERS";
1846
1847 /**
1848 * A string that associates with a metadata entry, indicating the last run version of the
1849 * platform that was setup.
1850 *
1851 * @see #ACTION_UPGRADE_SETUP
1852 *
1853 * @hide
1854 */
1855 @SystemApi
1856 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1857
1858 /**
1859 * Activity action: Launch UI to manage the permissions of an app.
1860 * <p>
1861 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1862 * will be managed by the launched UI.
1863 * </p>
1864 * <p>
1865 * Output: Nothing.
1866 * </p>
1867 *
1868 * @see #EXTRA_PACKAGE_NAME
1869 *
1870 * @hide
1871 */
1872 @SystemApi
1873 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1874 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1875 "android.intent.action.MANAGE_APP_PERMISSIONS";
1876
1877 /**
1878 * Activity action: Launch UI to manage a specific permission group of an app.
1879 * <p>
1880 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1881 * will be managed by the launched UI.
1882 * </p>
1883 * <p>
1884 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1885 * whose group should be managed by the launched UI.
1886 * </p>
1887 * <p>
1888 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group
1889 * that should be managed by the launched UI. Do not send both this and EXTRA_PERMISSION_NAME
1890 * together.
1891 * </p>
1892 * <p>
1893 * <li> {@link #EXTRA_USER} specifies the {@link UserHandle} of the user that owns the app.
1894 * </p>
1895 * <p>
1896 * Output: Nothing.
1897 * </p>
1898 *
1899 * @see #EXTRA_PACKAGE_NAME
1900 * @see #EXTRA_PERMISSION_NAME
1901 * @see #EXTRA_PERMISSION_GROUP_NAME
1902 * @see #EXTRA_USER
1903 *
1904 * @hide
1905 */
1906 @SystemApi
1907 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1908 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1909 public static final String ACTION_MANAGE_APP_PERMISSION =
1910 "android.intent.action.MANAGE_APP_PERMISSION";
1911
1912 /**
1913 * Activity action: Launch UI to manage permissions.
1914 * <p>
1915 * Input: Nothing.
1916 * </p>
1917 * <p>
1918 * Output: Nothing.
1919 * </p>
1920 *
1921 * @hide
1922 */
1923 @SystemApi
1924 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1925 public static final String ACTION_MANAGE_PERMISSIONS =
1926 "android.intent.action.MANAGE_PERMISSIONS";
1927
1928 /**
1929 * Activity action: Launch UI to manage auto-revoke state.
1930 *
1931 * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS
1932 *
1933 * <p>
1934 * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with
1935 * a package name, whose auto-revoke state will be reviewed (mandatory).
1936 * E.g. {@code Uri.fromParts("package", packageName, null) }
1937 * </p>
1938 * <p>
1939 * Output: Nothing.
1940 * </p>
1941 */
1942 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1943 public static final String ACTION_AUTO_REVOKE_PERMISSIONS =
1944 "android.intent.action.AUTO_REVOKE_PERMISSIONS";
1945
1946 /**
1947 * Activity action: Launch UI to manage unused apps (hibernated apps).
1948 *
1949 * <p>
1950 * Input: Nothing.
1951 * </p>
1952 * <p>
1953 * Output: Nothing.
1954 * </p>
1955 */
1956 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1957 public static final String ACTION_MANAGE_UNUSED_APPS =
1958 "android.intent.action.MANAGE_UNUSED_APPS";
1959
1960 /**
1961 * Activity action: Launch UI to review permissions for an app.
1962 * The system uses this intent if permission review for apps not
1963 * supporting the new runtime permissions model is enabled. In
1964 * this mode a permission review is required before any of the
1965 * app components can run.
1966 * <p>
1967 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1968 * permissions will be reviewed (mandatory).
1969 * </p>
1970 * <p>
1971 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1972 * be fired after the permission review (optional).
1973 * </p>
1974 * <p>
1975 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1976 * be invoked after the permission review (optional).
1977 * </p>
1978 * <p>
1979 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1980 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1981 * </p>
1982 * <p>
1983 * Output: Nothing.
1984 * </p>
1985 *
1986 * @see #EXTRA_PACKAGE_NAME
1987 * @see #EXTRA_INTENT
1988 * @see #EXTRA_REMOTE_CALLBACK
1989 * @see #EXTRA_RESULT_NEEDED
1990 *
1991 * @hide
1992 */
1993 @SystemApi
1994 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1995 public static final String ACTION_REVIEW_PERMISSIONS =
1996 "android.intent.action.REVIEW_PERMISSIONS";
1997
1998 /**
1999 * Activity action: Launch UI to show information about the usage
2000 * of a given permission group. This action would be handled by apps that
2001 * want to show details about how and why given permission group is being
2002 * used.
2003 * <p>
2004 * <strong>Important:</strong>You must protect the activity that handles
2005 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE
2006 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the
2007 * system can launch this activity. The system will not launch
2008 * activities that are not properly protected.
2009 *
2010 * <p>
2011 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group
2012 * for which the launched UI would be targeted.
2013 * </p>
2014 * <p>
2015 * Output: Nothing.
2016 * </p>
2017 */
2018 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2019 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
2020 public static final String ACTION_VIEW_PERMISSION_USAGE =
2021 "android.intent.action.VIEW_PERMISSION_USAGE";
2022
2023 /**
2024 * Activity action: Launch UI to show information about the usage of a given permission group in
2025 * a given period. This action would be handled by apps that want to show details about how and
2026 * why given permission group is being used.
2027 * <p>
2028 * <strong>Important:</strong>You must protect the activity that handles this action with the
2029 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that
2030 * only the system can launch this activity. The system will not launch activities that are not
2031 * properly protected.
2032 *
2033 * <p>
2034 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for which the
2035 * launched UI would be targeted.
2036 * </p>
2037 * <p>
2038 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry.
2039 * </p>
2040 * <p>
2041 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in
2042 * millis). Both start time and end time are needed and start time must be <= end time.
2043 * </p>
2044 * <p>
2045 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in
2046 * millis). Both start time and end time are needed and start time must be <= end time.
2047 * </p>
2048 * <p>
2049 * Output: Nothing.
2050 * </p>
2051 */
2052 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2053 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
2054 public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD =
2055 "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD";
2056
2057 /**
2058 * Activity action: Launch the Safety Center Quick Settings UI.
2059 *
2060 * <p>
2061 * Input: Nothing.
2062 * </p>
2063 * <p>
2064 * Output: Nothing.
2065 * </p>
2066 *
2067 * @hide
2068 */
2069 @SystemApi
2070 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2071 @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY)
2072 public static final String ACTION_VIEW_SAFETY_CENTER_QS =
2073 "android.intent.action.VIEW_SAFETY_CENTER_QS";
2074
2075 /**
2076 * Activity action: Launch UI to manage a default app.
2077 * <p>
2078 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
2079 * by the launched UI.
2080 * </p>
2081 * <p>
2082 * Output: Nothing.
2083 * </p>
2084 *
2085 * @hide
2086 */
2087 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2088 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2089 @SystemApi
2090 public static final String ACTION_MANAGE_DEFAULT_APP =
2091 "android.intent.action.MANAGE_DEFAULT_APP";
2092
2093 /**
2094 * Intent extra: A role name.
2095 * <p>
2096 * Type: String
2097 * </p>
2098 *
2099 * @see android.app.role.RoleManager
2100 *
2101 * @hide
2102 */
2103 @SystemApi
2104 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
2105
2106 /**
2107 * Activity action: Launch UI to manage special app accesses.
2108 * <p>
2109 * Input: Nothing.
2110 * </p>
2111 * <p>
2112 * Output: Nothing.
2113 * </p>
2114 *
2115 * @hide
2116 */
2117 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2118 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2119 @SystemApi
2120 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
2121 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
2122
2123 /**
2124 * Intent extra: A callback for reporting remote result as a bundle.
2125 * <p>
2126 * Type: IRemoteCallback
2127 * </p>
2128 *
2129 * @hide
2130 */
2131 @SystemApi
2132 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
2133
2134 /**
2135 * Intent extra: An app package name.
2136 * <p>
2137 * Type: String
2138 * </p>
2139 *
2140 */
2141 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
2142
2143 /**
2144 * Intent extra: A {@link android.os.LocaleList}
2145 * <p>
2146 * Type: LocaleList
2147 * </p>
2148 */
2149 public static final String EXTRA_LOCALE_LIST = "android.intent.extra.LOCALE_LIST";
2150
2151 /**
2152 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
2153 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
2154 *
2155 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
2156 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
2157 * This is meant to enable the suspended app to better handle the state of being suspended.
2158 *
2159 * @see #ACTION_MY_PACKAGE_SUSPENDED
2160 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2161 * @see PackageManager#isPackageSuspended()
2162 * @see PackageManager#getSuspendedPackageAppExtras()
2163 */
2164 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
2165
2166 /**
2167 * Intent extra: An app split name.
2168 * <p>
2169 * Type: String
2170 * </p>
2171 */
2172 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
2173
2174 /**
2175 * Intent extra: A {@link ComponentName} value.
2176 * <p>
2177 * Type: String
2178 * </p>
2179 */
2180 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
2181
2182 /**
2183 * Intent extra: An extra for specifying whether a result is needed.
2184 * <p>
2185 * Type: boolean
2186 * </p>
2187 *
2188 * @hide
2189 */
2190 @SystemApi
2191 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
2192
2193 /**
2194 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with
2195 * {@link #ACTION_SEND}.
2196 *
2197 * @see ShortcutInfo#getId()
2198 *
2199 * <p>
2200 * Type: String
2201 * </p>
2202 */
2203 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2204
2205 /**
2206 * Activity action: Launch UI to manage which apps have a given permission.
2207 * <p>
2208 * Input: {@link #EXTRA_PERMISSION_NAME} or {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the
2209 * permission group which will be managed by the launched UI.
2210 * </p>
2211 * <p>
2212 * Output: Nothing.
2213 * </p>
2214 *
2215 * @see #EXTRA_PERMISSION_NAME
2216 * @see #EXTRA_PERMISSION_GROUP_NAME
2217 *
2218 * @hide
2219 */
2220 @SystemApi
2221 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2222 public static final String ACTION_MANAGE_PERMISSION_APPS =
2223 "android.intent.action.MANAGE_PERMISSION_APPS";
2224
2225 /**
2226 * Intent extra: The name of a permission.
2227 * <p>
2228 * Type: String
2229 * </p>
2230 *
2231 * @hide
2232 */
2233 @SystemApi
2234 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2235
2236 /**
2237 * Intent extra: The name of a permission group.
2238 * <p>
2239 * Type: String
2240 * </p>
2241 */
2242 public static final String EXTRA_PERMISSION_GROUP_NAME =
2243 "android.intent.extra.PERMISSION_GROUP_NAME";
2244
2245 /**
2246 * Intent extra: The number of milliseconds.
2247 * <p>
2248 * Type: long
2249 * </p>
2250 */
2251 public static final String EXTRA_DURATION_MILLIS =
2252 "android.intent.extra.DURATION_MILLIS";
2253
2254 /**
2255 * Activity action: Launch UI to review app uses of permissions.
2256 * <p>
2257 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
2258 * that will be displayed by the launched UI. Do not pass both this and
2259 * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2260 * </p>
2261 * <p>
2262 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2263 * that will be displayed by the launched UI. Do not pass both this and
2264 * {@link #EXTRA_PERMISSION_NAME}.
2265 * </p>
2266 * <p>
2267 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2268 * activity to show (optional). Must be non-negative.
2269 * </p>
2270 * <p>
2271 * Output: Nothing.
2272 * </p>
2273 * <p class="note">
2274 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2275 * </p>
2276 *
2277 * @see #EXTRA_PERMISSION_NAME
2278 * @see #EXTRA_PERMISSION_GROUP_NAME
2279 * @see #EXTRA_DURATION_MILLIS
2280 *
2281 * @hide
2282 */
2283 @SystemApi
2284 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2286 public static final String ACTION_REVIEW_PERMISSION_USAGE =
2287 "android.intent.action.REVIEW_PERMISSION_USAGE";
2288
2289 /**
2290 * Activity action: Launch UI to review the timeline history of permissions.
2291 * <p>
2292 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2293 * that will be displayed by the launched UI.
2294 * </p>
2295 * <p>
2296 * Output: Nothing.
2297 * </p>
2298 * <p class="note">
2299 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2300 * </p>
2301 *
2302 * @see #EXTRA_PERMISSION_GROUP_NAME
2303 *
2304 * @hide
2305 */
2306 @SystemApi
2307 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2308 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2309 public static final String ACTION_REVIEW_PERMISSION_HISTORY =
2310 "android.intent.action.REVIEW_PERMISSION_HISTORY";
2311
2312 /**
2313 * Activity action: Launch UI to review ongoing app uses of permissions.
2314 * <p>
2315 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2316 * activity to show (optional). Must be non-negative.
2317 * </p>
2318 * <p>
2319 * Output: Nothing.
2320 * </p>
2321 * <p class="note">
2322 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2323 * </p>
2324 *
2325 * @see #EXTRA_DURATION_MILLIS
2326 *
2327 * @hide
2328 */
2329 @SystemApi
2330 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2332 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE =
2333 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE";
2334
2335 /**
2336 * Activity action: Launch UI to review running accessibility services.
2337 * <p>
2338 * Input: Nothing.
2339 * </p>
2340 * <p>
2341 * Output: Nothing.
2342 * </p>
2343 *
2344 * @hide
2345 */
2346 @SystemApi
2347 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES)
2348 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2349 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2350 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2351
2352 /**
2353 * Activity action: Launch UI to manage the usage of a given permission group.
2354 * This action would be handled by apps that want to show controls about the features
2355 * which use the permission group.
2356 *
2357 * <p>
2358 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for
2359 * which the launched UI would be targeted.
2360 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry.
2361 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in
2362 * millis). If both start time and end time are present, start time must be <= end time.
2363 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in
2364 * millis). If the end time is empty, that implies that the permission usage is still in use.
2365 * If both start time and end time are present, start time must be <= end time.
2366 * Input: {@link #EXTRA_SHOWING_ATTRIBUTION} specifies whether the subattribution was shown
2367 * in the UI.
2368 * </p>
2369 * <p>
2370 * Output: Nothing.
2371 * </p>
2372 * <p class="note">
2373 * You must protect the activity that handles this action with the
2374 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that
2375 * only the system can launch this activity. The system will not launch activities
2376 * that are not properly protected.
2377 * </p>
2378 *
2379 * @see #EXTRA_PERMISSION_GROUP_NAME
2380 * @see #EXTRA_ATTRIBUTION_TAGS
2381 * @see #EXTRA_START_TIME
2382 * @see #EXTRA_END_TIME
2383 * @see #EXTRA_SHOWING_ATTRIBUTION
2384 *
2385 * @hide
2386 */
2387 @SystemApi
2388 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
2389 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2390 public static final String ACTION_MANAGE_PERMISSION_USAGE =
2391 "android.intent.action.MANAGE_PERMISSION_USAGE";
2392
2393 /**
2394 * Activity action: Launch UI to view the app's feature's information.
2395 *
2396 * <p>
2397 * Output: Nothing.
2398 * </p>
2399 * <p class="note">
2400 * You must protect the activity that handles this action with the
2401 * {@link android.Manifest.permission#START_VIEW_APP_FEATURES} permission to ensure that
2402 * only the system can launch this activity. The system will not launch activities
2403 * that are not properly protected.
2404 *
2405 * An optional <meta-data> tag in the activity's manifest with
2406 * android:name=app_features_preference_summary and android:resource=@string/<string name> will
2407 * be used to add a summary line for the "All Services" preference in settings.
2408 * </p>
2409 * @hide
2410 */
2411 @SystemApi
2412 @RequiresPermission(android.Manifest.permission.START_VIEW_APP_FEATURES)
2413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2414 public static final String ACTION_VIEW_APP_FEATURES =
2415 "android.intent.action.VIEW_APP_FEATURES";
2416
2417 /**
2418 * Activity action: Launch UI to open the Safety Center, which highlights the user's security
2419 * and privacy status.
2420 */
2421 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2422 public static final String ACTION_SAFETY_CENTER =
2423 "android.intent.action.SAFETY_CENTER";
2424
2425 // ---------------------------------------------------------------------
2426 // ---------------------------------------------------------------------
2427 // Standard intent broadcast actions (see action variable).
2428
2429 /**
2430 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2431 * <p>
2432 * For historical reasons, the name of this broadcast action refers to the power
2433 * state of the screen but it is actually sent in response to changes in the
2434 * overall interactive state of the device.
2435 * </p><p>
2436 * This broadcast is sent when the device becomes non-interactive which may have
2437 * nothing to do with the screen turning off. To determine the
2438 * actual state of the screen, use {@link android.view.Display#getState}.
2439 * </p><p>
2440 * See {@link android.os.PowerManager#isInteractive} for details.
2441 * </p>
2442 * You <em>cannot</em> receive this through components declared in
2443 * manifests, only by explicitly registering for it with
2444 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2445 * Context.registerReceiver()}.
2446 *
2447 * <p class="note">This is a protected intent that can only be sent
2448 * by the system.
2449 */
2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2451 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
2452
2453 /**
2454 * Broadcast Action: Sent when the device wakes up and becomes interactive.
2455 * <p>
2456 * For historical reasons, the name of this broadcast action refers to the power
2457 * state of the screen but it is actually sent in response to changes in the
2458 * overall interactive state of the device.
2459 * </p><p>
2460 * This broadcast is sent when the device becomes interactive which may have
2461 * nothing to do with the screen turning on. To determine the
2462 * actual state of the screen, use {@link android.view.Display#getState}.
2463 * </p><p>
2464 * See {@link android.os.PowerManager#isInteractive} for details.
2465 * </p>
2466 * You <em>cannot</em> receive this through components declared in
2467 * manifests, only by explicitly registering for it with
2468 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2469 * Context.registerReceiver()}.
2470 *
2471 * <p class="note">This is a protected intent that can only be sent
2472 * by the system.
2473 */
2474 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2475 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
2476
2477 /**
2478 * Broadcast Action: Sent after the system stops dreaming.
2479 *
2480 * <p class="note">This is a protected intent that can only be sent by the system.
2481 * It is only sent to registered receivers.</p>
2482 */
2483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2484 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2485
2486 /**
2487 * Broadcast Action: Sent after the system starts dreaming.
2488 *
2489 * <p class="note">This is a protected intent that can only be sent by the system.
2490 * It is only sent to registered receivers.</p>
2491 */
2492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2493 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2494
2495 /**
2496 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
2497 * keyguard is gone).
2498 *
2499 * <p class="note">This is a protected intent that can only be sent
2500 * by the system.
2501 */
2502 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2503 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
2504
2505 /**
2506 * Broadcast Action: The current time has changed. Sent every
2507 * minute. You <em>cannot</em> receive this through components declared
2508 * in manifests, only by explicitly registering for it with
2509 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2510 * Context.registerReceiver()}.
2511 *
2512 * <p class="note">This is a protected intent that can only be sent
2513 * by the system.
2514 */
2515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2516 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2517 /**
2518 * Broadcast Action: The time was set.
2519 */
2520 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2521 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2522 /**
2523 * Broadcast Action: The date has changed.
2524 */
2525 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2526 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2527 /**
2528 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2529 * <ul>
2530 * <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new
2531 * time zone.</li>
2532 * </ul>
2533 *
2534 * <p class="note">This is a protected intent that can only be sent
2535 * by the system.
2536 */
2537 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2538 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2539 /**
2540 * Alarm Changed Action: This is broadcast when the AlarmClock
2541 * application's alarm is set or unset. It is used by the
2542 * AlarmClock application and the StatusBar service.
2543 * @hide
2544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2546 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
2547 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
2548
2549 /**
2550 * Broadcast Action: This is broadcast once, after the user has finished
2551 * booting, but while still in the "locked" state. It can be used to perform
2552 * application-specific initialization, such as installing alarms. You must
2553 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2554 * permission in order to receive this broadcast.
2555 * <p>
2556 * This broadcast is sent immediately at boot by all devices (regardless of
2557 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2558 * higher. Upon receipt of this broadcast, the user is still locked and only
2559 * device-protected storage can be accessed safely. If you want to access
2560 * credential-protected storage, you need to wait for the user to be
2561 * unlocked (typically by entering their lock pattern or PIN for the first
2562 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2563 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2564 * <p>
2565 * To receive this broadcast, your receiver component must be marked as
2566 * being {@link ComponentInfo#directBootAware}.
2567 * <p class="note">
2568 * This is a protected intent that can only be sent by the system.
2569 *
2570 * @see Context#createDeviceProtectedStorageContext()
2571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2573 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2574
2575 /**
2576 * Broadcast Action: This is broadcast once, after the user has finished
2577 * booting. It can be used to perform application-specific initialization,
2578 * such as installing alarms. You must hold the
2579 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2580 * order to receive this broadcast.
2581 * <p>
2582 * This broadcast is sent at boot by all devices (both with and without
2583 * direct boot support). Upon receipt of this broadcast, the user is
2584 * unlocked and both device-protected and credential-protected storage can
2585 * accessed safely.
2586 * <p>
2587 * If you need to run while the user is still locked (before they've entered
2588 * their lock pattern or PIN for the first time), you can listen for the
2589 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2590 * <p class="note">
2591 * This is a protected intent that can only be sent by the system.
2592 */
2593 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2594 @BroadcastBehavior(includeBackground = true)
2595 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
2596
2597 /**
2598 * Broadcast Action: This is broadcast when a user action should request a
2599 * temporary system dialog to dismiss. Some examples of temporary system
2600 * dialogs are the notification window-shade and the recent tasks dialog.
2601 *
2602 * @deprecated This intent is deprecated for third-party applications starting from Android
2603 * {@link Build.VERSION_CODES#S} for security reasons. Unauthorized usage by applications
2604 * will result in the broadcast intent being dropped for apps targeting API level less than
2605 * {@link Build.VERSION_CODES#S} and in a {@link SecurityException} for apps targeting SDK
2606 * level {@link Build.VERSION_CODES#S} or higher. Instrumentation initiated from the shell
2607 * (eg. tests) is still able to use the intent. The platform will automatically collapse
2608 * the proper system dialogs in the proper use-cases. For all others, the user is the one in
2609 * control of closing dialogs.
2610 *
2611 * @see AccessibilityService#GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE
2612 */
2613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2614 @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS)
2615 @Deprecated
2616 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2617 /**
2618 * Broadcast Action: Trigger the download and eventual installation
2619 * of a package.
2620 * <p>Input: {@link #getData} is the URI of the package file to download.
2621 *
2622 * <p class="note">This is a protected intent that can only be sent
2623 * by the system.
2624 *
2625 * @deprecated This constant has never been used.
2626 */
2627 @Deprecated
2628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2629 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2630 /**
2631 * Broadcast Action: A new application package has been installed on the
2632 * device. The data contains the name of the package. Note that the
2633 * newly installed package does <em>not</em> receive this broadcast.
2634 * <p>May include the following extras:
2635 * <ul>
2636 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2637 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2638 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2639 * </ul>
2640 *
2641 * <p class="note">This is a protected intent that can only be sent
2642 * by the system.
2643 */
2644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2645 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2646 /**
2647 * Broadcast Action: A new version of an application package has been
2648 * installed, replacing an existing version that was previously installed.
2649 * The data contains the name of the package.
2650 * <p>May include the following extras:
2651 * <ul>
2652 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2653 * </ul>
2654 *
2655 * <p class="note">This is a protected intent that can only be sent
2656 * by the system.
2657 */
2658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2659 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2660 /**
2661 * Broadcast Action: A new version of your application has been installed
2662 * over an existing one. This is only sent to the application that was
2663 * replaced. It does not contain any additional data; to receive it, just
2664 * use an intent filter for this action.
2665 *
2666 * <p class="note">This is a protected intent that can only be sent
2667 * by the system.
2668 */
2669 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2670 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2671 /**
2672 * Broadcast Action: An existing application package has been removed from
2673 * the device. The data contains the name of the package. The package
2674 * that is being removed does <em>not</em> receive this Intent.
2675 * <ul>
2676 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2677 * to the package.
2678 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2679 * application -- data and code -- is being removed.
2680 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2681 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2682 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal that the application
2683 * was removed with the user-initiated action.
2684 * </ul>
2685 *
2686 * <p class="note">This is a protected intent that can only be sent
2687 * by the system.
2688 */
2689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2690 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2691 /**
2692 * Broadcast Action: An existing application package has been removed from
2693 * the device. The data contains the name of the package and the visibility
2694 * allow list. The package that is being removed does <em>not</em> receive
2695 * this Intent.
2696 * <ul>
2697 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2698 * to the package.
2699 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2700 * application -- data and code -- is being removed.
2701 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2702 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2703 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal
2704 * that the application was removed with the user-initiated action.
2705 * <li> {@link #EXTRA_VISIBILITY_ALLOW_LIST} containing an int array to
2706 * indicate the visibility allow list.
2707 * </ul>
2708 *
2709 * <p class="note">This is a protected intent that can only be sent
2710 * by the system.
2711 *
2712 * @hide This broadcast is used internally by the system.
2713 */
2714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2715 public static final String ACTION_PACKAGE_REMOVED_INTERNAL =
2716 "android.intent.action.PACKAGE_REMOVED_INTERNAL";
2717 /**
2718 * Broadcast Action: An existing application package has been completely
2719 * removed from the device. The data contains the name of the package.
2720 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2721 * {@link #EXTRA_DATA_REMOVED} is true and
2722 * {@link #EXTRA_REPLACING} is false of that broadcast.
2723 *
2724 * <ul>
2725 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2726 * to the package.
2727 * </ul>
2728 *
2729 * <p class="note">This is a protected intent that can only be sent
2730 * by the system.
2731 */
2732 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2733 public static final String ACTION_PACKAGE_FULLY_REMOVED
2734 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2735 /**
2736 * Broadcast Action: An existing application package has been changed (for
2737 * example, a component has been enabled or disabled). The data contains
2738 * the name of the package.
2739 * <ul>
2740 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2741 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
2742 * of the changed components (or the package name itself).
2743 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2744 * default action of restarting the application.
2745 * </ul>
2746 *
2747 * <p class="note">This is a protected intent that can only be sent
2748 * by the system.
2749 */
2750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2751 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2752 /**
2753 * Broadcast Action: Sent to the system rollback manager when a package
2754 * needs to have rollback enabled.
2755 * <p class="note">
2756 * This is a protected intent that can only be sent by the system.
2757 * </p>
2758 *
2759 * @hide This broadcast is used internally by the system.
2760 */
2761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2762 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2763 "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2764 /**
2765 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain
2766 * package needs to be cancelled.
2767 *
2768 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager
2769 * that enabling a specific rollback has timed out.
2770 *
2771 * @hide
2772 */
2773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2774 public static final String ACTION_CANCEL_ENABLE_ROLLBACK =
2775 "android.intent.action.CANCEL_ENABLE_ROLLBACK";
2776 /**
2777 * Broadcast Action: A rollback has been committed.
2778 *
2779 * <p class="note">This is a protected intent that can only be sent
2780 * by the system. The receiver must hold MANAGE_ROLLBACK permission.
2781 *
2782 * @hide
2783 */
2784 @SystemApi
2785 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2786 public static final String ACTION_ROLLBACK_COMMITTED =
2787 "android.intent.action.ROLLBACK_COMMITTED";
2788 /**
2789 * @hide
2790 * Broadcast Action: Ask system services if there is any reason to
2791 * restart the given package. The data contains the name of the
2792 * package.
2793 * <ul>
2794 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2795 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2796 * </ul>
2797 *
2798 * <p class="note">This is a protected intent that can only be sent
2799 * by the system.
2800 */
2801 @SystemApi
2802 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2803 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2804 /**
2805 * Broadcast Action: The user has restarted a package, and all of its
2806 * processes have been killed. All runtime state
2807 * associated with it (processes, alarms, notifications, etc) should
2808 * be removed. Note that the restarted package does <em>not</em>
2809 * receive this broadcast.
2810 * The data contains the name of the package.
2811 * <ul>
2812 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2813 * </ul>
2814 *
2815 * <p class="note">This is a protected intent that can only be sent
2816 * by the system.
2817 */
2818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2819 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2820 /**
2821 * Broadcast Action: The user has cleared the data of a package. This should
2822 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
2823 * its persistent data is erased and this broadcast sent.
2824 * Note that the cleared package does <em>not</em>
2825 * receive this broadcast. The data contains the name of the package.
2826 * <ul>
2827 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2828 * package whose data was cleared is an uninstalled instant app, then the UID
2829 * will be -1. The platform keeps some meta-data associated with instant apps
2830 * after they are uninstalled.
2831 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2832 * data was for an instant app.
2833 * </ul>
2834 *
2835 * <p class="note">This is a protected intent that can only be sent
2836 * by the system.
2837 */
2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2839 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2840 /**
2841 * Broadcast Action: Packages have been suspended.
2842 * <p>Includes the following extras:
2843 * <ul>
2844 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2845 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
2846 * </ul>
2847 *
2848 * <p class="note">This is a protected intent that can only be sent
2849 * by the system. It is only sent to registered receivers.
2850 */
2851 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2852 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2853 /**
2854 * Broadcast Action: Packages have been unsuspended.
2855 * <p>Includes the following extras:
2856 * <ul>
2857 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2858 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
2859 * </ul>
2860 *
2861 * <p class="note">This is a protected intent that can only be sent
2862 * by the system. It is only sent to registered receivers.
2863 */
2864 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2865 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2866 /**
2867 * Broadcast Action: One of the suspend conditions have been modified for the packages.
2868 * <p>Includes the following extras:
2869 * <ul>
2870 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been modified
2871 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been modified
2872 * </ul>
2873 *
2874 * <p class="note">This is a protected intent that can only be sent
2875 * by the system. It is only sent to registered receivers.
2876 *
2877 * @hide
2878 */
2879 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2880 public static final String ACTION_PACKAGES_SUSPENSION_CHANGED =
2881 "android.intent.action.PACKAGES_SUSPENSION_CHANGED";
2882
2883 /**
2884 * Broadcast Action: Distracting packages have been changed.
2885 * <p>Includes the following extras:
2886 * <ul>
2887 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2888 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2889 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2890 * </ul>
2891 *
2892 * <p class="note">This is a protected intent that can only be sent
2893 * by the system. It is only sent to registered receivers.
2894 *
2895 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2896 * @hide
2897 */
2898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2899 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2900 "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2901
2902 /**
2903 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
2904 * whenever a package is put into a suspended state or any of its app extras change while in the
2905 * suspended state.
2906 * <p> Optionally includes the following extras:
2907 * <ul>
2908 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2909 * useful information for the app being suspended.
2910 * </ul>
2911 * <p class="note">This is a protected intent that can only be sent
2912 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2913 * the manifest.</em>
2914 *
2915 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2916 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2917 * @see PackageManager#isPackageSuspended()
2918 * @see PackageManager#getSuspendedPackageAppExtras()
2919 */
2920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2921 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2922
2923 /**
2924 * Activity Action: Started to show more details about why an application was suspended.
2925 *
2926 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2927 * be used to show more details about the reason for suspension.
2928 *
2929 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2930 * handling this intent and protect it with
2931 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2932 *
2933 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2934 *
2935 * <p class="note">This is a protected intent that can only be sent
2936 * by the system.
2937 *
2938 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2939 * PersistableBundle, String)
2940 * @see PackageManager#isPackageSuspended()
2941 * @see #ACTION_PACKAGES_SUSPENDED
2942 *
2943 * @hide
2944 */
2945 @SystemApi
2946 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2947 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2948 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2949
2950 /**
2951 * Broadcast Action: Sent to indicate that the user unsuspended a package.
2952 *
2953 * <p>This can happen when the user taps on the neutral button of the
2954 * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using
2955 * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the
2956 * suspending app that originally specified this dialog while calling
2957 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2958 * PersistableBundle, SuspendDialogInfo)}.
2959 *
2960 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just
2961 * got unsuspended.
2962 *
2963 * <p class="note">This is a protected intent that can only be sent
2964 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2965 * the manifest.</em>
2966 *
2967 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2968 * PersistableBundle, SuspendDialogInfo)
2969 * @see PackageManager#isPackageSuspended()
2970 * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS
2971 * @hide
2972 */
2973 @SystemApi
2974 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2975 public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY =
2976 "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY";
2977
2978 /**
2979 * Broadcast Action: Sent to a package that has been unsuspended.
2980 *
2981 * <p class="note">This is a protected intent that can only be sent
2982 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2983 * the manifest.</em>
2984 *
2985 * @see #ACTION_MY_PACKAGE_SUSPENDED
2986 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2987 * @see PackageManager#isPackageSuspended()
2988 * @see PackageManager#getSuspendedPackageAppExtras()
2989 */
2990 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2991 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2992
2993 /**
2994 * Broadcast Action: A uid has been removed from the system. The uid
2995 * number is stored in the extra data under {@link #EXTRA_UID}.
2996 *
2997 * In certain instances, {@link #EXTRA_REPLACING} is set to true if the UID is not being
2998 * fully removed.
2999 *
3000 * <p class="note">This is a protected intent that can only be sent
3001 * by the system.
3002 */
3003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3004 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
3005
3006 /**
3007 * Broadcast Action: Sent to the installer package of an application when
3008 * that application is first launched (that is the first time it is moved
3009 * out of the stopped state). The data contains the name of the package.
3010 *
3011 * <p>When the application is first launched, the application itself doesn't receive this
3012 * broadcast.</p>
3013 *
3014 * <p class="note">This is a protected intent that can only be sent
3015 * by the system.
3016 */
3017 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3018 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
3019
3020 /**
3021 * Broadcast Action: Sent to the system package verifier when a package
3022 * needs to be verified. The data contains the package URI.
3023 * <p class="note">
3024 * This is a protected intent that can only be sent by the system.
3025 * </p>
3026 */
3027 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3028 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
3029
3030 /**
3031 * Broadcast Action: Sent to the system package verifier when a package is
3032 * verified. The data contains the package URI.
3033 * <p class="note">
3034 * This is a protected intent that can only be sent by the system.
3035 */
3036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3037 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
3038
3039 /**
3040 * Broadcast Action: Sent to the system intent filter verifier when an
3041 * intent filter needs to be verified. The data contains the filter data
3042 * hosts to be verified against.
3043 * <p class="note">
3044 * This is a protected intent that can only be sent by the system.
3045 * </p>
3046 *
3047 * @hide
3048 * @deprecated Superseded by domain verification APIs. See {@link DomainVerificationManager}.
3049 */
3050 @Deprecated
3051 @SystemApi
3052 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3053 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION =
3054 "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
3055
3056
3057 /**
3058 * Broadcast Action: Sent to the system domain verification agent when an app's domains need
3059 * to be verified. The data contains the domains hosts to be verified against.
3060 * <p class="note">
3061 * This is a protected intent that can only be sent by the system.
3062 * </p>
3063 *
3064 * @hide
3065 */
3066 @SystemApi
3067 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3068 public static final String ACTION_DOMAINS_NEED_VERIFICATION =
3069 "android.intent.action.DOMAINS_NEED_VERIFICATION";
3070
3071 /**
3072 * Broadcast Action: Resources for a set of packages (which were
3073 * previously unavailable) are currently
3074 * available since the media on which they exist is available.
3075 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
3076 * list of packages whose availability changed.
3077 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
3078 * list of uids of packages whose availability changed.
3079 * Note that the
3080 * packages in this list do <em>not</em> receive this broadcast.
3081 * The specified set of packages are now available on the system.
3082 * <p>Includes the following extras:
3083 * <ul>
3084 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
3085 * whose resources(were previously unavailable) are currently available.
3086 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
3087 * packages whose resources(were previously unavailable)
3088 * are currently available.
3089 * </ul>
3090 *
3091 * <p class="note">This is a protected intent that can only be sent
3092 * by the system.
3093 */
3094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3095 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
3096 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
3097
3098 /**
3099 * Broadcast Action: Resources for a set of packages are currently
3100 * unavailable since the media on which they exist is unavailable.
3101 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
3102 * list of packages whose availability changed.
3103 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
3104 * list of uids of packages whose availability changed.
3105 * The specified set of packages can no longer be
3106 * launched and are practically unavailable on the system.
3107 * <p>Inclues the following extras:
3108 * <ul>
3109 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
3110 * whose resources are no longer available.
3111 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
3112 * whose resources are no longer available.
3113 * </ul>
3114 *
3115 * <p class="note">This is a protected intent that can only be sent
3116 * by the system.
3117 */
3118 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3119 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
3120 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
3121
3122 /**
3123 * Broadcast Action: preferred activities have changed *explicitly*.
3124 *
3125 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
3126 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
3127 * be sent.
3128 *
3129 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
3130 *
3131 * @hide
3132 */
3133 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3134 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
3135 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
3136
3137
3138 /**
3139 * Broadcast Action: The current system wallpaper has changed. See
3140 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
3141 * This should <em>only</em> be used to determine when the wallpaper
3142 * has changed to show the new wallpaper to the user. You should certainly
3143 * never, in response to this, change the wallpaper or other attributes of
3144 * it such as the suggested size. That would be unexpected, right? You'd cause
3145 * all kinds of loops, especially if other apps are doing similar things,
3146 * right? Of course. So please don't do this.
3147 *
3148 * @deprecated Modern applications should use
3149 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
3150 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
3151 * shown behind their UI, rather than watching for this broadcast and
3152 * rendering the wallpaper on their own.
3153 */
3154 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3155 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
3156 /**
3157 * Broadcast Action: The current device {@link android.content.res.Configuration}
3158 * (orientation, locale, etc) has changed. When such a change happens, the
3159 * UIs (view hierarchy) will need to be rebuilt based on this new
3160 * information; for the most part, applications don't need to worry about
3161 * this, because the system will take care of stopping and restarting the
3162 * application to make sure it sees the new changes. Some system code that
3163 * can not be restarted will need to watch for this action and handle it
3164 * appropriately.
3165 *
3166 * <p class="note">
3167 * You <em>cannot</em> receive this through components declared
3168 * in manifests, only by explicitly registering for it with
3169 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3170 * Context.registerReceiver()}.
3171 *
3172 * <p class="note">This is a protected intent that can only be sent
3173 * by the system.
3174 *
3175 * @see android.content.res.Configuration
3176 */
3177 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3178 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
3179
3180 /**
3181 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
3182 * such that the device may be eligible for the installation of additional configuration splits.
3183 * Configuration properties that can trigger this broadcast include locale and display density.
3184 *
3185 * <p class="note">
3186 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
3187 * components declared in manifests. However, the receiver <em>must</em> hold the
3188 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
3189 *
3190 * <p class="note">
3191 * This is a protected intent that can only be sent by the system.
3192 *
3193 * @hide
3194 */
3195 @SystemApi
3196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3197 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
3198 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
3199 /**
3200 * Broadcast Action: The receiver's effective locale has changed.
3201 *
3202 * This happens when the device locale, or the receiving app's locale
3203 * (set via {@link android.app.LocaleManager#setApplicationLocales}) changed.
3204 *
3205 * Can be received by manifest-declared receivers.
3206 *
3207 * <p class="note"> If only the app locale changed, includes the following extras:
3208 * <ul>
3209 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed.
3210 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app
3211 * </ul>
3212 *
3213 * <p class="note">This is a protected intent that can only be sent
3214 * by the system.
3215 */
3216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3217 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
3218 /**
3219 * Broadcast Action: Locale of a particular app has changed.
3220 *
3221 * <p class="note"> This broadcast is explicitly sent to the
3222 * {@link android.content.pm.InstallSourceInfo#getInstallingPackageName} installer
3223 * of the app whose locale has changed.
3224 * <p class="note"> The broadcast could also be received by manifest-declared receivers with
3225 * {@code android.permission.READ_APP_SPECIFIC_LOCALES}
3226 *
3227 * <p class="note">This is a protected intent that can only be sent
3228 * by the system.
3229 *
3230 * <p>Includes the following extras:
3231 * <ul>
3232 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed.
3233 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app
3234 * </ul>
3235 */
3236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3237 public static final String ACTION_APPLICATION_LOCALE_CHANGED =
3238 "android.intent.action.APPLICATION_LOCALE_CHANGED";
3239 /**
3240 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
3241 * charging state, level, and other information about the battery.
3242 * See {@link android.os.BatteryManager} for documentation on the
3243 * contents of the Intent.
3244 *
3245 * <p class="note">
3246 * You <em>cannot</em> receive this through components declared
3247 * in manifests, only by explicitly registering for it with
3248 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3249 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
3250 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
3251 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
3252 * broadcasts that are sent and can be received through manifest
3253 * receivers.
3254 *
3255 * <p class="note">This is a protected intent that can only be sent
3256 * by the system.
3257 */
3258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3259 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
3260
3261
3262 /**
3263 * Broadcast Action: Sent when the current battery level or plug type changes.
3264 *
3265 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
3266 * instances representing individual battery level changes with associated
3267 * extras from {@link #ACTION_BATTERY_CHANGED}.
3268 *
3269 * <p class="note">
3270 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
3271 *
3272 * @hide
3273 */
3274 @SystemApi
3275 public static final String ACTION_BATTERY_LEVEL_CHANGED =
3276 "android.intent.action.BATTERY_LEVEL_CHANGED";
3277 /**
3278 * Broadcast Action: Indicates low battery condition on the device.
3279 * This broadcast corresponds to the "Low battery warning" system dialog.
3280 *
3281 * <p class="note">This is a protected intent that can only be sent
3282 * by the system.
3283 */
3284 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3285 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
3286 /**
3287 * Broadcast Action: Indicates the battery is now okay after being low.
3288 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
3289 * gone back up to an okay state.
3290 *
3291 * <p class="note">This is a protected intent that can only be sent
3292 * by the system.
3293 */
3294 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3295 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
3296 /**
3297 * Broadcast Action: External power has been connected to the device.
3298 * This is intended for applications that wish to register specifically to this notification.
3299 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
3300 * stay active to receive this notification. This action can be used to implement actions
3301 * that wait until power is available to trigger.
3302 *
3303 * <p class="note">This is a protected intent that can only be sent
3304 * by the system.
3305 */
3306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3307 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
3308 /**
3309 * Broadcast Action: External power has been removed from the device.
3310 * This is intended for applications that wish to register specifically to this notification.
3311 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
3312 * stay active to receive this notification. This action can be used to implement actions
3313 * that wait until power is available to trigger.
3314 *
3315 * <p class="note">This is a protected intent that can only be sent
3316 * by the system.
3317 */
3318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3319 public static final String ACTION_POWER_DISCONNECTED =
3320 "android.intent.action.ACTION_POWER_DISCONNECTED";
3321 /**
3322 * Broadcast Action: Device is shutting down.
3323 * This is broadcast when the device is being shut down (completely turned
3324 * off, not sleeping). Once the broadcast is complete, the final shutdown
3325 * will proceed and all unsaved data lost. Apps will not normally need
3326 * to handle this, since the foreground activity will be paused as well.
3327 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
3328 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3329 * Context.registerReceiver}.
3330 *
3331 * <p class="note">This is a protected intent that can only be sent
3332 * by the system.
3333 * <p>May include the following extras:
3334 * <ul>
3335 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
3336 * shutdown is only for userspace processes. If not set, assumed to be false.
3337 * </ul>
3338 */
3339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3340 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
3341 /**
3342 * Activity Action: Start this activity to request system shutdown.
3343 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
3344 * to request confirmation from the user before shutting down. The optional boolean
3345 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
3346 * indicate that the shutdown is requested by the user.
3347 *
3348 * <p class="note">This is a protected intent that can only be sent
3349 * by the system.
3350 *
3351 * {@hide}
3352 */
3353 public static final String ACTION_REQUEST_SHUTDOWN
3354 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
3355 /**
3356 * Broadcast Action: A sticky broadcast that indicates low storage space
3357 * condition on the device
3358 * <p class="note">
3359 * This is a protected intent that can only be sent by the system.
3360 *
3361 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3362 * or above, this broadcast will no longer be delivered to any
3363 * {@link BroadcastReceiver} defined in your manifest. Instead,
3364 * apps are strongly encouraged to use the improved
3365 * {@link Context#getCacheDir()} behavior so the system can
3366 * automatically free up storage when needed.
3367 */
3368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3369 @Deprecated
3370 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
3371 /**
3372 * Broadcast Action: Indicates low storage space condition on the device no
3373 * longer exists
3374 * <p class="note">
3375 * This is a protected intent that can only be sent by the system.
3376 *
3377 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3378 * or above, this broadcast will no longer be delivered to any
3379 * {@link BroadcastReceiver} defined in your manifest. Instead,
3380 * apps are strongly encouraged to use the improved
3381 * {@link Context#getCacheDir()} behavior so the system can
3382 * automatically free up storage when needed.
3383 */
3384 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3385 @Deprecated
3386 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
3387 /**
3388 * Broadcast Action: A sticky broadcast that indicates a storage space full
3389 * condition on the device. This is intended for activities that want to be
3390 * able to fill the data partition completely, leaving only enough free
3391 * space to prevent system-wide SQLite failures.
3392 * <p class="note">
3393 * This is a protected intent that can only be sent by the system.
3394 *
3395 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3396 * or above, this broadcast will no longer be delivered to any
3397 * {@link BroadcastReceiver} defined in your manifest. Instead,
3398 * apps are strongly encouraged to use the improved
3399 * {@link Context#getCacheDir()} behavior so the system can
3400 * automatically free up storage when needed.
3401 * @hide
3402 */
3403 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3404 @Deprecated
3405 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
3406 /**
3407 * Broadcast Action: Indicates storage space full condition on the device no
3408 * longer exists.
3409 * <p class="note">
3410 * This is a protected intent that can only be sent by the system.
3411 *
3412 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3413 * or above, this broadcast will no longer be delivered to any
3414 * {@link BroadcastReceiver} defined in your manifest. Instead,
3415 * apps are strongly encouraged to use the improved
3416 * {@link Context#getCacheDir()} behavior so the system can
3417 * automatically free up storage when needed.
3418 * @hide
3419 */
3420 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3421 @Deprecated
3422 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
3423 /**
3424 * Broadcast Action: Indicates low memory condition notification acknowledged by user
3425 * and package management should be started.
3426 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
3427 * notification.
3428 */
3429 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3430 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
3431 /**
3432 * Broadcast Action: The device has entered USB Mass Storage mode.
3433 * This is used mainly for the USB Settings panel.
3434 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3435 * when the SD card file system is mounted or unmounted
3436 * @deprecated replaced by android.os.storage.StorageEventListener
3437 */
3438 @Deprecated
3439 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3440 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
3441
3442 /**
3443 * Broadcast Action: The device has exited USB Mass Storage mode.
3444 * This is used mainly for the USB Settings panel.
3445 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3446 * when the SD card file system is mounted or unmounted
3447 * @deprecated replaced by android.os.storage.StorageEventListener
3448 */
3449 @Deprecated
3450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3451 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3452
3453 /**
3454 * Broadcast Action: External media has been removed.
3455 * The path to the mount point for the removed media is contained in the Intent.mData field.
3456 */
3457 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3458 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3459
3460 /**
3461 * Broadcast Action: External media is present, but not mounted at its mount point.
3462 * The path to the mount point for the unmounted media is contained in the Intent.mData field.
3463 */
3464 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3465 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3466
3467 /**
3468 * Broadcast Action: External media is present, and being disk-checked
3469 * The path to the mount point for the checking media is contained in the Intent.mData field.
3470 */
3471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3472 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3473
3474 /**
3475 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
3476 * The path to the mount point for the checking media is contained in the Intent.mData field.
3477 */
3478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3479 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3480
3481 /**
3482 * Broadcast Action: External media is present and mounted at its mount point.
3483 * The path to the mount point for the mounted media is contained in the Intent.mData field.
3484 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3485 * media was mounted read only.
3486 */
3487 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3488 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3489
3490 /**
3491 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
3492 * The path to the mount point for the shared media is contained in the Intent.mData field.
3493 */
3494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3495 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3496
3497 /**
3498 * Broadcast Action: External media is no longer being shared via USB mass storage.
3499 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3500 *
3501 * @hide
3502 */
3503 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3504
3505 /**
3506 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
3507 * The path to the mount point for the removed media is contained in the Intent.mData field.
3508 */
3509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3510 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3511
3512 /**
3513 * Broadcast Action: External media is present but cannot be mounted.
3514 * The path to the mount point for the unmountable media is contained in the Intent.mData field.
3515 */
3516 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3517 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3518
3519 /**
3520 * Broadcast Action: User has expressed the desire to remove the external storage media.
3521 * Applications should close all files they have open within the mount point when they receive this intent.
3522 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3523 */
3524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3525 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3526
3527 /**
3528 * Broadcast Action: The media scanner has started scanning a directory.
3529 * The path to the directory being scanned is contained in the Intent.mData field.
3530 */
3531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3532 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3533
3534 /**
3535 * Broadcast Action: The media scanner has finished scanning a directory.
3536 * The path to the scanned directory is contained in the Intent.mData field.
3537 */
3538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3539 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3540
3541 /**
3542 * Broadcast Action: Request the media scanner to scan a file and add it to
3543 * the media database.
3544 * <p>
3545 * The path to the file is contained in {@link Intent#getData()}.
3546 *
3547 * @deprecated Callers should migrate to inserting items directly into
3548 * {@link MediaStore}, where they will be automatically scanned
3549 * after each mutation.
3550 */
3551 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3552 @Deprecated
3553 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3554
3555 /**
3556 * Broadcast Action: The "Media Button" was pressed. Includes a single
3557 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3558 * caused the broadcast.
3559 */
3560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3561 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3562
3563 /**
3564 * Broadcast Action: The "Camera Button" was pressed. Includes a single
3565 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3566 * caused the broadcast.
3567 */
3568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3569 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3570
3571 // *** NOTE: @todo(*) The following really should go into a more domain-specific
3572 // location; they are not general-purpose actions.
3573
3574 /**
3575 * Broadcast Action: A GTalk connection has been established.
3576 */
3577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3578 public static final String ACTION_GTALK_SERVICE_CONNECTED =
3579 "android.intent.action.GTALK_CONNECTED";
3580
3581 /**
3582 * Broadcast Action: A GTalk connection has been disconnected.
3583 */
3584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3585 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3586 "android.intent.action.GTALK_DISCONNECTED";
3587
3588 /**
3589 * Broadcast Action: An input method has been changed.
3590 */
3591 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3592 public static final String ACTION_INPUT_METHOD_CHANGED =
3593 "android.intent.action.INPUT_METHOD_CHANGED";
3594
3595 /**
3596 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3597 * more radios have been turned off or on. The intent will have the following extra value:</p>
3598 * <ul>
3599 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3600 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3601 * turned off</li>
3602 * </ul>
3603 *
3604 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3605 */
3606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3607 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3608
3609 /**
3610 * Broadcast Action: Some content providers have parts of their namespace
3611 * where they publish new events or items that the user may be especially
3612 * interested in. For these things, they may broadcast this action when the
3613 * set of interesting items change.
3614 *
3615 * For example, GmailProvider sends this notification when the set of unread
3616 * mail in the inbox changes.
3617 *
3618 * <p>The data of the intent identifies which part of which provider
3619 * changed. When queried through the content resolver, the data URI will
3620 * return the data set in question.
3621 *
3622 * <p>The intent will have the following extra values:
3623 * <ul>
3624 * <li><em>count</em> - The number of items in the data set. This is the
3625 * same as the number of items in the cursor returned by querying the
3626 * data URI. </li>
3627 * </ul>
3628 *
3629 * This intent will be sent at boot (if the count is non-zero) and when the
3630 * data set changes. It is possible for the data set to change without the
3631 * count changing (for example, if a new unread message arrives in the same
3632 * sync operation in which a message is archived). The phone should still
3633 * ring/vibrate/etc as normal in this case.
3634 */
3635 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3636 public static final String ACTION_PROVIDER_CHANGED =
3637 "android.intent.action.PROVIDER_CHANGED";
3638
3639 /**
3640 * Broadcast Action: Wired Headset plugged in or unplugged.
3641 *
3642 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3643 * and documentation.
3644 * <p>If the minimum SDK version of your application is
3645 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
3646 * to the <code>AudioManager</code> constant in your receiver registration code instead.
3647 */
3648 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3649 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
3650
3651 /**
3652 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3653 * <ul>
3654 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3655 * </ul>
3656 *
3657 * <p class="note">This is a protected intent that can only be sent
3658 * by the system.
3659 *
3660 * @hide
3661 */
3662 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3663 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3664 = "android.intent.action.ADVANCED_SETTINGS";
3665
3666 /**
3667 * Broadcast Action: Sent after application restrictions are changed.
3668 *
3669 * <p class="note">This is a protected intent that can only be sent
3670 * by the system.</p>
3671 */
3672 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3673 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3674 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3675
3676 /**
3677 * Broadcast Action: An outgoing call is about to be placed.
3678 *
3679 * <p>The Intent will have the following extra value:</p>
3680 * <ul>
3681 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
3682 * the phone number originally intended to be dialed.</li>
3683 * </ul>
3684 * <p>Once the broadcast is finished, the resultData is used as the actual
3685 * number to call. If <code>null</code>, no call will be placed.</p>
3686 * <p>It is perfectly acceptable for multiple receivers to process the
3687 * outgoing call in turn: for example, a parental control application
3688 * might verify that the user is authorized to place the call at that
3689 * time, then a number-rewriting application might add an area code if
3690 * one was not specified.</p>
3691 * <p>For consistency, any receiver whose purpose is to prohibit phone
3692 * calls should have a priority of 0, to ensure it will see the final
3693 * phone number to be dialed.
3694 * Any receiver whose purpose is to rewrite phone numbers to be called
3695 * should have a positive priority.
3696 * Negative priorities are reserved for the system for this broadcast;
3697 * using them may cause problems.</p>
3698 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3699 * abort the broadcast.</p>
3700 * <p>Emergency calls cannot be intercepted using this mechanism, and
3701 * other calls cannot be modified to call emergency numbers using this
3702 * mechanism.
3703 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3704 * call to use their own service instead. Those apps should first prevent
3705 * the call from being placed by setting resultData to <code>null</code>
3706 * and then start their own app to make the call.
3707 * <p>You must hold the
3708 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3709 * permission to receive this Intent.</p>
3710 *
3711 * <p class="note">This is a protected intent that can only be sent
3712 * by the system.
3713 *
3714 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3715 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3716 * This means that attempts to re-write the outgoing call by other apps using this intent will
3717 * be ignored.
3718 * </p>
3719 *
3720 * @deprecated Apps that redirect outgoing calls should use the
3721 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening
3722 * should use the {@link android.telecom.CallScreeningService} API. Apps which need to be
3723 * notified of basic call state should use
3724 * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine
3725 * when a new outgoing call is placed.
3726 */
3727 @Deprecated
3728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3729 public static final String ACTION_NEW_OUTGOING_CALL =
3730 "android.intent.action.NEW_OUTGOING_CALL";
3731
3732 /**
3733 * Broadcast Action: Have the device reboot. This is only for use by
3734 * system code.
3735 *
3736 * <p class="note">This is a protected intent that can only be sent
3737 * by the system.
3738 */
3739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3740 public static final String ACTION_REBOOT =
3741 "android.intent.action.REBOOT";
3742
3743 /**
3744 * Broadcast Action: A sticky broadcast for changes in the physical
3745 * docking state of the device.
3746 *
3747 * <p>The intent will have the following extra values:
3748 * <ul>
3749 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
3750 * state, indicating which dock the device is physically in.</li>
3751 * </ul>
3752 * <p>This is intended for monitoring the current physical dock state.
3753 * See {@link android.app.UiModeManager} for the normal API dealing with
3754 * dock mode changes.
3755 */
3756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3757 public static final String ACTION_DOCK_EVENT =
3758 "android.intent.action.DOCK_EVENT";
3759
3760 /**
3761 * Broadcast Action: A broadcast when idle maintenance can be started.
3762 * This means that the user is not interacting with the device and is
3763 * not expected to do so soon. Typical use of the idle maintenance is
3764 * to perform somehow expensive tasks that can be postponed at a moment
3765 * when they will not degrade user experience.
3766 * <p>
3767 * <p class="note">In order to keep the device responsive in case of an
3768 * unexpected user interaction, implementations of a maintenance task
3769 * should be interruptible. In such a scenario a broadcast with action
3770 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3771 * should not do the maintenance work in
3772 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3773 * maintenance service by {@link Context#startService(Intent)}. Also
3774 * you should hold a wake lock while your maintenance service is running
3775 * to prevent the device going to sleep.
3776 * </p>
3777 * <p>
3778 * <p class="note">This is a protected intent that can only be sent by
3779 * the system.
3780 * </p>
3781 *
3782 * @see #ACTION_IDLE_MAINTENANCE_END
3783 *
3784 * @hide
3785 */
3786 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3787 public static final String ACTION_IDLE_MAINTENANCE_START =
3788 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3789
3790 /**
3791 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3792 * This means that the user was not interacting with the device as a result
3793 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3794 * was sent and now the user started interacting with the device. Typical
3795 * use of the idle maintenance is to perform somehow expensive tasks that
3796 * can be postponed at a moment when they will not degrade user experience.
3797 * <p>
3798 * <p class="note">In order to keep the device responsive in case of an
3799 * unexpected user interaction, implementations of a maintenance task
3800 * should be interruptible. Hence, on receiving a broadcast with this
3801 * action, the maintenance task should be interrupted as soon as possible.
3802 * In other words, you should not do the maintenance work in
3803 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3804 * maintenance service that was started on receiving of
3805 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3806 * lock you acquired when your maintenance service started.
3807 * </p>
3808 * <p class="note">This is a protected intent that can only be sent
3809 * by the system.
3810 *
3811 * @see #ACTION_IDLE_MAINTENANCE_START
3812 *
3813 * @hide
3814 */
3815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3816 public static final String ACTION_IDLE_MAINTENANCE_END =
3817 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3818
3819 /**
3820 * Broadcast Action: a remote intent is to be broadcasted.
3821 *
3822 * A remote intent is used for remote RPC between devices. The remote intent
3823 * is serialized and sent from one device to another device. The receiving
3824 * device parses the remote intent and broadcasts it. Note that anyone can
3825 * broadcast a remote intent. However, if the intent receiver of the remote intent
3826 * does not trust intent broadcasts from arbitrary intent senders, it should require
3827 * the sender to hold certain permissions so only trusted sender's broadcast will be
3828 * let through.
3829 * @hide
3830 */
3831 public static final String ACTION_REMOTE_INTENT =
3832 "com.google.android.c2dm.intent.RECEIVE";
3833
3834 /**
3835 * Broadcast Action: This is broadcast once when the user is booting after a
3836 * system update. It can be used to perform cleanup or upgrades after a
3837 * system update.
3838 * <p>
3839 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3840 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3841 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3842 * sent to receivers in the system image.
3843 *
3844 * @hide
3845 */
3846 @SystemApi
3847 public static final String ACTION_PRE_BOOT_COMPLETED =
3848 "android.intent.action.PRE_BOOT_COMPLETED";
3849
3850 /**
3851 * Broadcast to a specific application to query any supported restrictions to impose
3852 * on restricted users. The broadcast intent contains an extra
3853 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3854 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3855 * String[] depending on the restriction type.<p/>
3856 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
3857 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3858 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3859 * The activity specified by that intent will be launched for a result which must contain
3860 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3861 * The keys and values of the returned restrictions will be persisted.
3862 * @see RestrictionEntry
3863 */
3864 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3865 "android.intent.action.GET_RESTRICTION_ENTRIES";
3866
3867 /**
3868 * Sent the first time a user is starting, to allow system apps to
3869 * perform one time initialization. (This will not be seen by third
3870 * party applications because a newly initialized user does not have any
3871 * third party applications installed for it.) This is sent early in
3872 * starting the user, around the time the home app is started, before
3873 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3874 * broadcast, since it is part of a visible user interaction; be as quick
3875 * as possible when handling it.
3876 */
3877 public static final String ACTION_USER_INITIALIZE =
3878 "android.intent.action.USER_INITIALIZE";
3879
3880 /**
3881 * Sent when a user switch is happening, causing the process's user to be
3882 * brought to the foreground. This is only sent to receivers registered
3883 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3884 * Context.registerReceiver}. It is sent to the user that is going to the
3885 * foreground. This is sent as a foreground
3886 * broadcast, since it is part of a visible user interaction; be as quick
3887 * as possible when handling it.
3888 */
3889 public static final String ACTION_USER_FOREGROUND =
3890 "android.intent.action.USER_FOREGROUND";
3891
3892 /**
3893 * Sent when a user switch is happening, causing the process's user to be
3894 * sent to the background. This is only sent to receivers registered
3895 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3896 * Context.registerReceiver}. It is sent to the user that is going to the
3897 * background. This is sent as a foreground
3898 * broadcast, since it is part of a visible user interaction; be as quick
3899 * as possible when handling it.
3900 */
3901 public static final String ACTION_USER_BACKGROUND =
3902 "android.intent.action.USER_BACKGROUND";
3903
3904 /**
3905 * Broadcast sent to the system when a user is added.
3906 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the new user
3907 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that
3908 * user's user ID).
3909 * It is sent to all running users.
3910 * You must hold {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3911 * @hide
3912 */
3913 @SystemApi
3914 public static final String ACTION_USER_ADDED =
3915 "android.intent.action.USER_ADDED";
3916
3917 /**
3918 * Broadcast sent by the system when a user is started. Carries an extra
3919 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only sent to
3920 * registered receivers, not manifest receivers. It is sent to the user
3921 * that has been started. This is sent as a foreground
3922 * broadcast, since it is part of a visible user interaction; be as quick
3923 * as possible when handling it.
3924 *
3925 * <p>
3926 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
3927 * received. For example, the user could have been removed, started or stopped already,
3928 * regardless of which broadcast you receive. Because of that, receivers should always check
3929 * the current state of the user.
3930 * @hide
3931 */
3932 public static final String ACTION_USER_STARTED =
3933 "android.intent.action.USER_STARTED";
3934
3935 /**
3936 * Broadcast sent when a user is in the process of starting. Carries an extra
3937 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only
3938 * sent to registered receivers, not manifest receivers. It is sent to all
3939 * users (including the one that is being started). You must hold
3940 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3941 * this broadcast. This is sent as a background broadcast, since
3942 * its result is not part of the primary UX flow; to safely keep track of
3943 * started/stopped state of a user you can use this in conjunction with
3944 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3945 * other user state broadcasts since those are foreground broadcasts so can
3946 * execute in a different order.
3947 *
3948 * <p>
3949 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
3950 * received. For example, the user could have been removed, started or stopped already,
3951 * regardless of which broadcast you receive. Because of that, receivers should always check
3952 * the current state of the user.
3953 * @hide
3954 */
3955 public static final String ACTION_USER_STARTING =
3956 "android.intent.action.USER_STARTING";
3957
3958 /**
3959 * Broadcast sent when a user is going to be stopped. Carries an extra
3960 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only
3961 * sent to registered receivers, not manifest receivers. It is sent to all
3962 * users (including the one that is being stopped). You must hold
3963 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3964 * this broadcast. The user will not stop until all receivers have
3965 * handled the broadcast. This is sent as a background broadcast, since
3966 * its result is not part of the primary UX flow; to safely keep track of
3967 * started/stopped state of a user you can use this in conjunction with
3968 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3969 * other user state broadcasts since those are foreground broadcasts so can
3970 * execute in a different order.
3971 * <p>
3972 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
3973 * received. For example, the user could have been removed, started or stopped already,
3974 * regardless of which broadcast you receive. Because of that, receivers should always check
3975 * the current state of the user.
3976 * @hide
3977 */
3978 public static final String ACTION_USER_STOPPING =
3979 "android.intent.action.USER_STOPPING";
3980
3981 /**
3982 * Broadcast sent to the system when a user is stopped. Carries an extra
3983 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is similar to
3984 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3985 * specific package. This is only sent to registered receivers, not manifest
3986 * receivers. It is sent to all running users <em>except</em> the one that
3987 * has just been stopped (which is no longer running).
3988 *
3989 * <p>
3990 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
3991 * received. For example, the user could have been removed, started or stopped already,
3992 * regardless of which broadcast you receive. Because of that, receivers should always check
3993 * the current state of the user.
3994 * @hide
3995 */
3996 @TestApi
3997 public static final String ACTION_USER_STOPPED =
3998 "android.intent.action.USER_STOPPED";
3999
4000 /**
4001 * Broadcast sent to the system when a user is removed.
4002 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the user that
4003 * was removed
4004 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that
4005 * user's user ID).
4006 * It is sent to all running users except the
4007 * one that has been removed. The user will not be completely removed until all receivers have
4008 * handled the broadcast. You must hold
4009 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
4010 * @hide
4011 */
4012 @SystemApi
4013 public static final String ACTION_USER_REMOVED =
4014 "android.intent.action.USER_REMOVED";
4015
4016 /**
4017 * Broadcast sent to the system when the user switches.
4018 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle}
4019 * of the user to become the current one
4020 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that
4021 * user's user ID).
4022 * This is only sent to registered receivers, not manifest receivers.
4023 * It is sent to all running users.
4024 * You must hold
4025 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
4026 *
4027 * <p>
4028 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4029 * received. For example, the user could have been removed, started or stopped already,
4030 * regardless of which broadcast you receive. Because of that, receivers should always check
4031 * the current state of the user.
4032 * @hide
4033 */
4034 @SystemApi
4035 public static final String ACTION_USER_SWITCHED =
4036 "android.intent.action.USER_SWITCHED";
4037
4038 /**
4039 * Broadcast Action: Sent when the credential-encrypted private storage has
4040 * become unlocked for the target user. This is only sent to registered
4041 * receivers, not manifest receivers.
4042 *
4043 * <p>
4044 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is
4045 * received. For example, the user could have been removed, started or stopped already,
4046 * regardless of which broadcast you receive. Because of that, receivers should always check
4047 * the current state of the user.
4048 */
4049 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4050 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
4051
4052 /**
4053 * Broadcast sent to the system when a user's information changes. Carries an extra
4054 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
4055 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
4056 * @hide
4057 */
4058 public static final String ACTION_USER_INFO_CHANGED =
4059 "android.intent.action.USER_INFO_CHANGED";
4060
4061 /**
4062 * Broadcast sent to the primary user when an associated managed profile is added (the profile
4063 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
4064 * the {@link UserHandle} of the profile that was added. Only applications (for example
4065 * Launchers) that need to display merged content across both primary and managed profiles need
4066 * to worry about this broadcast. This is only sent to registered receivers,
4067 * not manifest receivers.
4068 */
4069 public static final String ACTION_MANAGED_PROFILE_ADDED =
4070 "android.intent.action.MANAGED_PROFILE_ADDED";
4071
4072 /**
4073 * Broadcast sent to the primary user when an associated managed profile is removed.
4074 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile
4075 * that was removed.
4076 * Only applications (for example Launchers) that need to display merged content across both
4077 * primary and managed profiles need to worry about this broadcast. This is only sent to
4078 * registered receivers, not manifest receivers.
4079 */
4080 public static final String ACTION_MANAGED_PROFILE_REMOVED =
4081 "android.intent.action.MANAGED_PROFILE_REMOVED";
4082
4083 /**
4084 * Broadcast sent to the primary user when the credential-encrypted private storage for
4085 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
4086 * specifies the {@link UserHandle} of the profile that was unlocked. Only applications (for
4087 * example Launchers) that need to display merged content across both primary and managed
4088 * profiles need to worry about this broadcast. This is only sent to registered receivers,
4089 * not manifest receivers.
4090 */
4091 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
4092 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
4093
4094 /**
4095 * Broadcast sent to the primary user when an associated managed profile has become available.
4096 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
4097 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is
4098 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the
4099 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers.
4100 */
4101 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
4102 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
4103
4104 /**
4105 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
4106 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
4107 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is
4108 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the
4109 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers.
4110 */
4111 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
4112 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
4113
4114 /**
4115 * Broadcast sent to the parent user when an associated profile has been started and unlocked.
4116 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile.
4117 * This is only sent to registered receivers, not manifest receivers.
4118 */
4119 public static final String ACTION_PROFILE_ACCESSIBLE =
4120 "android.intent.action.PROFILE_ACCESSIBLE";
4121
4122 /**
4123 * Broadcast sent to the parent user when an associated profile has stopped.
4124 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile.
4125 * This is only sent to registered receivers, not manifest receivers.
4126 */
4127 public static final String ACTION_PROFILE_INACCESSIBLE =
4128 "android.intent.action.PROFILE_INACCESSIBLE";
4129
4130 /**
4131 * Broadcast sent to the system user when the 'device locked' state changes for any user.
4132 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
4133 * the device was locked or unlocked.
4134 *
4135 * This is only sent to registered receivers.
4136 *
4137 * @hide
4138 */
4139 public static final String ACTION_DEVICE_LOCKED_CHANGED =
4140 "android.intent.action.DEVICE_LOCKED_CHANGED";
4141
4142 /**
4143 * Sent when the user taps on the clock widget in the system's "quick settings" area.
4144 */
4145 public static final String ACTION_QUICK_CLOCK =
4146 "android.intent.action.QUICK_CLOCK";
4147
4148 /**
4149 * Activity Action: Shows the brightness setting dialog.
4150 * @hide
4151 */
4152 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
4153 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
4154
4155 /**
4156 * Broadcast Action: A global button was pressed. Includes a single
4157 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
4158 * caused the broadcast.
4159 * @hide
4160 */
4161 @SystemApi
4162 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
4163
4164 /**
4165 * Broadcast Action: Sent when media resource is granted.
4166 * <p>
4167 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
4168 * granted.
4169 * </p>
4170 * <p class="note">
4171 * This is a protected intent that can only be sent by the system.
4172 * </p>
4173 * <p class="note">
4174 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
4175 * </p>
4176 *
4177 * @hide
4178 */
4179 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
4180 "android.intent.action.MEDIA_RESOURCE_GRANTED";
4181
4182 /**
4183 * Broadcast Action: An overlay package has changed. The data contains the
4184 * name of the overlay package which has changed. This is broadcast on all
4185 * changes to the OverlayInfo returned by {@link
4186 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
4187 * most common change is a state change that will change whether the
4188 * overlay is enabled or not.
4189 * @hide
4190 */
4191 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
4192
4193 /**
4194 * Activity Action: Allow the user to select and return one or more existing
4195 * documents. When invoked, the system will display the various
4196 * {@link DocumentsProvider} instances installed on the device, letting the
4197 * user interactively navigate through them. These documents include local
4198 * media, such as photos and video, and documents provided by installed
4199 * cloud storage providers.
4200 * <p>
4201 * Each document is represented as a {@code content://} URI backed by a
4202 * {@link DocumentsProvider}, which can be opened as a stream with
4203 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
4204 * {@link android.provider.DocumentsContract.Document} metadata.
4205 * <p>
4206 * All selected documents are returned to the calling application with
4207 * persistable read and write permission grants. If you want to maintain
4208 * access to the documents across device reboots, you need to explicitly
4209 * take the persistable permissions using
4210 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
4211 * <p>
4212 * Callers must indicate the acceptable document MIME types through
4213 * {@link #setType(String)}. For example, to select photos, use
4214 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
4215 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
4216 * {@literal *}/*.
4217 * <p>
4218 * If the caller can handle multiple returned items (the user performing
4219 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
4220 * to indicate this.
4221 * <p>
4222 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
4223 * URIs that can be opened with
4224 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
4225 * <p>
4226 * Callers can set a document URI through
4227 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4228 * location of documents navigator. System will do its best to launch the
4229 * navigator in the specified document if it's a folder, or the folder that
4230 * contains the specified document if not.
4231 * <p>
4232 * Output: The URI of the item that was picked, returned in
4233 * {@link #getData()}. This must be a {@code content://} URI so that any
4234 * receiver can access it. If multiple documents were selected, they are
4235 * returned in {@link #getClipData()}.
4236 *
4237 * @see DocumentsContract
4238 * @see #ACTION_OPEN_DOCUMENT_TREE
4239 * @see #ACTION_CREATE_DOCUMENT
4240 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4241 */
4242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4243 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
4244
4245 /**
4246 * Activity Action: Allow the user to create a new document. When invoked,
4247 * the system will display the various {@link DocumentsProvider} instances
4248 * installed on the device, letting the user navigate through them. The
4249 * returned document may be a newly created document with no content, or it
4250 * may be an existing document with the requested MIME type.
4251 * <p>
4252 * Each document is represented as a {@code content://} URI backed by a
4253 * {@link DocumentsProvider}, which can be opened as a stream with
4254 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
4255 * {@link android.provider.DocumentsContract.Document} metadata.
4256 * <p>
4257 * Callers must indicate the concrete MIME type of the document being
4258 * created by setting {@link #setType(String)}. This MIME type cannot be
4259 * changed after the document is created.
4260 * <p>
4261 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
4262 * but the user may change this value before creating the file.
4263 * <p>
4264 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
4265 * URIs that can be opened with
4266 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
4267 * <p>
4268 * Callers can set a document URI through
4269 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4270 * location of documents navigator. System will do its best to launch the
4271 * navigator in the specified document if it's a folder, or the folder that
4272 * contains the specified document if not.
4273 * <p>
4274 * Output: The URI of the item that was created. This must be a
4275 * {@code content://} URI so that any receiver can access it.
4276 *
4277 * @see DocumentsContract
4278 * @see #ACTION_OPEN_DOCUMENT
4279 * @see #ACTION_OPEN_DOCUMENT_TREE
4280 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4281 */
4282 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4283 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
4284
4285 /**
4286 * Activity Action: Allow the user to pick a directory subtree. When
4287 * invoked, the system will display the various {@link DocumentsProvider}
4288 * instances installed on the device, letting the user navigate through
4289 * them. Apps can fully manage documents within the returned directory.
4290 * <p>
4291 * To gain access to descendant (child, grandchild, etc) documents, use
4292 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
4293 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
4294 * with the returned URI.
4295 * <p>
4296 * Callers can set a document URI through
4297 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4298 * location of documents navigator. System will do its best to launch the
4299 * navigator in the specified document if it's a folder, or the folder that
4300 * contains the specified document if not.
4301 * <p>
4302 * Output: The URI representing the selected directory tree.
4303 *
4304 * @see DocumentsContract
4305 */
4306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4307 public static final String
4308 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
4309
4310
4311 /**
4312 * Activity Action: Perform text translation.
4313 * <p>
4314 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
4315 * <p>
4316 * Output: nothing.
4317 */
4318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4319 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
4320
4321 /**
4322 * Activity Action: Define the meaning of the selected word(s).
4323 * <p>
4324 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
4325 * <p>
4326 * Output: nothing.
4327 */
4328 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4329 public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
4330
4331 /**
4332 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
4333 * exisiting sensor being disconnected.
4334 *
4335 * <p class="note">This is a protected intent that can only be sent by the system.</p>
4336 *
4337 * {@hide}
4338 */
4339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4340 public static final String
4341 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
4342
4343 /**
4344 * Deprecated - use ACTION_FACTORY_RESET instead.
4345 * @hide
4346 * @removed
4347 */
4348 @Deprecated
4349 @SystemApi
4350 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
4351
4352 /**
4353 * Broadcast intent sent by the RecoverySystem to inform listeners that a global clear (wipe)
4354 * is about to be performed.
4355 * @hide
4356 */
4357 @SystemApi
4358 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4359 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
4360 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
4361
4362 /**
4363 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4364 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4365 *
4366 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
4367 *
4368 * @hide
4369 */
4370 @Deprecated
4371 public static final String EXTRA_FORCE_MASTER_CLEAR =
4372 "android.intent.extra.FORCE_MASTER_CLEAR";
4373
4374 /**
4375 * A broadcast action to trigger a factory reset.
4376 *
4377 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
4378 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
4379 *
4380 * <p>Not for use by third-party applications.
4381 *
4382 * @see #EXTRA_FORCE_FACTORY_RESET
4383 *
4384 * {@hide}
4385 */
4386 @SystemApi
4387 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4388 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
4389
4390 /**
4391 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4392 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4393 *
4394 * <p>Not for use by third-party applications.
4395 *
4396 * @hide
4397 */
4398 @SystemApi
4399 public static final String EXTRA_FORCE_FACTORY_RESET =
4400 "android.intent.extra.FORCE_FACTORY_RESET";
4401
4402 /**
4403 * Broadcast action: report that a settings element is being restored from backup. The intent
4404 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
4405 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
4406 * is the value of that settings entry prior to the restore operation, and
4407 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
4408 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
4409 * values are represented as strings, the fourth one as int.
4410 *
4411 * <p>This broadcast is sent only for settings provider entries known to require special
4412 * handling around restore time to specific receivers. These entries are found in the
4413 * BROADCAST_ON_RESTORE table within the provider's backup agent implementation.
4414 *
4415 * @see #EXTRA_SETTING_NAME
4416 * @see #EXTRA_SETTING_PREVIOUS_VALUE
4417 * @see #EXTRA_SETTING_NEW_VALUE
4418 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
4419 * {@hide}
4420 */
4421 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4422 @SuppressLint("ActionValue")
4423 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
4424
4425 /**
4426 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4427 * Contain the name of the restored setting.
4428 * {@hide}
4429 */
4430 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4431 @SuppressLint("ActionValue")
4432 public static final String EXTRA_SETTING_NAME = "setting_name";
4433
4434 /**
4435 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4436 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry prior to the restore
4437 * operation.
4438 * {@hide}
4439 */
4440 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4441 @SuppressLint("ActionValue")
4442 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
4443
4444 /**
4445 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4446 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry being restored.
4447 * {@hide}
4448 */
4449 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4450 @SuppressLint("ActionValue")
4451 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
4452
4453 /**
4454 * Int intent extra to be used with {@link ACTION_SETTING_RESTORED}.
4455 * Contain the version of the SDK that the setting has been restored from (corresponds to
4456 * {@link android.os.Build.VERSION#SDK_INT}).
4457 * {@hide}
4458 */
4459 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
4460 @SuppressLint("ActionValue")
4461 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
4462
4463 /**
4464 * Activity Action: Process a piece of text.
4465 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
4466 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
4467 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
4468 */
4469 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4470 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
4471
4472 /**
4473 * Broadcast Action: The sim card state has changed.
4474 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
4475 * because TelephonyIntents is an internal class.
4476 * The intent will have following extras.</p>
4477 * <p>
4478 * @see #EXTRA_SIM_STATE
4479 * @see #EXTRA_SIM_LOCKED_REASON
4480 * @see #EXTRA_REBROADCAST_ON_UNLOCK
4481 *
4482 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4483 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4484 *
4485 * @hide
4486 */
4487 @Deprecated
4488 @SystemApi
4489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4490 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
4491
4492 /**
4493 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4494 * This will have one of the following intent values.
4495 * @see #SIM_STATE_UNKNOWN
4496 * @see #SIM_STATE_NOT_READY
4497 * @see #SIM_STATE_ABSENT
4498 * @see #SIM_STATE_PRESENT
4499 * @see #SIM_STATE_CARD_IO_ERROR
4500 * @see #SIM_STATE_CARD_RESTRICTED
4501 * @see #SIM_STATE_LOCKED
4502 * @see #SIM_STATE_READY
4503 * @see #SIM_STATE_IMSI
4504 * @see #SIM_STATE_LOADED
4505 * @hide
4506 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4507 */
4508 public static final String EXTRA_SIM_STATE = "ss";
4509
4510 /**
4511 * The intent value UNKNOWN represents the SIM state unknown
4512 * @hide
4513 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4514 */
4515 public static final String SIM_STATE_UNKNOWN = "UNKNOWN";
4516
4517 /**
4518 * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on
4519 * @hide
4520 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4521 */
4522 public static final String SIM_STATE_NOT_READY = "NOT_READY";
4523
4524 /**
4525 * The intent value ABSENT means the SIM card is missing
4526 * @hide
4527 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4528 */
4529 public static final String SIM_STATE_ABSENT = "ABSENT";
4530
4531 /**
4532 * The intent value PRESENT means the device has a SIM card inserted
4533 * @hide
4534 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4535 */
4536 public static final String SIM_STATE_PRESENT = "PRESENT";
4537
4538 /**
4539 * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error
4540 * @hide
4541 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4542 */
4543 static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR";
4544
4545 /**
4546 * The intent value CARD_RESTRICTED means card is present but not usable due to carrier
4547 * restrictions
4548 * @hide
4549 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4550 */
4551 static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED";
4552
4553 /**
4554 * The intent value LOCKED means the SIM is locked by PIN or by network
4555 * @hide
4556 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4557 */
4558 public static final String SIM_STATE_LOCKED = "LOCKED";
4559
4560 /**
4561 * The intent value READY means the SIM is ready to be accessed
4562 * @hide
4563 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4564 */
4565 public static final String SIM_STATE_READY = "READY";
4566
4567 /**
4568 * The intent value IMSI means the SIM IMSI is ready in property
4569 * @hide
4570 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4571 */
4572 public static final String SIM_STATE_IMSI = "IMSI";
4573
4574 /**
4575 * The intent value LOADED means all SIM records, including IMSI, are loaded
4576 * @hide
4577 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4578 */
4579 public static final String SIM_STATE_LOADED = "LOADED";
4580
4581 /**
4582 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4583 * This extra will have one of the following intent values.
4584 * <p>
4585 * @see #SIM_LOCKED_ON_PIN
4586 * @see #SIM_LOCKED_ON_PUK
4587 * @see #SIM_LOCKED_NETWORK
4588 * @see #SIM_ABSENT_ON_PERM_DISABLED
4589 *
4590 * @hide
4591 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4592 */
4593 public static final String EXTRA_SIM_LOCKED_REASON = "reason";
4594
4595 /**
4596 * The intent value PIN means the SIM is locked on PIN1
4597 * @hide
4598 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4599 */
4600 public static final String SIM_LOCKED_ON_PIN = "PIN";
4601
4602 /**
4603 * The intent value PUK means the SIM is locked on PUK1
4604 * @hide
4605 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4606 */
4607 /* PUK means ICC is locked on PUK1 */
4608 public static final String SIM_LOCKED_ON_PUK = "PUK";
4609
4610 /**
4611 * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION
4612 * @hide
4613 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4614 */
4615 public static final String SIM_LOCKED_NETWORK = "NETWORK";
4616
4617 /**
4618 * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails
4619 * @hide
4620 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4621 */
4622 public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED";
4623
4624 /**
4625 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast
4626 * is a rebroadcast on unlock. Defaults to {@code false} if not specified.
4627 *
4628 * @hide
4629 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4630 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4631 */
4632 public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock";
4633
4634 /**
4635 * Broadcast Action: indicate that the phone service state has changed.
4636 * The intent will have the following extra values:</p>
4637 * <p>
4638 * @see #EXTRA_VOICE_REG_STATE
4639 * @see #EXTRA_DATA_REG_STATE
4640 * @see #EXTRA_VOICE_ROAMING_TYPE
4641 * @see #EXTRA_DATA_ROAMING_TYPE
4642 * @see #EXTRA_OPERATOR_ALPHA_LONG
4643 * @see #EXTRA_OPERATOR_ALPHA_SHORT
4644 * @see #EXTRA_OPERATOR_NUMERIC
4645 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
4646 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
4647 * @see #EXTRA_DATA_OPERATOR_NUMERIC
4648 * @see #EXTRA_MANUAL
4649 * @see #EXTRA_VOICE_RADIO_TECH
4650 * @see #EXTRA_DATA_RADIO_TECH
4651 * @see #EXTRA_CSS_INDICATOR
4652 * @see #EXTRA_NETWORK_ID
4653 * @see #EXTRA_SYSTEM_ID
4654 * @see #EXTRA_CDMA_ROAMING_INDICATOR
4655 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
4656 * @see #EXTRA_EMERGENCY_ONLY
4657 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
4658 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
4659 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
4660 *
4661 * <p class="note">
4662 * Requires the READ_PHONE_STATE permission.
4663 *
4664 * <p class="note">This is a protected intent that can only be sent by the system.
4665 * @hide
4666 * @removed
4667 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
4668 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
4669 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
4670 * for a given subscription id and field with a ContentObserver or using JobScheduler.
4671 */
4672 @Deprecated
4673 @SystemApi
4674 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
4675 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
4676
4677 /**
4678 * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService}
4679 * for querying Data Loader Service providers. Data loader service providers register this
4680 * intent filter in their manifests, so that they can be looked up and bound to by
4681 * {@code DataLoaderManagerService}.
4682 *
4683 * <p class="note">This is a protected intent that can only be sent by the system.
4684 *
4685 * Data loader service providers must be privileged apps.
4686 * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such
4687 * data loader service provider.
4688 *
4689 * @hide
4690 */
4691 @SystemApi
4692 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
4693 public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA";
4694
4695 /**
4696 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
4697 * state.
4698 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4699 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4700 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4701 * @see android.telephony.ServiceState#STATE_POWER_OFF
4702 * @hide
4703 * @removed
4704 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
4705 */
4706 @Deprecated
4707 @SystemApi
4708 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4709
4710 /**
4711 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4712 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4713 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4714 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4715 * @see android.telephony.ServiceState#STATE_POWER_OFF
4716 * @hide
4717 * @removed
4718 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
4719 */
4720 @Deprecated
4721 @SystemApi
4722 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4723
4724 /**
4725 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4726 * type.
4727 * @hide
4728 * @removed
4729 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
4730 */
4731 @Deprecated
4732 @SystemApi
4733 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4734
4735 /**
4736 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4737 * type.
4738 * @hide
4739 * @removed
4740 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
4741 */
4742 @Deprecated
4743 @SystemApi
4744 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4745
4746 /**
4747 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4748 * registered voice operator name in long alphanumeric format.
4749 * {@code null} if the operator name is not known or unregistered.
4750 * @hide
4751 * @removed
4752 * @deprecated Use
4753 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
4754 */
4755 @Deprecated
4756 @SystemApi
4757 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4758
4759 /**
4760 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4761 * registered voice operator name in short alphanumeric format.
4762 * {@code null} if the operator name is not known or unregistered.
4763 * @hide
4764 * @removed
4765 * @deprecated Use
4766 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
4767 */
4768 @Deprecated
4769 @SystemApi
4770 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4771
4772 /**
4773 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4774 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4775 * network.
4776 * @hide
4777 * @removed
4778 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
4779 */
4780 @Deprecated
4781 @SystemApi
4782 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4783
4784 /**
4785 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4786 * registered data operator name in long alphanumeric format.
4787 * {@code null} if the operator name is not known or unregistered.
4788 * @hide
4789 * @removed
4790 * @deprecated Use
4791 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
4792 */
4793 @Deprecated
4794 @SystemApi
4795 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4796
4797 /**
4798 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4799 * registered data operator name in short alphanumeric format.
4800 * {@code null} if the operator name is not known or unregistered.
4801 * @hide
4802 * @removed
4803 * @deprecated Use
4804 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
4805 */
4806 @Deprecated
4807 @SystemApi
4808 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4809
4810 /**
4811 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4812 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4813 * data operator.
4814 * @hide
4815 * @removed
4816 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
4817 */
4818 @Deprecated
4819 @SystemApi
4820 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4821
4822 /**
4823 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4824 * network selection mode is manual.
4825 * Will be {@code true} if manual mode, {@code false} if automatic mode.
4826 * @hide
4827 * @removed
4828 * @deprecated Use
4829 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
4830 */
4831 @Deprecated
4832 @SystemApi
4833 public static final String EXTRA_MANUAL = "manual";
4834
4835 /**
4836 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4837 * radio technology.
4838 * @hide
4839 * @removed
4840 * @deprecated Use
4841 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
4842 */
4843 @Deprecated
4844 @SystemApi
4845 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4846
4847 /**
4848 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4849 * radio technology.
4850 * @hide
4851 * @removed
4852 * @deprecated Use
4853 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
4854 */
4855 @Deprecated
4856 @SystemApi
4857 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4858
4859 /**
4860 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4861 * support on CDMA network.
4862 * Will be {@code true} if support, {@code false} otherwise.
4863 * @hide
4864 * @removed
4865 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
4866 */
4867 @Deprecated
4868 @SystemApi
4869 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4870
4871 /**
4872 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4873 * id. {@code Integer.MAX_VALUE} if unknown.
4874 * @hide
4875 * @removed
4876 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
4877 */
4878 @Deprecated
4879 @SystemApi
4880 public static final String EXTRA_NETWORK_ID = "networkId";
4881
4882 /**
4883 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4884 * {@code Integer.MAX_VALUE} if unknown.
4885 * @hide
4886 * @removed
4887 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
4888 */
4889 @Deprecated
4890 @SystemApi
4891 public static final String EXTRA_SYSTEM_ID = "systemId";
4892
4893 /**
4894 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4895 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4896 * @hide
4897 * @removed
4898 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
4899 */
4900 @Deprecated
4901 @SystemApi
4902 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4903
4904 /**
4905 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4906 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4907 * @hide
4908 * @removed
4909 * @deprecated Use
4910 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
4911 */
4912 @Deprecated
4913 @SystemApi
4914 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4915
4916 /**
4917 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4918 * only mode.
4919 * {@code true} if in emergency only mode, {@code false} otherwise.
4920 * @hide
4921 * @removed
4922 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
4923 */
4924 @Deprecated
4925 @SystemApi
4926 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4927
4928 /**
4929 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4930 * registration state is roaming.
4931 * {@code true} if registration indicates roaming, {@code false} otherwise
4932 * @hide
4933 * @removed
4934 * @deprecated Use
4935 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
4936 */
4937 @Deprecated
4938 @SystemApi
4939 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4940 "isDataRoamingFromRegistration";
4941
4942 /**
4943 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4944 * aggregation is in use.
4945 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4946 * @hide
4947 * @removed
4948 * @deprecated Use
4949 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
4950 */
4951 @Deprecated
4952 @SystemApi
4953 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4954
4955 /**
4956 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4957 * is reduced from the rsrp threshold while calculating signal strength level.
4958 * @hide
4959 * @removed
4960 */
4961 @Deprecated
4962 @SystemApi
4963 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4964
4965 /**
4966 * The name of the extra used to define the text to be processed, as a
4967 * CharSequence. Note that this may be a styled CharSequence, so you must use
4968 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
4969 */
4970 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4971 /**
4972 * The name of the boolean extra used to define if the processed text will be used as read-only.
4973 */
4974 public static final String EXTRA_PROCESS_TEXT_READONLY =
4975 "android.intent.extra.PROCESS_TEXT_READONLY";
4976
4977 /**
4978 * Broadcast action: reports when a new thermal event has been reached. When the device
4979 * is reaching its maximum temperatue, the thermal level reported
4980 * {@hide}
4981 */
4982 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4983 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4984
4985 /** {@hide} */
4986 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4987
4988 /**
4989 * Thermal state when the device is normal. This state is sent in the
4990 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4991 * {@hide}
4992 */
4993 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4994
4995 /**
4996 * Thermal state where the device is approaching its maximum threshold. This state is sent in
4997 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4998 * {@hide}
4999 */
5000 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
5001
5002 /**
5003 * Thermal state where the device has reached its maximum threshold. This state is sent in the
5004 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
5005 * {@hide}
5006 */
5007 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
5008
5009 /**
5010 * Broadcast Action: Indicates the dock in idle state while device is docked.
5011 *
5012 * <p class="note">This is a protected intent that can only be sent
5013 * by the system.
5014 *
5015 * @hide
5016 */
5017 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
5018
5019 /**
5020 * Broadcast Action: Indicates the dock in active state while device is docked.
5021 *
5022 * <p class="note">This is a protected intent that can only be sent
5023 * by the system.
5024 *
5025 * @hide
5026 */
5027 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
5028
5029 /**
5030 * Broadcast Action: Indicates that a new device customization has been
5031 * downloaded and applied (packages installed, runtime resource overlays
5032 * enabled, xml files copied, ...), and that it is time for components that
5033 * need to for example clear their caches to do so now.
5034 *
5035 * @hide
5036 */
5037 @SystemApi
5038 public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
5039 "android.intent.action.DEVICE_CUSTOMIZATION_READY";
5040
5041
5042 /**
5043 * Activity Action: Display an activity state associated with an unique {@link LocusId}.
5044 *
5045 * <p>For example, a chat app could use the context to resume a conversation between 2 users.
5046 *
5047 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
5048 * app domain. Should be stable across reboots and backup / restore.
5049 * <p>Output: nothing.
5050 */
5051 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
5052 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
5053
5054 /**
5055 * Broadcast Action: Sent to the integrity component when a package
5056 * needs to be verified. The data contains the package URI along with other relevant
5057 * information.
5058 *
5059 * <p class="note">
5060 * This is a protected intent that can only be sent by the system.
5061 * </p>
5062 *
5063 * @hide
5064 */
5065 @SystemApi
5066 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
5067 public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION =
5068 "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION";
5069
5070 /**
5071 * Broadcast Action: Start the foreground service manager.
5072 *
5073 * <p class="note">
5074 * This is a protected intent that can only be sent by the system.
5075 * </p>
5076 *
5077 * @hide
5078 */
5079 public static final String ACTION_SHOW_FOREGROUND_SERVICE_MANAGER =
5080 "android.intent.action.SHOW_FOREGROUND_SERVICE_MANAGER";
5081
5082 // ---------------------------------------------------------------------
5083 // ---------------------------------------------------------------------
5084 // Standard intent categories (see addCategory()).
5085
5086 /**
5087 * Set if the activity should be an option for the default action
5088 * (center press) to perform on a piece of data. Setting this will
5089 * hide from the user any activities without it set when performing an
5090 * action on some data. Note that this is normally -not- set in the
5091 * Intent when initiating an action -- it is for use in intent filters
5092 * specified in packages.
5093 */
5094 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5095 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
5096 /**
5097 * Activities that can be safely invoked from a browser must support this
5098 * category. For example, if the user is viewing a web page or an e-mail
5099 * and clicks on a link in the text, the Intent generated execute that
5100 * link will require the BROWSABLE category, so that only activities
5101 * supporting this category will be considered as possible actions. By
5102 * supporting this category, you are promising that there is nothing
5103 * damaging (without user intervention) that can happen by invoking any
5104 * matching Intent.
5105 */
5106 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5107 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
5108 /**
5109 * Categories for activities that can participate in voice interaction.
5110 * An activity that supports this category must be prepared to run with
5111 * no UI shown at all (though in some case it may have a UI shown), and
5112 * rely on {@link android.app.VoiceInteractor} to interact with the user.
5113 */
5114 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5115 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
5116 /**
5117 * Set if the activity should be considered as an alternative action to
5118 * the data the user is currently viewing. See also
5119 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
5120 * applies to the selection in a list of items.
5121 *
5122 * <p>Supporting this category means that you would like your activity to be
5123 * displayed in the set of alternative things the user can do, usually as
5124 * part of the current activity's options menu. You will usually want to
5125 * include a specific label in the &lt;intent-filter&gt; of this action
5126 * describing to the user what it does.
5127 *
5128 * <p>The action of IntentFilter with this category is important in that it
5129 * describes the specific action the target will perform. This generally
5130 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
5131 * a specific name such as "com.android.camera.action.CROP. Only one
5132 * alternative of any particular action will be shown to the user, so using
5133 * a specific action like this makes sure that your alternative will be
5134 * displayed while also allowing other applications to provide their own
5135 * overrides of that particular action.
5136 */
5137 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5138 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
5139 /**
5140 * Set if the activity should be considered as an alternative selection
5141 * action to the data the user has currently selected. This is like
5142 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
5143 * of items from which the user can select, giving them alternatives to the
5144 * default action that will be performed on it.
5145 */
5146 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5147 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
5148 /**
5149 * Intended to be used as a tab inside of a containing TabActivity.
5150 */
5151 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5152 public static final String CATEGORY_TAB = "android.intent.category.TAB";
5153 /**
5154 * Should be displayed in the top-level launcher.
5155 */
5156 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5157 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
5158 /**
5159 * Indicates an activity optimized for Leanback mode, and that should
5160 * be displayed in the Leanback launcher.
5161 */
5162 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5163 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
5164 /**
5165 * Indicates the preferred entry-point activity when an application is launched from a Car
5166 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
5167 * fallback, or exclude the application entirely.
5168 * @hide
5169 */
5170 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5171 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
5172 /**
5173 * Used to indicate that the activity can be used in communal mode.
5174 * @hide
5175 */
5176 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5177 public static final String CATEGORY_COMMUNAL_MODE = "android.intent.category.COMMUNAL_MODE";
5178 /**
5179 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
5180 * @hide
5181 */
5182 @SystemApi
5183 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
5184 /**
5185 * Provides information about the package it is in; typically used if
5186 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
5187 * a front-door to the user without having to be shown in the all apps list.
5188 */
5189 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5190 public static final String CATEGORY_INFO = "android.intent.category.INFO";
5191 /**
5192 * This is the home activity, that is the first activity that is displayed
5193 * when the device boots.
5194 */
5195 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5196 public static final String CATEGORY_HOME = "android.intent.category.HOME";
5197 /**
5198 * This is the home activity that is displayed when the device is finished setting up and ready
5199 * for use.
5200 * @hide
5201 */
5202 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5203 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
5204 /**
5205 * The home activity shown on secondary displays that support showing home activities.
5206 */
5207 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5208 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
5209 /**
5210 * This is the setup wizard activity, that is the first activity that is displayed
5211 * when the user sets up the device for the first time.
5212 * @hide
5213 */
5214 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5215 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
5216 /**
5217 * This is the home activity, that is the activity that serves as the launcher app
5218 * from there the user can start other apps. Often components with lower/higher
5219 * priority intent filters handle the home intent, for example SetupWizard, to
5220 * setup the device and we need to be able to distinguish the home app from these
5221 * setup helpers.
5222 * @hide
5223 */
5224 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5225 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
5226 /**
5227 * This activity is a preference panel.
5228 */
5229 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5230 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
5231 /**
5232 * This activity is a development preference panel.
5233 */
5234 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5235 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
5236 /**
5237 * Capable of running inside a parent activity container.
5238 */
5239 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5240 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
5241 /**
5242 * This activity allows the user to browse and download new applications.
5243 */
5244 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5245 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
5246 /**
5247 * This activity may be exercised by the monkey or other automated test tools.
5248 */
5249 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5250 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
5251 /**
5252 * To be used as a test (not part of the normal user experience).
5253 */
5254 public static final String CATEGORY_TEST = "android.intent.category.TEST";
5255 /**
5256 * To be used as a unit test (run through the Test Harness).
5257 */
5258 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
5259 /**
5260 * To be used as a sample code example (not part of the normal user
5261 * experience).
5262 */
5263 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
5264
5265 /**
5266 * Used to indicate that an intent only wants URIs that can be opened with
5267 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
5268 * must support at least the columns defined in {@link OpenableColumns} when
5269 * queried.
5270 *
5271 * @see #ACTION_GET_CONTENT
5272 * @see #ACTION_OPEN_DOCUMENT
5273 * @see #ACTION_CREATE_DOCUMENT
5274 */
5275 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5276 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
5277
5278 /**
5279 * Used to indicate that an intent filter can accept files which are not necessarily
5280 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
5281 * at least streamable via
5282 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
5283 * using one of the stream types exposed via
5284 * {@link ContentResolver#getStreamTypes(Uri, String)}.
5285 *
5286 * @see #ACTION_SEND
5287 * @see #ACTION_SEND_MULTIPLE
5288 */
5289 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5290 public static final String CATEGORY_TYPED_OPENABLE =
5291 "android.intent.category.TYPED_OPENABLE";
5292
5293 /**
5294 * To be used as code under test for framework instrumentation tests.
5295 */
5296 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
5297 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
5298 /**
5299 * An activity to run when device is inserted into a car dock.
5300 * Used with {@link #ACTION_MAIN} to launch an activity. For more
5301 * information, see {@link android.app.UiModeManager}.
5302 */
5303 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5304 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
5305 /**
5306 * An activity to run when device is inserted into a desk dock.
5307 * Used with {@link #ACTION_MAIN} to launch an activity. For more
5308 * information, see {@link android.app.UiModeManager}.
5309 */
5310 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5311 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
5312 /**
5313 * An activity to run when device is inserted into a analog (low end) dock.
5314 * Used with {@link #ACTION_MAIN} to launch an activity. For more
5315 * information, see {@link android.app.UiModeManager}.
5316 */
5317 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5318 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
5319
5320 /**
5321 * An activity to run when device is inserted into a digital (high end) dock.
5322 * Used with {@link #ACTION_MAIN} to launch an activity. For more
5323 * information, see {@link android.app.UiModeManager}.
5324 */
5325 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5326 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
5327
5328 /**
5329 * Used to indicate that the activity can be used in a car environment.
5330 */
5331 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5332 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
5333
5334 /**
5335 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
5336 * Used with {@link #ACTION_MAIN} to launch an activity. For more
5337 * information, see {@link android.app.UiModeManager}.
5338 */
5339 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5340 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
5341
5342 /**
5343 * The accessibility shortcut is a global gesture for users with disabilities to trigger an
5344 * important for them accessibility feature to help developers determine whether they want to
5345 * make their activity a shortcut target.
5346 * <p>
5347 * An activity of interest to users with accessibility needs may request to be the target of
5348 * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category,
5349 * which will be dispatched by the system when the user activates the shortcut when it is
5350 * configured to point at this target.
5351 * </p>
5352 * <p>
5353 * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must
5354 * also do two things:
5355 * <ul>
5356 * <ol>
5357 * Specify that it handles the <code>android.intent.action.MAIN</code>
5358 * {@link android.content.Intent}
5359 * with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>.
5360 * </ol>
5361 * <ol>
5362 * Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the
5363 * manifest when declaring the activity.
5364 * </ol>
5365 * </ul>
5366 * If either of these items is missing, the system will ignore the accessibility shortcut
5367 * target. Following is an example declaration:
5368 * </p>
5369 * <pre>
5370 * &lt;activity android:name=".MainActivity"
5371 * . . .
5372 * &lt;intent-filter&gt;
5373 * &lt;action android:name="android.intent.action.MAIN" /&gt;
5374 * &lt;category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /&gt;
5375 * &lt;/intent-filter&gt;
5376 * &lt;meta-data android:name="android.accessibilityshortcut.target"
5377 * android:resource="@xml/accessibilityshortcut" /&gt;
5378 * &lt;/activity&gt;
5379 * </pre>
5380 * <p> This is a sample XML file configuring a accessibility shortcut target: </p>
5381 * <pre>
5382 * &lt;accessibility-shortcut-target
5383 * android:description="@string/shortcut_target_description"
5384 * android:summary="@string/shortcut_target_summary"
5385 * android:animatedImageDrawable="@drawable/shortcut_target_animated_image"
5386 * android:htmlDescription="@string/shortcut_target_html_description"
5387 * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /&gt;
5388 * </pre>
5389 * <p>
5390 * Both description and summary are necessary. The system will ignore the accessibility
5391 * shortcut target if they are missing. The animated image and html description are supported
5392 * to help users understand how to use the shortcut target. The settings activity is a
5393 * component name that allows the user to modify the settings for this accessibility shortcut
5394 * target.
5395 * </p>
5396 */
5397 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5398 public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET =
5399 "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET";
5400 // ---------------------------------------------------------------------
5401 // ---------------------------------------------------------------------
5402 // Application launch intent categories (see addCategory()).
5403
5404 /**
5405 * Used with {@link #ACTION_MAIN} to launch the browser application.
5406 * The activity should be able to browse the Internet.
5407 * <p>NOTE: This should not be used as the primary key of an Intent,
5408 * since it will not result in the app launching with the correct
5409 * action and category. Instead, use this with
5410 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5411 * Intent with this category in the selector.</p>
5412 */
5413 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5414 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
5415
5416 /**
5417 * Used with {@link #ACTION_MAIN} to launch the calculator application.
5418 * The activity should be able to perform standard arithmetic operations.
5419 * <p>NOTE: This should not be used as the primary key of an Intent,
5420 * since it will not result in the app launching with the correct
5421 * action and category. Instead, use this with
5422 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5423 * Intent with this category in the selector.</p>
5424 */
5425 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5426 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
5427
5428 /**
5429 * Used with {@link #ACTION_MAIN} to launch the calendar application.
5430 * The activity should be able to view and manipulate calendar entries.
5431 * <p>NOTE: This should not be used as the primary key of an Intent,
5432 * since it will not result in the app launching with the correct
5433 * action and category. Instead, use this with
5434 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5435 * Intent with this category in the selector.</p>
5436 */
5437 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5438 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
5439
5440 /**
5441 * Used with {@link #ACTION_MAIN} to launch the contacts application.
5442 * The activity should be able to view and manipulate address book entries.
5443 * <p>NOTE: This should not be used as the primary key of an Intent,
5444 * since it will not result in the app launching with the correct
5445 * action and category. Instead, use this with
5446 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5447 * Intent with this category in the selector.</p>
5448 */
5449 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5450 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
5451
5452 /**
5453 * Used with {@link #ACTION_MAIN} to launch the email application.
5454 * The activity should be able to send and receive email.
5455 * <p>NOTE: This should not be used as the primary key of an Intent,
5456 * since it will not result in the app launching with the correct
5457 * action and category. Instead, use this with
5458 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5459 * Intent with this category in the selector.</p>
5460 */
5461 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5462 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
5463
5464 /**
5465 * Used with {@link #ACTION_MAIN} to launch the gallery application.
5466 * The activity should be able to view and manipulate image and video files
5467 * stored on the device.
5468 * <p>NOTE: This should not be used as the primary key of an Intent,
5469 * since it will not result in the app launching with the correct
5470 * action and category. Instead, use this with
5471 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5472 * Intent with this category in the selector.</p>
5473 */
5474 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5475 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
5476
5477 /**
5478 * Used with {@link #ACTION_MAIN} to launch the maps application.
5479 * The activity should be able to show the user's current location and surroundings.
5480 * <p>NOTE: This should not be used as the primary key of an Intent,
5481 * since it will not result in the app launching with the correct
5482 * action and category. Instead, use this with
5483 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5484 * Intent with this category in the selector.</p>
5485 */
5486 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5487 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
5488
5489 /**
5490 * Used with {@link #ACTION_MAIN} to launch the messaging application.
5491 * The activity should be able to send and receive text messages.
5492 * <p>NOTE: This should not be used as the primary key of an Intent,
5493 * since it will not result in the app launching with the correct
5494 * action and category. Instead, use this with
5495 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5496 * Intent with this category in the selector.</p>
5497 */
5498 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5499 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
5500
5501 /**
5502 * Used with {@link #ACTION_MAIN} to launch the music application.
5503 * The activity should be able to play, browse, or manipulate music files
5504 * stored on the device.
5505 * <p>NOTE: This should not be used as the primary key of an Intent,
5506 * since it will not result in the app launching with the correct
5507 * action and category. Instead, use this with
5508 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5509 * Intent with this category in the selector.</p>
5510 */
5511 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5512 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
5513
5514 /**
5515 * Used with {@link #ACTION_MAIN} to launch the files application.
5516 * The activity should be able to browse and manage files stored on the device.
5517 * <p>NOTE: This should not be used as the primary key of an Intent,
5518 * since it will not result in the app launching with the correct
5519 * action and category. Instead, use this with
5520 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5521 * Intent with this category in the selector.</p>
5522 */
5523 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5524 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES";
5525
5526 /**
5527 * Used with {@link #ACTION_MAIN} to launch the weather application.
5528 * The activity should be able to give the user information about the weather
5529 * <p>NOTE: This should not be used as the primary key of an Intent,
5530 * since it will not result in the app launching with the correct
5531 * action and category. Instead, use this with
5532 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5533 * Intent with this category in the selector.</p>
5534 */
5535 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5536 public static final String CATEGORY_APP_WEATHER = "android.intent.category.APP_WEATHER";
5537
5538 /**
5539 * Used with {@link #ACTION_MAIN} to launch the fitness application.
5540 * The activity should be able to give the user fitness information and manage workouts
5541 * <p>NOTE: This should not be used as the primary key of an Intent,
5542 * since it will not result in the app launching with the correct
5543 * action and category. Instead, use this with
5544 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5545 * Intent with this category in the selector.</p>
5546 */
5547 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5548 public static final String CATEGORY_APP_FITNESS = "android.intent.category.APP_FITNESS";
5549
5550 // ---------------------------------------------------------------------
5551 // ---------------------------------------------------------------------
5552 // Standard extra data keys.
5553
5554 /**
5555 * The initial data to place in a newly created record. Use with
5556 * {@link #ACTION_INSERT}. The data here is a Map containing the same
5557 * fields as would be given to the underlying ContentProvider.insert()
5558 * call.
5559 */
5560 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
5561
5562 /**
5563 * A constant CharSequence that is associated with the Intent, used with
5564 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
5565 * this may be a styled CharSequence, so you must use
5566 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
5567 * retrieve it.
5568 */
5569 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
5570
5571 /**
5572 * A constant String that is associated with the Intent, used with
5573 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
5574 * as HTML formatted text. Note that you <em>must</em> also supply
5575 * {@link #EXTRA_TEXT}.
5576 */
5577 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
5578
5579 /**
5580 * A content: URI holding a stream of data associated with the Intent,
5581 * used with {@link #ACTION_SEND} to supply the data being sent.
5582 */
5583 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
5584
5585 /**
5586 * A String[] holding e-mail addresses that should be delivered to.
5587 */
5588 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
5589
5590 /**
5591 * A String[] holding e-mail addresses that should be carbon copied.
5592 */
5593 public static final String EXTRA_CC = "android.intent.extra.CC";
5594
5595 /**
5596 * A String[] holding e-mail addresses that should be blind carbon copied.
5597 */
5598 public static final String EXTRA_BCC = "android.intent.extra.BCC";
5599
5600 /**
5601 * A constant string holding the desired subject line of a message.
5602 */
5603 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
5604
5605 /**
5606 * An Intent describing the choices you would like shown with
5607 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
5608 */
5609 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
5610
5611 /**
5612 * An int representing the user ID to be used.
5613 *
5614 * @hide
5615 */
5616 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
5617
5618 /**
5619 * An int representing the task id to be retrieved. This is used when a launch from recents is
5620 * intercepted by another action such as credentials confirmation to remember which task should
5621 * be resumed when complete.
5622 *
5623 * @hide
5624 */
5625 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
5626
5627 /**
5628 * A String[] holding attribution tags when used with
5629 * {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
5630 * and ACTION_MANAGE_PERMISSION_USAGE
5631 *
5632 * E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc.
5633 */
5634 public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS";
5635
5636 /**
5637 * A long representing the start timestamp (epoch time in millis) of the permission usage
5638 * when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
5639 * and ACTION_MANAGE_PERMISSION_USAGE
5640 */
5641 public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME";
5642
5643 /**
5644 * A long representing the end timestamp (epoch time in millis) of the permission usage when
5645 * used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
5646 * and ACTION_MANAGE_PERMISSION_USAGE
5647 */
5648 public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME";
5649
5650 /**
5651 * A boolean extra, when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
5652 * and {@link #ACTION_MANAGE_PERMISSION_USAGE},
5653 * that specifies whether the permission usage system UI is showing attribution information
5654 * for the chosen entry.
5655 *
5656 * <p> The extra can only be true if application has specified attributionsAreUserVisible
5657 * in its manifest. </p>
5658 *
5659 * <p> Applications can use this extra to improve their permission usage explanation
5660 * experience. </p>
5661 * @hide
5662 */
5663 @SystemApi
5664 public static final String EXTRA_SHOWING_ATTRIBUTION =
5665 "android.intent.extra.SHOWING_ATTRIBUTION";
5666
5667 /**
5668 * An Intent[] describing additional, alternate choices you would like shown with
5669 * {@link #ACTION_CHOOSER}.
5670 *
5671 * <p>An app may be capable of providing several different payload types to complete a
5672 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
5673 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
5674 * several different supported sending mechanisms for sharing, such as the actual "image/*"
5675 * photo data or a hosted link where the photos can be viewed.</p>
5676 *
5677 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
5678 * first/primary/preferred intent in the set. Additional intents specified in
5679 * this extra are ordered; by default intents that appear earlier in the array will be
5680 * preferred over intents that appear later in the array as matches for the same
5681 * target component. To alter this preference, a calling app may also supply
5682 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
5683 */
5684 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
5685
5686 /**
5687 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
5688 * and omitted from a list of components presented to the user.
5689 *
5690 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
5691 * in this array if it otherwise would have shown them. Useful for omitting specific targets
5692 * from your own package or other apps from your organization if the idea of sending to those
5693 * targets would be redundant with other app functionality. Filtered components will not
5694 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
5695 */
5696 public static final String EXTRA_EXCLUDE_COMPONENTS
5697 = "android.intent.extra.EXCLUDE_COMPONENTS";
5698
5699 /**
5700 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
5701 * describing additional high-priority deep-link targets for the chooser to present to the user.
5702 *
5703 * <p>Targets provided in this way will be presented inline with all other targets provided
5704 * by services from other apps. They will be prioritized before other service targets, but
5705 * after those targets provided by sources that the user has manually pinned to the front.
5706 * You can provide up to two targets on this extra (the limit of two targets
5707 * starts in Android 10).</p>
5708 *
5709 * @see #ACTION_CHOOSER
5710 */
5711 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
5712
5713 /**
5714 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
5715 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
5716 *
5717 * <p>An app preparing an action for another app to complete may wish to allow the user to
5718 * disambiguate between several options for completing the action based on the chosen target
5719 * or otherwise refine the action before it is invoked.
5720 * </p>
5721 *
5722 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
5723 * <ul>
5724 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
5725 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
5726 * chosen target beyond the first</li>
5727 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
5728 * should fill in and send once the disambiguation is complete</li>
5729 * </ul>
5730 */
5731 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
5732 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
5733
5734 /**
5735 * A Parcelable[] of {@link ChooserAction} objects to provide the Android Sharesheet with
5736 * app-specific actions to be presented to the user when invoking {@link #ACTION_CHOOSER}.
5737 * @hide
5738 */
5739 public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS =
5740 "android.intent.extra.EXTRA_CHOOSER_CUSTOM_ACTIONS";
5741
5742 /**
5743 * Optional argument to be used with {@link #ACTION_CHOOSER}.
5744 * A {@link android.app.PendingIntent} to be sent when the user wants to do payload reselection
5745 * in the sharesheet.
5746 * A reselection action allows the user to return to the source app to change the content being
5747 * shared.
5748 * @hide
5749 */
5750 public static final String EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION =
5751 "android.intent.extra.EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION";
5752
5753 /**
5754 * An {@code ArrayList} of {@code String} annotations describing content for
5755 * {@link #ACTION_CHOOSER}.
5756 *
5757 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
5758 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
5759 *
5760 * <p>Annotations should describe the major components or topics of the content. It is up to
5761 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
5762 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
5763 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
5764 * character. Performance on customized annotations can suffer, if they are rarely used for
5765 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
5766 * following annotations when applicable.</p>
5767 * <ul>
5768 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
5769 * health & beauty, and office supplies.</li>
5770 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
5771 * happy, and sad.</li>
5772 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
5773 * face, finger, standing, and walking.</li>
5774 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
5775 * child, and baby.</li>
5776 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
5777 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
5778 * <li>"party" represents that the topic of the content is mainly about parties.</li>
5779 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
5780 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
5781 * flowers.</li>
5782 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
5783 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
5784 * sunglasses, jewelry, handbags and clothing.</li>
5785 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
5786 * paper, and silk.</li>
5787 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
5788 * cars, and boats.</li>
5789 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
5790 * posters.</li>
5791 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
5792 * and designs of houses.</li>
5793 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
5794 * Christmas and Thanksgiving.</li>
5795 * </ul>
5796 */
5797 public static final String EXTRA_CONTENT_ANNOTATIONS
5798 = "android.intent.extra.CONTENT_ANNOTATIONS";
5799
5800 /**
5801 * A {@link ResultReceiver} used to return data back to the sender.
5802 *
5803 * <p>Used to complete an app-specific
5804 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
5805 *
5806 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
5807 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
5808 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
5809 * when the user selects a target component from the chooser. It is up to the recipient
5810 * to send a result to this ResultReceiver to signal that disambiguation is complete
5811 * and that the chooser should invoke the user's choice.</p>
5812 *
5813 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
5814 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
5815 * to match and fill in the final Intent or ChooserTarget before starting it.
5816 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
5817 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
5818 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
5819 *
5820 * <p>The result code passed to the ResultReceiver should be
5821 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
5822 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
5823 * the chooser should finish without starting a target.</p>
5824 */
5825 public static final String EXTRA_RESULT_RECEIVER
5826 = "android.intent.extra.RESULT_RECEIVER";
5827
5828 /**
5829 * A CharSequence dialog title to provide to the user when used with a
5830 * {@link #ACTION_CHOOSER}.
5831 */
5832 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
5833
5834 /**
5835 * A Parcelable[] of {@link Intent} or
5836 * {@link android.content.pm.LabeledIntent} objects as set with
5837 * {@link #putExtra(String, Parcelable[])} to place
5838 * at the front of the list of choices, when shown to the user with an
5839 * {@link #ACTION_CHOOSER}. You can choose up to two additional activities
5840 * to show before the app suggestions (the limit of two additional activities starts in
5841 * Android 10).
5842 */
5843 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
5844
5845 /**
5846 * A {@link IntentSender} to start after instant app installation success.
5847 * @hide
5848 */
5849 @SystemApi
5850 public static final String EXTRA_INSTANT_APP_SUCCESS =
5851 "android.intent.extra.INSTANT_APP_SUCCESS";
5852
5853 /**
5854 * A {@link IntentSender} to start after instant app installation failure.
5855 * @hide
5856 */
5857 @SystemApi
5858 public static final String EXTRA_INSTANT_APP_FAILURE =
5859 "android.intent.extra.INSTANT_APP_FAILURE";
5860
5861 /**
5862 * The host name that triggered an instant app resolution.
5863 * @hide
5864 */
5865 @SystemApi
5866 public static final String EXTRA_INSTANT_APP_HOSTNAME =
5867 "android.intent.extra.INSTANT_APP_HOSTNAME";
5868
5869 /**
5870 * An opaque token to track instant app resolution.
5871 * @hide
5872 */
5873 @SystemApi
5874 public static final String EXTRA_INSTANT_APP_TOKEN =
5875 "android.intent.extra.INSTANT_APP_TOKEN";
5876
5877 /**
5878 * The action that triggered an instant application resolution.
5879 * @hide
5880 */
5881 @SystemApi
5882 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
5883
5884 /**
5885 * An array of {@link Bundle}s containing details about resolved instant apps..
5886 * @hide
5887 */
5888 @SystemApi
5889 public static final String EXTRA_INSTANT_APP_BUNDLES =
5890 "android.intent.extra.INSTANT_APP_BUNDLES";
5891
5892 /**
5893 * A {@link Bundle} of metadata that describes the instant application that needs to be
5894 * installed. This data is populated from the response to
5895 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
5896 * instant application resolver.
5897 * @hide
5898 */
5899 @SystemApi
5900 public static final String EXTRA_INSTANT_APP_EXTRAS =
5901 "android.intent.extra.INSTANT_APP_EXTRAS";
5902
5903 /**
5904 * A boolean value indicating that the instant app resolver was unable to state with certainty
5905 * that it did or did not have an app for the sanitized {@link Intent} defined at
5906 * {@link #EXTRA_INTENT}.
5907 * @hide
5908 */
5909 @SystemApi
5910 public static final String EXTRA_UNKNOWN_INSTANT_APP =
5911 "android.intent.extra.UNKNOWN_INSTANT_APP";
5912
5913 /**
5914 * The version code of the app to install components from.
5915 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
5916 * @hide
5917 */
5918 @Deprecated
5919 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5920
5921 /**
5922 * The version code of the app to install components from.
5923 * @hide
5924 */
5925 @SystemApi
5926 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5927
5928 /**
5929 * The app that triggered the instant app installation.
5930 * @hide
5931 */
5932 @SystemApi
5933 public static final String EXTRA_CALLING_PACKAGE
5934 = "android.intent.extra.CALLING_PACKAGE";
5935
5936 /**
5937 * Optional calling app provided bundle containing additional launch information the
5938 * installer may use.
5939 * @hide
5940 */
5941 @SystemApi
5942 public static final String EXTRA_VERIFICATION_BUNDLE
5943 = "android.intent.extra.VERIFICATION_BUNDLE";
5944
5945 /**
5946 * A Bundle forming a mapping of potential target package names to different extras Bundles
5947 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5948 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5949 * be currently installed on the device.
5950 *
5951 * <p>An application may choose to provide alternate extras for the case where a user
5952 * selects an activity from a predetermined set of target packages. If the activity
5953 * the user selects from the chooser belongs to a package with its package name as
5954 * a key in this bundle, the corresponding extras for that package will be merged with
5955 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5956 * extra has the same key as an extra already present in the intent it will overwrite
5957 * the extra from the intent.</p>
5958 *
5959 * <p><em>Examples:</em>
5960 * <ul>
5961 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
5962 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5963 * parameters for that target.</li>
5964 * <li>An application may offer additional metadata for known targets of a given intent
5965 * to pass along information only relevant to that target such as account or content
5966 * identifiers already known to that application.</li>
5967 * </ul></p>
5968 */
5969 public static final String EXTRA_REPLACEMENT_EXTRAS =
5970 "android.intent.extra.REPLACEMENT_EXTRAS";
5971
5972 /**
5973 * An {@link IntentSender} that will be notified if a user successfully chooses a target
5974 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5975 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5976 * {@link ComponentName} of the chosen component.
5977 *
5978 * <p>In some situations this callback may never come, for example if the user abandons
5979 * the chooser, switches to another task or any number of other reasons. Apps should not
5980 * be written assuming that this callback will always occur.</p>
5981 */
5982 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5983 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5984
5985 /**
5986 * The {@link ComponentName} chosen by the user to complete an action.
5987 *
5988 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5989 */
5990 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5991
5992 /**
5993 * A {@link android.view.KeyEvent} object containing the event that
5994 * triggered the creation of the Intent it is in.
5995 */
5996 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5997
5998 /**
5999 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
6000 * before shutting down.
6001 *
6002 * {@hide}
6003 */
6004 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
6005
6006 /**
6007 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
6008 * requested by the user.
6009 *
6010 * {@hide}
6011 */
6012 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
6013 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
6014
6015 /**
6016 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
6017 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
6018 * of restarting the application.
6019 */
6020 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
6021
6022 /**
6023 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6024 * intents to signal that the application was removed with the user-initiated action.
6025 */
6026 public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED";
6027
6028 /**
6029 * A String holding the phone number originally entered in
6030 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
6031 * number to call in a {@link android.content.Intent#ACTION_CALL}.
6032 */
6033 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
6034
6035 /**
6036 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
6037 * intents to supply the uid the package had been assigned. Also an optional
6038 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
6039 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
6040 * purpose.
6041 */
6042 public static final String EXTRA_UID = "android.intent.extra.UID";
6043
6044 /**
6045 * @hide String array of package names.
6046 */
6047 @SystemApi
6048 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
6049
6050 /**
6051 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6052 * intents to indicate whether this represents a full uninstall (removing
6053 * both the code and its data) or a partial uninstall (leaving its data,
6054 * implying that this is an update).
6055 */
6056 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
6057
6058 /**
6059 * @hide
6060 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6061 * intents to indicate that at this point the package has been removed for
6062 * all users on the device.
6063 */
6064 public static final String EXTRA_REMOVED_FOR_ALL_USERS
6065 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
6066
6067 /**
6068 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
6069 * intents to indicate that this is a replacement of the package, so this
6070 * broadcast will immediately be followed by an add broadcast for a
6071 * different version of the same package.
6072 */
6073 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
6074
6075 /**
6076 * Used as an int extra field in {@link android.app.AlarmManager} pending intents
6077 * to tell the application being invoked how many pending alarms are being
6078 * delivered with the intent. For one-shot alarms this will always be 1.
6079 * For recurring alarms, this might be greater than 1 if the device was
6080 * asleep or powered off at the time an earlier alarm would have been
6081 * delivered.
6082 *
6083 * <p>Note: You must supply a <b>mutable</b> {@link android.app.PendingIntent} to
6084 * {@code AlarmManager} while setting your alarms to be able to read this value on receiving
6085 * them. <em>Mutability of pending intents must be explicitly specified by apps targeting
6086 * {@link Build.VERSION_CODES#S} or higher</em>.
6087 *
6088 * @see android.app.PendingIntent#FLAG_MUTABLE
6089 *
6090 */
6091 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
6092
6093 /**
6094 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
6095 * intents to request the dock state. Possible values are
6096 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
6097 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
6098 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
6099 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
6100 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
6101 */
6102 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
6103
6104 /**
6105 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6106 * to represent that the phone is not in any dock.
6107 */
6108 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
6109
6110 /**
6111 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6112 * to represent that the phone is in a desk dock.
6113 */
6114 public static final int EXTRA_DOCK_STATE_DESK = 1;
6115
6116 /**
6117 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6118 * to represent that the phone is in a car dock.
6119 */
6120 public static final int EXTRA_DOCK_STATE_CAR = 2;
6121
6122 /**
6123 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6124 * to represent that the phone is in a analog (low end) dock.
6125 */
6126 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
6127
6128 /**
6129 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
6130 * to represent that the phone is in a digital (high end) dock.
6131 */
6132 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
6133
6134 /**
6135 * Boolean that can be supplied as meta-data with a dock activity, to
6136 * indicate that the dock should take over the home key when it is active.
6137 */
6138 public static final String METADATA_DOCK_HOME = "android.dock_home";
6139
6140 /**
6141 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
6142 * the bug report.
6143 */
6144 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
6145
6146 /**
6147 * Used in the extra field in the remote intent. It's a string token passed with the
6148 * remote intent.
6149 */
6150 public static final String EXTRA_REMOTE_INTENT_TOKEN =
6151 "android.intent.extra.remote_intent_token";
6152
6153 /**
6154 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
6155 * will contain only the first name in the list.
6156 */
6157 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
6158 "android.intent.extra.changed_component_name";
6159
6160 /**
6161 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
6162 * and contains a string array of all of the components that have changed. If
6163 * the state of the overall package has changed, then it will contain an entry
6164 * with the package name itself.
6165 */
6166 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
6167 "android.intent.extra.changed_component_name_list";
6168
6169 /**
6170 * This field is part of
6171 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
6172 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
6173 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
6174 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
6175 * and contains a string array of all of the components that have changed.
6176 */
6177 public static final String EXTRA_CHANGED_PACKAGE_LIST =
6178 "android.intent.extra.changed_package_list";
6179
6180 /**
6181 * This field is part of
6182 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
6183 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
6184 * and contains an integer array of uids of all of the components
6185 * that have changed.
6186 */
6187 public static final String EXTRA_CHANGED_UID_LIST =
6188 "android.intent.extra.changed_uid_list";
6189
6190 /**
6191 * An integer denoting a bitwise combination of restrictions set on distracting packages via
6192 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
6193 *
6194 * @hide
6195 * @see PackageManager.DistractionRestriction
6196 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
6197 */
6198 public static final String EXTRA_DISTRACTION_RESTRICTIONS =
6199 "android.intent.extra.distraction_restrictions";
6200
6201 /**
6202 * @hide
6203 * Magic extra system code can use when binding, to give a label for
6204 * who it is that has bound to a service. This is an integer giving
6205 * a framework string resource that can be displayed to the user.
6206 */
6207 public static final String EXTRA_CLIENT_LABEL =
6208 "android.intent.extra.client_label";
6209
6210 /**
6211 * @hide
6212 * Magic extra system code can use when binding, to give a PendingIntent object
6213 * that can be launched for the user to disable the system's use of this
6214 * service.
6215 */
6216 public static final String EXTRA_CLIENT_INTENT =
6217 "android.intent.extra.client_intent";
6218
6219 /**
6220 * Extra used to indicate that an intent should only return data that is on
6221 * the local device. This is a boolean extra; the default is false. If true,
6222 * an implementation should only allow the user to select data that is
6223 * already on the device, not requiring it be downloaded from a remote
6224 * service when opened.
6225 *
6226 * @see #ACTION_GET_CONTENT
6227 * @see #ACTION_OPEN_DOCUMENT
6228 * @see #ACTION_OPEN_DOCUMENT_TREE
6229 * @see #ACTION_CREATE_DOCUMENT
6230 */
6231 public static final String EXTRA_LOCAL_ONLY =
6232 "android.intent.extra.LOCAL_ONLY";
6233
6234 /**
6235 * Extra used to indicate that an intent can allow the user to select and
6236 * return multiple items. This is a boolean extra; the default is false. If
6237 * true, an implementation is allowed to present the user with a UI where
6238 * they can pick multiple items that are all returned to the caller. When
6239 * this happens, they should be returned as the {@link #getClipData()} part
6240 * of the result Intent.
6241 *
6242 * @see #ACTION_GET_CONTENT
6243 * @see #ACTION_OPEN_DOCUMENT
6244 */
6245 public static final String EXTRA_ALLOW_MULTIPLE =
6246 "android.intent.extra.ALLOW_MULTIPLE";
6247
6248 /**
6249 * The user ID integer carried with broadcast intents related to addition,
6250 * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED},
6251 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
6252 *
6253 * @hide
6254 */
6255 @SystemApi
6256 @SuppressLint("ActionValue")
6257 public static final String EXTRA_USER_HANDLE =
6258 "android.intent.extra.user_handle";
6259
6260 /**
6261 * The {@link UserHandle} carried with intents.
6262 */
6263 public static final String EXTRA_USER =
6264 "android.intent.extra.USER";
6265
6266 /**
6267 * Extra used in the response from a BroadcastReceiver that handles
6268 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
6269 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
6270 */
6271 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
6272
6273 /**
6274 * Extra sent in the intent to the BroadcastReceiver that handles
6275 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
6276 * the restrictions as key/value pairs.
6277 */
6278 public static final String EXTRA_RESTRICTIONS_BUNDLE =
6279 "android.intent.extra.restrictions_bundle";
6280
6281 /**
6282 * Extra used in the response from a BroadcastReceiver that handles
6283 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
6284 */
6285 public static final String EXTRA_RESTRICTIONS_INTENT =
6286 "android.intent.extra.restrictions_intent";
6287
6288 /**
6289 * Extra used to communicate a set of acceptable MIME types. The type of the
6290 * extra is {@code String[]}. Values may be a combination of concrete MIME
6291 * types (such as "image/png") and/or partial MIME types (such as
6292 * "audio/*").
6293 *
6294 * @see #ACTION_GET_CONTENT
6295 * @see #ACTION_OPEN_DOCUMENT
6296 */
6297 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
6298
6299 /**
6300 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
6301 * this shutdown is only for the user space of the system, not a complete shutdown.
6302 * When this is true, hardware devices can use this information to determine that
6303 * they shouldn't do a complete shutdown of their device since this is not a
6304 * complete shutdown down to the kernel, but only user space restarting.
6305 * The default if not supplied is false.
6306 */
6307 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
6308 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
6309
6310 /**
6311 * Optional extra specifying a time in milliseconds since the Epoch. The value must be
6312 * non-negative.
6313 * <p>
6314 * Type: long
6315 * </p>
6316 */
6317 public static final String EXTRA_TIME = "android.intent.extra.TIME";
6318
6319 /**
6320 * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device.
6321 *
6322 * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones.
6323 */
6324 @SuppressLint("ActionValue")
6325 public static final String EXTRA_TIMEZONE = "time-zone";
6326
6327 /**
6328 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
6329 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
6330 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
6331 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
6332 *
6333 * @hide for internal use only.
6334 */
6335 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
6336 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
6337 /** @hide */
6338 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
6339 /** @hide */
6340 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
6341 /** @hide */
6342 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
6343
6344 /**
6345 * Intent extra: the reason that the operation associated with this intent is being performed.
6346 *
6347 * <p>Type: String
6348 * @hide
6349 */
6350 @SystemApi
6351 public static final String EXTRA_REASON = "android.intent.extra.REASON";
6352
6353 /**
6354 * {@hide}
6355 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
6356 */
6357 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
6358
6359 /**
6360 * {@hide}
6361 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
6362 * reset for the device with eSIM. This extra will be sent together with
6363 * {@link #ACTION_FACTORY_RESET}
6364 */
6365 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
6366
6367 /**
6368 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
6369 * activation request.
6370 * TODO: Add information about the structure and response data used with the pending intent.
6371 * @hide
6372 */
6373 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
6374 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
6375
6376 /**
6377 * Optional index with semantics depending on the intent action.
6378 *
6379 * <p>The value must be an integer greater or equal to 0.
6380 * @see #ACTION_QUICK_VIEW
6381 */
6382 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
6383
6384 /**
6385 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
6386 * such as opening in other apps, sharing, opening, editing, printing, deleting,
6387 * casting, etc.
6388 *
6389 * <p>The value is boolean. By default false.
6390 * @see #ACTION_QUICK_VIEW
6391 * @removed
6392 */
6393 @Deprecated
6394 public static final String EXTRA_QUICK_VIEW_ADVANCED =
6395 "android.intent.extra.QUICK_VIEW_ADVANCED";
6396
6397 /**
6398 * An optional extra of {@code String[]} indicating which quick view features should be made
6399 * available to the user in the quick view UI while handing a
6400 * {@link Intent#ACTION_QUICK_VIEW} intent.
6401 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
6402 * Quick viewer can implement features not listed below.
6403 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
6404 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
6405 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
6406 * {@link QuickViewConstants#FEATURE_PRINT}.
6407 * <p>
6408 * Requirements:
6409 * <li>Quick viewer shouldn't show a feature if the feature is absent in
6410 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
6411 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
6412 * internal policies.
6413 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
6414 * requirement that the feature be shown. Quick viewer may, according to its own policies,
6415 * disable or hide features.
6416 *
6417 * @see #ACTION_QUICK_VIEW
6418 */
6419 public static final String EXTRA_QUICK_VIEW_FEATURES =
6420 "android.intent.extra.QUICK_VIEW_FEATURES";
6421
6422 /**
6423 * Optional boolean extra indicating whether quiet mode has been switched on or off.
6424 * When a profile goes into quiet mode, all apps in the profile are killed and the
6425 * profile user is stopped. Widgets originating from the profile are masked, and app
6426 * launcher icons are grayed out.
6427 */
6428 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
6429
6430 /**
6431 * Optional CharSequence extra to provide a search query.
6432 * The format of this query is dependent on the receiving application.
6433 *
6434 * <p>Applicable to {@link Intent} with actions:
6435 * <ul>
6436 * <li>{@link Intent#ACTION_GET_CONTENT}</li>
6437 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
6438 * </ul>
6439 */
6440 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
6441
6442 /**
6443 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
6444 * intents to specify the resource type granted. Possible values are
6445 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
6446 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
6447 *
6448 * @hide
6449 */
6450 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
6451 "android.intent.extra.MEDIA_RESOURCE_TYPE";
6452
6453 /**
6454 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
6455 * whether to show the chooser or not when there is only one application available
6456 * to choose from.
6457 */
6458 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
6459 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
6460
6461 /**
6462 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
6463 * to represent that a video codec is allowed to use.
6464 *
6465 * @hide
6466 */
6467 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
6468
6469 /**
6470 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
6471 * to represent that a audio codec is allowed to use.
6472 *
6473 * @hide
6474 */
6475 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
6476
6477 /**
6478 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
6479 *
6480 * <p>
6481 * Type: {@link LocusId}
6482 * </p>
6483 */
6484 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
6485
6486 /**
6487 * Used as an int array extra field in
6488 * {@link android.content.Intent#ACTION_PACKAGE_REMOVED_INTERNAL}
6489 * intents to indicate that visibility allow list of this removed package.
6490 *
6491 * @hide
6492 */
6493 public static final String EXTRA_VISIBILITY_ALLOW_LIST =
6494 "android.intent.extra.VISIBILITY_ALLOW_LIST";
6495
6496 // ---------------------------------------------------------------------
6497 // ---------------------------------------------------------------------
6498 // Intent flags (see mFlags variable).
6499
6500 /** @hide */
6501 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
6502 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
6503 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
6504 @Retention(RetentionPolicy.SOURCE)
6505 public @interface GrantUriMode {}
6506
6507 /** @hide */
6508 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
6509 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
6510 @Retention(RetentionPolicy.SOURCE)
6511 public @interface AccessUriMode {}
6512
6513 /**
6514 * Test if given mode flags specify an access mode, which must be at least
6515 * read and/or write.
6516 *
6517 * @hide
6518 */
6519 public static boolean isAccessUriMode(int modeFlags) {
6520 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
6521 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
6522 }
6523
6524 /** @hide */
6525 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
6526 FLAG_GRANT_READ_URI_PERMISSION,
6527 FLAG_GRANT_WRITE_URI_PERMISSION,
6528 FLAG_FROM_BACKGROUND,
6529 FLAG_DEBUG_LOG_RESOLUTION,
6530 FLAG_EXCLUDE_STOPPED_PACKAGES,
6531 FLAG_INCLUDE_STOPPED_PACKAGES,
6532 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
6533 FLAG_GRANT_PREFIX_URI_PERMISSION,
6534 FLAG_DEBUG_TRIAGED_MISSING,
6535 FLAG_IGNORE_EPHEMERAL,
6536 FLAG_ACTIVITY_MATCH_EXTERNAL,
6537 FLAG_ACTIVITY_NO_HISTORY,
6538 FLAG_ACTIVITY_SINGLE_TOP,
6539 FLAG_ACTIVITY_NEW_TASK,
6540 FLAG_ACTIVITY_MULTIPLE_TASK,
6541 FLAG_ACTIVITY_CLEAR_TOP,
6542 FLAG_ACTIVITY_FORWARD_RESULT,
6543 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6544 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6545 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6546 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6547 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6548 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6549 FLAG_ACTIVITY_NEW_DOCUMENT,
6550 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6551 FLAG_ACTIVITY_NO_USER_ACTION,
6552 FLAG_ACTIVITY_REORDER_TO_FRONT,
6553 FLAG_ACTIVITY_NO_ANIMATION,
6554 FLAG_ACTIVITY_CLEAR_TASK,
6555 FLAG_ACTIVITY_TASK_ON_HOME,
6556 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6557 FLAG_ACTIVITY_LAUNCH_ADJACENT,
6558 FLAG_ACTIVITY_REQUIRE_NON_BROWSER,
6559 FLAG_ACTIVITY_REQUIRE_DEFAULT,
6560 FLAG_RECEIVER_REGISTERED_ONLY,
6561 FLAG_RECEIVER_REPLACE_PENDING,
6562 FLAG_RECEIVER_FOREGROUND,
6563 FLAG_RECEIVER_NO_ABORT,
6564 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6565 FLAG_RECEIVER_BOOT_UPGRADE,
6566 FLAG_RECEIVER_INCLUDE_BACKGROUND,
6567 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6568 FLAG_RECEIVER_FROM_SHELL,
6569 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6570 FLAG_RECEIVER_OFFLOAD,
6571 FLAG_RECEIVER_OFFLOAD_FOREGROUND,
6572 })
6573 @Retention(RetentionPolicy.SOURCE)
6574 public @interface Flags {}
6575
6576 /** @hide */
6577 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
6578 FLAG_FROM_BACKGROUND,
6579 FLAG_DEBUG_LOG_RESOLUTION,
6580 FLAG_EXCLUDE_STOPPED_PACKAGES,
6581 FLAG_INCLUDE_STOPPED_PACKAGES,
6582 FLAG_DEBUG_TRIAGED_MISSING,
6583 FLAG_IGNORE_EPHEMERAL,
6584 FLAG_ACTIVITY_MATCH_EXTERNAL,
6585 FLAG_ACTIVITY_NO_HISTORY,
6586 FLAG_ACTIVITY_SINGLE_TOP,
6587 FLAG_ACTIVITY_NEW_TASK,
6588 FLAG_ACTIVITY_MULTIPLE_TASK,
6589 FLAG_ACTIVITY_CLEAR_TOP,
6590 FLAG_ACTIVITY_FORWARD_RESULT,
6591 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6592 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6593 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6594 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6595 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6596 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6597 FLAG_ACTIVITY_NEW_DOCUMENT,
6598 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6599 FLAG_ACTIVITY_NO_USER_ACTION,
6600 FLAG_ACTIVITY_REORDER_TO_FRONT,
6601 FLAG_ACTIVITY_NO_ANIMATION,
6602 FLAG_ACTIVITY_CLEAR_TASK,
6603 FLAG_ACTIVITY_TASK_ON_HOME,
6604 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6605 FLAG_ACTIVITY_LAUNCH_ADJACENT,
6606 FLAG_RECEIVER_REGISTERED_ONLY,
6607 FLAG_RECEIVER_REPLACE_PENDING,
6608 FLAG_RECEIVER_FOREGROUND,
6609 FLAG_RECEIVER_NO_ABORT,
6610 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6611 FLAG_RECEIVER_BOOT_UPGRADE,
6612 FLAG_RECEIVER_INCLUDE_BACKGROUND,
6613 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6614 FLAG_RECEIVER_FROM_SHELL,
6615 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6616 FLAG_RECEIVER_OFFLOAD,
6617 FLAG_RECEIVER_OFFLOAD_FOREGROUND,
6618 })
6619 @Retention(RetentionPolicy.SOURCE)
6620 public @interface MutableFlags {}
6621
6622 /**
6623 * If set, the recipient of this Intent will be granted permission to
6624 * perform read operations on the URI in the Intent's data and any URIs
6625 * specified in its ClipData. When applying to an Intent's ClipData,
6626 * all URIs as well as recursive traversals through data or other ClipData
6627 * in Intent items will be granted; only the grant flags of the top-level
6628 * Intent are used.
6629 */
6630 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
6631 /**
6632 * If set, the recipient of this Intent will be granted permission to
6633 * perform write operations on the URI in the Intent's data and any URIs
6634 * specified in its ClipData. When applying to an Intent's ClipData,
6635 * all URIs as well as recursive traversals through data or other ClipData
6636 * in Intent items will be granted; only the grant flags of the top-level
6637 * Intent are used.
6638 */
6639 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
6640 /**
6641 * Can be set by the caller to indicate that this Intent is coming from
6642 * a background operation, not from direct user interaction.
6643 */
6644 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
6645 /**
6646 * A flag you can enable for debugging: when set, log messages will be
6647 * printed during the resolution of this intent to show you what has
6648 * been found to create the final resolved list.
6649 */
6650 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
6651 /**
6652 * If set, this intent will not match any components in packages that
6653 * are currently stopped. If this is not set, then the default behavior
6654 * is to include such applications in the result.
6655 */
6656 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
6657 /**
6658 * If set, this intent will always match any components in packages that
6659 * are currently stopped. This is the default behavior when
6660 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
6661 * flags are set, this one wins (it allows overriding of exclude for
6662 * places where the framework may automatically set the exclude flag).
6663 */
6664 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
6665
6666 /**
6667 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6668 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
6669 * persisted across device reboots until explicitly revoked with
6670 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
6671 * grant for possible persisting; the receiving application must call
6672 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
6673 * actually persist.
6674 *
6675 * @see ContentResolver#takePersistableUriPermission(Uri, int)
6676 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
6677 * @see ContentResolver#getPersistedUriPermissions()
6678 * @see ContentResolver#getOutgoingPersistedUriPermissions()
6679 */
6680 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
6681
6682 /**
6683 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6684 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
6685 * applies to any URI that is a prefix match against the original granted
6686 * URI. (Without this flag, the URI must match exactly for access to be
6687 * granted.) Another URI is considered a prefix match only when scheme,
6688 * authority, and all path segments defined by the prefix are an exact
6689 * match.
6690 */
6691 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
6692
6693 /**
6694 * Flag used to automatically match intents based on their Direct Boot
6695 * awareness and the current user state.
6696 * <p>
6697 * Since the default behavior is to automatically apply the current user
6698 * state, this is effectively a sentinel value that doesn't change the
6699 * output of any queries based on its presence or absence.
6700 * <p>
6701 * Instead, this value can be useful in conjunction with
6702 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
6703 * to detect when a caller is relying on implicit automatic matching,
6704 * instead of confirming the explicit behavior they want.
6705 */
6706 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
6707
6708 /** {@hide} */
6709 @Deprecated
6710 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
6711
6712 /**
6713 * Internal flag used to indicate ephemeral applications should not be
6714 * considered when resolving the intent.
6715 *
6716 * @hide
6717 */
6718 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
6719
6720 /**
6721 * If set, the new activity is not kept in the history stack. As soon as
6722 * the user navigates away from it, the activity is finished. This may also
6723 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
6724 * noHistory} attribute.
6725 *
6726 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
6727 * is never invoked when the current activity starts a new activity which
6728 * sets a result and finishes.
6729 */
6730 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
6731 /**
6732 * If set, the activity will not be launched if it is already running
6733 * at the top of the history stack. See
6734 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes">
6735 * Tasks and Back Stack</a> for more information.
6736 */
6737 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
6738 /**
6739 * If set, this activity will become the start of a new task on this
6740 * history stack. A task (from the activity that started it to the
6741 * next task activity) defines an atomic group of activities that the
6742 * user can move to. Tasks can be moved to the foreground and background;
6743 * all of the activities inside of a particular task always remain in
6744 * the same order. See
6745 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6746 * Stack</a> for more information about tasks.
6747 *
6748 * <p>This flag is generally used by activities that want
6749 * to present a "launcher" style behavior: they give the user a list of
6750 * separate things that can be done, which otherwise run completely
6751 * independently of the activity launching them.
6752 *
6753 * <p>When using this flag, if a task is already running for the activity
6754 * you are now starting, then a new activity will not be started; instead,
6755 * the current task will simply be brought to the front of the screen with
6756 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
6757 * to disable this behavior.
6758 *
6759 * <p>This flag can not be used when the caller is requesting a result from
6760 * the activity being launched.
6761 */
6762 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
6763 /**
6764 * This flag is used to create a new task and launch an activity into it.
6765 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
6766 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
6767 * search through existing tasks for ones matching this Intent. Only if no such
6768 * task is found would a new task be created. When paired with
6769 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
6770 * the search for a matching task and unconditionally start a new task.
6771 *
6772 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
6773 * flag unless you are implementing your own
6774 * top-level application launcher.</strong> Used in conjunction with
6775 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
6776 * behavior of bringing an existing task to the foreground. When set,
6777 * a new task is <em>always</em> started to host the Activity for the
6778 * Intent, regardless of whether there is already an existing task running
6779 * the same thing.
6780 *
6781 * <p><strong>Because the default system does not include graphical task management,
6782 * you should not use this flag unless you provide some way for a user to
6783 * return back to the tasks you have launched.</strong>
6784 *
6785 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
6786 * creating new document tasks.
6787 *
6788 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
6789 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
6790 *
6791 * <p>See
6792 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6793 * Stack</a> for more information about tasks.
6794 *
6795 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
6796 * @see #FLAG_ACTIVITY_NEW_TASK
6797 */
6798 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
6799 /**
6800 * If set, and the activity being launched is already running in the
6801 * current task, then instead of launching a new instance of that activity,
6802 * all of the other activities on top of it will be closed and this Intent
6803 * will be delivered to the (now on top) old activity as a new Intent.
6804 *
6805 * <p>For example, consider a task consisting of the activities: A, B, C, D.
6806 * If D calls startActivity() with an Intent that resolves to the component
6807 * of activity B, then C and D will be finished and B receive the given
6808 * Intent, resulting in the stack now being: A, B.
6809 *
6810 * <p>The currently running instance of activity B in the above example will
6811 * either receive the new intent you are starting here in its
6812 * onNewIntent() method, or be itself finished and restarted with the
6813 * new intent. If it has declared its launch mode to be "multiple" (the
6814 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
6815 * the same intent, then it will be finished and re-created; for all other
6816 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
6817 * Intent will be delivered to the current instance's onNewIntent().
6818 *
6819 * <p>This launch mode can also be used to good effect in conjunction with
6820 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
6821 * of a task, it will bring any currently running instance of that task
6822 * to the foreground, and then clear it to its root state. This is
6823 * especially useful, for example, when launching an activity from the
6824 * notification manager.
6825 *
6826 * <p>See
6827 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6828 * Stack</a> for more information about tasks.
6829 */
6830 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
6831 /**
6832 * If set and this intent is being used to launch a new activity from an
6833 * existing one, then the reply target of the existing activity will be
6834 * transferred to the new activity. This way, the new activity can call
6835 * {@link android.app.Activity#setResult} and have that result sent back to
6836 * the reply target of the original activity.
6837 */
6838 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
6839 /**
6840 * If set and this intent is being used to launch a new activity from an
6841 * existing one, the current activity will not be counted as the top
6842 * activity for deciding whether the new intent should be delivered to
6843 * the top instead of starting a new one. The previous activity will
6844 * be used as the top, with the assumption being that the current activity
6845 * will finish itself immediately.
6846 */
6847 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
6848 /**
6849 * If set, the new activity is not kept in the list of recently launched
6850 * activities.
6851 */
6852 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
6853 /**
6854 * This flag is not normally set by application code, but set for you by
6855 * the system as described in the
6856 * {@link android.R.styleable#AndroidManifestActivity_launchMode
6857 * launchMode} documentation for the singleTask mode.
6858 */
6859 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
6860 /**
6861 * If set, and this activity is either being started in a new task or
6862 * bringing to the top an existing task, then it will be launched as
6863 * the front door of the task. This will result in the application of
6864 * any affinities needed to have that task in the proper state (either
6865 * moving activities to or from it), or simply resetting that task to
6866 * its initial state if needed.
6867 *
6868 * @see android.R.attr#allowTaskReparenting
6869 * @see android.R.attr#clearTaskOnLaunch
6870 * @see android.R.attr#finishOnTaskLaunch
6871 */
6872 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
6873 /**
6874 * This flag is not normally set by application code, but set for you by
6875 * the system if this activity is being launched from history.
6876 */
6877 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
6878 /**
6879 * @deprecated As of API 21 this performs identically to
6880 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
6881 */
6882 @Deprecated
6883 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
6884 /**
6885 * This flag is used to open a document into a new task rooted at the activity launched
6886 * by this Intent. Through the use of this flag, or its equivalent attribute,
6887 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
6888 * containing different documents will appear in the recent tasks list.
6889 *
6890 * <p>The use of the activity attribute form of this,
6891 * {@link android.R.attr#documentLaunchMode}, is
6892 * preferred over the Intent flag described here. The attribute form allows the
6893 * Activity to specify multiple document behavior for all launchers of the Activity
6894 * whereas using this flag requires each Intent that launches the Activity to specify it.
6895 *
6896 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
6897 * it is kept after the activity is finished is different than the use of
6898 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
6899 * this flag is being used to create a new recents entry, then by default that entry
6900 * will be removed once the activity is finished. You can modify this behavior with
6901 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
6902 *
6903 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
6904 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
6905 * equivalent of the Activity manifest specifying {@link
6906 * android.R.attr#documentLaunchMode}="intoExisting". When used with
6907 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
6908 * {@link android.R.attr#documentLaunchMode}="always". The flag is ignored even in
6909 * conjunction with {@link #FLAG_ACTIVITY_MULTIPLE_TASK} when the Activity manifest specifies
6910 * {@link android.R.attr#documentLaunchMode}="never".
6911 *
6912 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
6913 *
6914 * @see android.R.attr#documentLaunchMode
6915 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
6916 */
6917 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
6918 /**
6919 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
6920 * callback from occurring on the current frontmost activity before it is
6921 * paused as the newly-started activity is brought to the front.
6922 *
6923 * <p>Typically, an activity can rely on that callback to indicate that an
6924 * explicit user action has caused their activity to be moved out of the
6925 * foreground. The callback marks an appropriate point in the activity's
6926 * lifecycle for it to dismiss any notifications that it intends to display
6927 * "until the user has seen them," such as a blinking LED.
6928 *
6929 * <p>If an activity is ever started via any non-user-driven events such as
6930 * phone-call receipt or an alarm handler, this flag should be passed to {@link
6931 * Context#startActivity Context.startActivity}, ensuring that the pausing
6932 * activity does not think the user has acknowledged its notification.
6933 */
6934 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
6935 /**
6936 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6937 * this flag will cause the launched activity to be brought to the front of its
6938 * task's history stack if it is already running.
6939 *
6940 * <p>For example, consider a task consisting of four activities: A, B, C, D.
6941 * If D calls startActivity() with an Intent that resolves to the component
6942 * of activity B, then B will be brought to the front of the history stack,
6943 * with this resulting order: A, C, D, B.
6944 *
6945 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
6946 * specified.
6947 */
6948 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
6949 /**
6950 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6951 * this flag will prevent the system from applying an activity transition
6952 * animation to go to the next activity state. This doesn't mean an
6953 * animation will never run -- if another activity change happens that doesn't
6954 * specify this flag before the activity started here is displayed, then
6955 * that transition will be used. This flag can be put to good use
6956 * when you are going to do a series of activity operations but the
6957 * animation seen by the user shouldn't be driven by the first activity
6958 * change but rather a later one.
6959 */
6960 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
6961 /**
6962 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6963 * this flag will cause any existing task that would be associated with the
6964 * activity to be cleared before the activity is started. That is, the activity
6965 * becomes the new root of an otherwise empty task, and any old activities
6966 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6967 */
6968 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
6969 /**
6970 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6971 * this flag will cause a newly launching task to be placed on top of the current
6972 * home activity task (if there is one). That is, pressing back from the task
6973 * will always return the user to home even if that was not the last activity they
6974 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6975 */
6976 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6977 /**
6978 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6979 * have its entry in recent tasks removed when the user closes it (with back
6980 * or however else it may finish()). If you would like to instead allow the
6981 * document to be kept in recents so that it can be re-launched, you can use
6982 * this flag. When set and the task's activity is finished, the recents
6983 * entry will remain in the interface for the user to re-launch it, like a
6984 * recents entry for a top-level application.
6985 * <p>
6986 * The receiving activity can override this request with
6987 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6988 * {@link android.app.Activity#finishAndRemoveTask()
6989 * Activity.finishAndRemoveTask()}.
6990 */
6991 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
6992
6993 /**
6994 * This flag is only used for split-screen multi-window mode. The new activity will be displayed
6995 * adjacent to the one launching it. This can only be used in conjunction with
6996 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6997 * required if you want a new instance of an existing activity to be created.
6998 */
6999 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
7000
7001
7002 /**
7003 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
7004 * this flag will attempt to launch an instant app if no full app on the device can already
7005 * handle the intent.
7006 * <p>
7007 * When attempting to resolve instant apps externally, the following {@link Intent} properties
7008 * are supported:
7009 * <ul>
7010 * <li>{@link Intent#setAction(String)}</li>
7011 * <li>{@link Intent#addCategory(String)}</li>
7012 * <li>{@link Intent#setData(Uri)}</li>
7013 * <li>{@link Intent#setType(String)}</li>
7014 * <li>{@link Intent#setPackage(String)}</li>
7015 * <li>{@link Intent#addFlags(int)}</li>
7016 * </ul>
7017 * <p>
7018 * In the case that no instant app can be found, the installer will be launched to notify the
7019 * user that the intent could not be resolved. On devices that do not support instant apps,
7020 * the flag will be ignored.
7021 */
7022 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
7023
7024 /**
7025 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
7026 * flag will only launch the intent if it resolves to a result that is not a browser. If no such
7027 * result exists, an {@link ActivityNotFoundException} will be thrown.
7028 */
7029 public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400;
7030
7031 /**
7032 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
7033 * flag will only launch the intent if it resolves to a single result. If no such result exists
7034 * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException}
7035 * will be thrown.
7036 */
7037 public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200;
7038
7039 /**
7040 * If set, when sending a broadcast only registered receivers will be
7041 * called -- no BroadcastReceiver components will be launched.
7042 */
7043 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
7044 /**
7045 * If set, when sending a broadcast the new broadcast will replace
7046 * any existing pending broadcast that matches it. Matching is defined
7047 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
7048 * true for the intents of the two broadcasts. When a match is found,
7049 * the new broadcast (and receivers associated with it) will replace the
7050 * existing one in the pending broadcast list, remaining at the same
7051 * position in the list.
7052 *
7053 * <p>This flag is most typically used with sticky broadcasts, which
7054 * only care about delivering the most recent values of the broadcast
7055 * to their receivers.
7056 */
7057 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
7058 /**
7059 * If set, when sending a broadcast the recipient is allowed to run at
7060 * foreground priority, with a shorter timeout interval. During normal
7061 * broadcasts the receivers are not automatically hoisted out of the
7062 * background priority class.
7063 */
7064 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
7065 /**
7066 * If set, when sending a broadcast the recipient will be run on the offload queue.
7067 *
7068 * @hide
7069 */
7070 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
7071 /**
7072 * If set, when sending a broadcast the recipient will run on the system dedicated queue.
7073 *
7074 * @hide
7075 */
7076 public static final int FLAG_RECEIVER_OFFLOAD_FOREGROUND = 0x00000800;
7077
7078 /**
7079 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
7080 * They can still propagate results through to later receivers, but they can not prevent
7081 * later receivers from seeing the broadcast.
7082 */
7083 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
7084 /**
7085 * If set, when sending a broadcast <i>before the system has fully booted up
7086 * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only
7087 * registered receivers will be called -- no BroadcastReceiver components
7088 * will be launched. Sticky intent state will be recorded properly even
7089 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
7090 * is specified in the broadcast intent, this flag is unnecessary.
7091 *
7092 * <p>This flag is only for use by system services (even services from mainline modules) as a
7093 * convenience to avoid having to implement a more complex mechanism around detection
7094 * of boot completion.
7095 *
7096 * <p>This is useful to system server mainline modules
7097 *
7098 * @hide
7099 */
7100 @SystemApi
7101 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
7102 /**
7103 * Set when this broadcast is for a boot upgrade, a special mode that
7104 * allows the broadcast to be sent before the system is ready and launches
7105 * the app process with no providers running in it.
7106 * @hide
7107 */
7108 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
7109 /**
7110 * If set, the broadcast will always go to manifest receivers in background (cached
7111 * or not running) apps, regardless of whether that would be done by default. By
7112 * default they will only receive broadcasts if the broadcast has specified an
7113 * explicit component or package name.
7114 *
7115 * NOTE: dumpstate uses this flag numerically, so when its value is changed
7116 * the broadcast code there must also be changed to match.
7117 *
7118 * @hide
7119 */
7120 @SystemApi
7121 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
7122 /**
7123 * If set, the broadcast will never go to manifest receivers in background (cached
7124 * or not running) apps, regardless of whether that would be done by default. By
7125 * default they will receive broadcasts if the broadcast has specified an
7126 * explicit component or package name.
7127 * @hide
7128 */
7129 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
7130 /**
7131 * If set, this broadcast is being sent from the shell.
7132 * @hide
7133 */
7134 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
7135
7136 /**
7137 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
7138 * will not receive broadcasts.
7139 *
7140 * <em>This flag has no effect when used by an Instant App.</em>
7141 */
7142 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
7143
7144 /**
7145 * @hide Flags that can't be changed with PendingIntent.
7146 */
7147 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
7148 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7149 | FLAG_GRANT_PREFIX_URI_PERMISSION;
7150
7151 /**
7152 * Local flag indicating this instance was created by copy constructor.
7153 */
7154 private static final int LOCAL_FLAG_FROM_COPY = 1 << 0;
7155
7156 /**
7157 * Local flag indicating this instance was created from a {@link Parcel}.
7158 */
7159 private static final int LOCAL_FLAG_FROM_PARCEL = 1 << 1;
7160
7161 /**
7162 * Local flag indicating this instance was delivered through a protected
7163 * component, such as an activity that requires a signature permission, or a
7164 * protected broadcast. Note that this flag <em>cannot</em> be recursively
7165 * applied to any contained instances, since a malicious app may have
7166 * controlled them via {@link #fillIn(Intent, int)}.
7167 */
7168 private static final int LOCAL_FLAG_FROM_PROTECTED_COMPONENT = 1 << 2;
7169
7170 /**
7171 * Local flag indicating this instance had unfiltered extras copied into it. This could be
7172 * from either {@link #putExtras(Intent)} when an unparceled Intent is provided or {@link
7173 * #putExtras(Bundle)} when the provided Bundle has not been unparceled.
7174 */
7175 private static final int LOCAL_FLAG_UNFILTERED_EXTRAS = 1 << 3;
7176
7177 /**
7178 * Local flag indicating this instance was created from a {@link Uri}.
7179 */
7180 private static final int LOCAL_FLAG_FROM_URI = 1 << 4;
7181
7182 // ---------------------------------------------------------------------
7183 // ---------------------------------------------------------------------
7184 // toUri() and parseUri() options.
7185
7186 /** @hide */
7187 @IntDef(flag = true, prefix = { "URI_" }, value = {
7188 URI_ALLOW_UNSAFE,
7189 URI_ANDROID_APP_SCHEME,
7190 URI_INTENT_SCHEME,
7191 })
7192 @Retention(RetentionPolicy.SOURCE)
7193 public @interface UriFlags {}
7194
7195 /**
7196 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
7197 * always has the "intent:" scheme. This syntax can be used when you want
7198 * to later disambiguate between URIs that are intended to describe an
7199 * Intent vs. all others that should be treated as raw URIs. When used
7200 * with {@link #parseUri}, any other scheme will result in a generic
7201 * VIEW action for that raw URI.
7202 */
7203 public static final int URI_INTENT_SCHEME = 1<<0;
7204
7205 /**
7206 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
7207 * always has the "android-app:" scheme. This is a variation of
7208 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
7209 * http/https URI being delivered to a specific package name. The format
7210 * is:
7211 *
7212 * <pre class="prettyprint">
7213 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
7214 *
7215 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
7216 * you must also include a scheme; including a path also requires both a host and a scheme.
7217 * The final #Intent; fragment can be used without a scheme, host, or path.
7218 * Note that this can not be
7219 * used with intents that have a {@link #setSelector}, since the base intent
7220 * will always have an explicit package name.</p>
7221 *
7222 * <p>Some examples of how this scheme maps to Intent objects:</p>
7223 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
7224 * <colgroup align="left" />
7225 * <colgroup align="left" />
7226 * <thead>
7227 * <tr><th>URI</th> <th>Intent</th></tr>
7228 * </thead>
7229 *
7230 * <tbody>
7231 * <tr><td><code>android-app://com.example.app</code></td>
7232 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7233 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
7234 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7235 * </table></td>
7236 * </tr>
7237 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
7238 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7239 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
7240 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
7241 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7242 * </table></td>
7243 * </tr>
7244 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
7245 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7246 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
7247 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
7248 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7249 * </table></td>
7250 * </tr>
7251 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
7252 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7253 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
7254 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7255 * </table></td>
7256 * </tr>
7257 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
7258 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
7259 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
7260 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
7261 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7262 * </table></td>
7263 * </tr>
7264 * <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>
7265 * <td><table border="" style="margin:0" >
7266 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
7267 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
7268 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
7269 * </table></td>
7270 * </tr>
7271 * </tbody>
7272 * </table>
7273 */
7274 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
7275
7276 /**
7277 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
7278 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
7279 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
7280 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
7281 * generated Intent can not cause unexpected data access to happen.
7282 *
7283 * <p>If you do not trust the source of the URI being parsed, you should still do further
7284 * processing to protect yourself from it. In particular, when using it to start an
7285 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
7286 * that can handle it.</p>
7287 */
7288 public static final int URI_ALLOW_UNSAFE = 1<<2;
7289
7290 // ---------------------------------------------------------------------
7291
7292 private String mAction;
7293 private Uri mData;
7294 private String mType;
7295 private String mIdentifier;
7296 private String mPackage;
7297 private ComponentName mComponent;
7298 private int mFlags;
7299 /** Set of in-process flags which are never parceled */
7300 private int mLocalFlags;
7301 private ArraySet<String> mCategories;
7302 @UnsupportedAppUsage
7303 private Bundle mExtras;
7304 private Rect mSourceBounds;
7305 private Intent mSelector;
7306 private ClipData mClipData;
7307 private int mContentUserHint = UserHandle.USER_CURRENT;
7308 /** Token to track instant app launches. Local only; do not copy cross-process. */
7309 private String mLaunchToken;
7310 private Intent mOriginalIntent; // Used for the experimental "component alias" feature.
7311
7312 // ---------------------------------------------------------------------
7313
7314 private static final int COPY_MODE_ALL = 0;
7315 private static final int COPY_MODE_FILTER = 1;
7316 private static final int COPY_MODE_HISTORY = 2;
7317
7318 /** @hide */
7319 @IntDef(prefix = { "COPY_MODE_" }, value = {
7320 COPY_MODE_ALL,
7321 COPY_MODE_FILTER,
7322 COPY_MODE_HISTORY
7323 })
7324 @Retention(RetentionPolicy.SOURCE)
7325 public @interface CopyMode {}
7326
7327 /**
7328 * Create an empty intent.
7329 */
7330 public Intent() {
7331 }
7332
7333 /**
7334 * Copy constructor.
7335 */
7336 public Intent(Intent o) {
7337 this(o, COPY_MODE_ALL);
7338 }
7339
7340 private Intent(Intent o, @CopyMode int copyMode) {
7341 this.mAction = o.mAction;
7342 this.mData = o.mData;
7343 this.mType = o.mType;
7344 this.mIdentifier = o.mIdentifier;
7345 this.mPackage = o.mPackage;
7346 this.mComponent = o.mComponent;
7347 this.mOriginalIntent = o.mOriginalIntent;
7348
7349 if (o.mCategories != null) {
7350 this.mCategories = new ArraySet<>(o.mCategories);
7351 }
7352
7353 // Inherit flags from the original, plus mark that we were
7354 // created by this copy constructor
7355 this.mLocalFlags = o.mLocalFlags;
7356 this.mLocalFlags |= LOCAL_FLAG_FROM_COPY;
7357
7358 if (copyMode != COPY_MODE_FILTER) {
7359 this.mFlags = o.mFlags;
7360 this.mContentUserHint = o.mContentUserHint;
7361 this.mLaunchToken = o.mLaunchToken;
7362 if (o.mSourceBounds != null) {
7363 this.mSourceBounds = new Rect(o.mSourceBounds);
7364 }
7365 if (o.mSelector != null) {
7366 this.mSelector = new Intent(o.mSelector);
7367 }
7368
7369 if (copyMode != COPY_MODE_HISTORY) {
7370 if (o.mExtras != null) {
7371 this.mExtras = new Bundle(o.mExtras);
7372 }
7373 if (o.mClipData != null) {
7374 this.mClipData = new ClipData(o.mClipData);
7375 }
7376 } else {
7377 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) {
7378 this.mExtras = Bundle.STRIPPED;
7379 }
7380
7381 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
7382 // history.
7383 }
7384 }
7385 }
7386
7387 @Override
7388 public Object clone() {
7389 return new Intent(this);
7390 }
7391
7392 /**
7393 * Make a clone of only the parts of the Intent that are relevant for
7394 * filter matching: the action, data, type, component, and categories.
7395 */
7396 public @NonNull Intent cloneFilter() {
7397 return new Intent(this, COPY_MODE_FILTER);
7398 }
7399
7400 /**
7401 * Create an intent with a given action. All other fields (data, type,
7402 * class) are null. Note that the action <em>must</em> be in a
7403 * namespace because Intents are used globally in the system -- for
7404 * example the system VIEW action is android.intent.action.VIEW; an
7405 * application's custom action would be something like
7406 * com.google.app.myapp.CUSTOM_ACTION.
7407 *
7408 * @param action The Intent action, such as ACTION_VIEW.
7409 */
7410 public Intent(String action) {
7411 setAction(action);
7412 }
7413
7414 /**
7415 * Create an intent with a given action and for a given data url. Note
7416 * that the action <em>must</em> be in a namespace because Intents are
7417 * used globally in the system -- for example the system VIEW action is
7418 * android.intent.action.VIEW; an application's custom action would be
7419 * something like com.google.app.myapp.CUSTOM_ACTION.
7420 *
7421 * <p><em>Note: scheme and host name matching in the Android framework is
7422 * case-sensitive, unlike the formal RFC. As a result,
7423 * you should always ensure that you write your Uri with these elements
7424 * using lower case letters, and normalize any Uris you receive from
7425 * outside of Android to ensure the scheme and host is lower case.</em></p>
7426 *
7427 * @param action The Intent action, such as ACTION_VIEW.
7428 * @param uri The Intent data URI.
7429 */
7430 public Intent(String action, Uri uri) {
7431 setAction(action);
7432 mData = uri;
7433 }
7434
7435 /**
7436 * Create an intent for a specific component. All other fields (action, data,
7437 * type, class) are null, though they can be modified later with explicit
7438 * calls. This provides a convenient way to create an intent that is
7439 * intended to execute a hard-coded class name, rather than relying on the
7440 * system to find an appropriate class for you; see {@link #setComponent}
7441 * for more information on the repercussions of this.
7442 *
7443 * @param packageContext A Context of the application package implementing
7444 * this class.
7445 * @param cls The component class that is to be used for the intent.
7446 *
7447 * @see #setClass
7448 * @see #setComponent
7449 * @see #Intent(String, android.net.Uri , Context, Class)
7450 */
7451 public Intent(Context packageContext, Class<?> cls) {
7452 mComponent = new ComponentName(packageContext, cls);
7453 }
7454
7455 /**
7456 * Create an intent for a specific component with a specified action and data.
7457 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
7458 * construct the Intent and then calling {@link #setClass} to set its
7459 * class.
7460 *
7461 * <p><em>Note: scheme and host name matching in the Android framework is
7462 * case-sensitive, unlike the formal RFC. As a result,
7463 * you should always ensure that you write your Uri with these elements
7464 * using lower case letters, and normalize any Uris you receive from
7465 * outside of Android to ensure the scheme and host is lower case.</em></p>
7466 *
7467 * @param action The Intent action, such as ACTION_VIEW.
7468 * @param uri The Intent data URI.
7469 * @param packageContext A Context of the application package implementing
7470 * this class.
7471 * @param cls The component class that is to be used for the intent.
7472 *
7473 * @see #Intent(String, android.net.Uri)
7474 * @see #Intent(Context, Class)
7475 * @see #setClass
7476 * @see #setComponent
7477 */
7478 public Intent(String action, Uri uri,
7479 Context packageContext, Class<?> cls) {
7480 setAction(action);
7481 mData = uri;
7482 mComponent = new ComponentName(packageContext, cls);
7483 }
7484
7485 /**
7486 * Create an intent to launch the main (root) activity of a task. This
7487 * is the Intent that is started when the application's is launched from
7488 * Home. For anything else that wants to launch an application in the
7489 * same way, it is important that they use an Intent structured the same
7490 * way, and can use this function to ensure this is the case.
7491 *
7492 * <p>The returned Intent has the given Activity component as its explicit
7493 * component, {@link #ACTION_MAIN} as its action, and includes the
7494 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
7495 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
7496 * to do that through {@link #addFlags(int)} on the returned Intent.
7497 *
7498 * @param mainActivity The main activity component that this Intent will
7499 * launch.
7500 * @return Returns a newly created Intent that can be used to launch the
7501 * activity as a main application entry.
7502 *
7503 * @see #setClass
7504 * @see #setComponent
7505 */
7506 public static Intent makeMainActivity(ComponentName mainActivity) {
7507 Intent intent = new Intent(ACTION_MAIN);
7508 intent.setComponent(mainActivity);
7509 intent.addCategory(CATEGORY_LAUNCHER);
7510 return intent;
7511 }
7512
7513 /**
7514 * Make an Intent for the main activity of an application, without
7515 * specifying a specific activity to run but giving a selector to find
7516 * the activity. This results in a final Intent that is structured
7517 * the same as when the application is launched from
7518 * Home. For anything else that wants to launch an application in the
7519 * same way, it is important that they use an Intent structured the same
7520 * way, and can use this function to ensure this is the case.
7521 *
7522 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
7523 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
7524 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
7525 * to do that through {@link #addFlags(int)} on the returned Intent.
7526 *
7527 * @param selectorAction The action name of the Intent's selector.
7528 * @param selectorCategory The name of a category to add to the Intent's
7529 * selector.
7530 * @return Returns a newly created Intent that can be used to launch the
7531 * activity as a main application entry.
7532 *
7533 * @see #setSelector(Intent)
7534 */
7535 public static Intent makeMainSelectorActivity(String selectorAction,
7536 String selectorCategory) {
7537 Intent intent = new Intent(ACTION_MAIN);
7538 intent.addCategory(CATEGORY_LAUNCHER);
7539 Intent selector = new Intent();
7540 selector.setAction(selectorAction);
7541 selector.addCategory(selectorCategory);
7542 intent.setSelector(selector);
7543 return intent;
7544 }
7545
7546 /**
7547 * Make an Intent that can be used to re-launch an application's task
7548 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
7549 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
7550 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
7551 *
7552 * @param mainActivity The activity component that is the root of the
7553 * task; this is the activity that has been published in the application's
7554 * manifest as the main launcher icon.
7555 *
7556 * @return Returns a newly created Intent that can be used to relaunch the
7557 * activity's task in its root state.
7558 */
7559 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
7560 Intent intent = makeMainActivity(mainActivity);
7561 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
7562 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
7563 return intent;
7564 }
7565
7566 /**
7567 * Call {@link #parseUri} with 0 flags.
7568 * @deprecated Use {@link #parseUri} instead.
7569 */
7570 @Deprecated
7571 public static Intent getIntent(String uri) throws URISyntaxException {
7572 return parseUri(uri, 0);
7573 }
7574
7575 /**
7576 * Create an intent from a URI. This URI may encode the action,
7577 * category, and other intent fields, if it was returned by
7578 * {@link #toUri}. If the Intent was not generate by toUri(), its data
7579 * will be the entire URI and its action will be ACTION_VIEW.
7580 *
7581 * <p>The URI given here must not be relative -- that is, it must include
7582 * the scheme and full path.
7583 *
7584 * @param uri The URI to turn into an Intent.
7585 * @param flags Additional processing flags.
7586 *
7587 * @return Intent The newly created Intent object.
7588 *
7589 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
7590 * it bad (as parsed by the Uri class) or the Intent data within the
7591 * URI is invalid.
7592 *
7593 * @see #toUri
7594 */
7595 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
7596 Intent intent = parseUriInternal(uri, flags);
7597 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI;
7598 return intent;
7599 }
7600
7601 /**
7602 * @see #parseUri(String, int)
7603 */
7604 private static Intent parseUriInternal(String uri, @UriFlags int flags)
7605 throws URISyntaxException {
7606 int i = 0;
7607 try {
7608 final boolean androidApp = uri.startsWith("android-app:");
7609
7610 // Validate intent scheme if requested.
7611 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
7612 if (!uri.startsWith("intent:") && !androidApp) {
7613 Intent intent = new Intent(ACTION_VIEW);
7614 try {
7615 intent.setData(Uri.parse(uri));
7616 } catch (IllegalArgumentException e) {
7617 throw new URISyntaxException(uri, e.getMessage());
7618 }
7619 return intent;
7620 }
7621 }
7622
7623 i = uri.lastIndexOf("#");
7624 // simple case
7625 if (i == -1) {
7626 if (!androidApp) {
7627 return new Intent(ACTION_VIEW, Uri.parse(uri));
7628 }
7629
7630 // old format Intent URI
7631 } else if (!uri.startsWith("#Intent;", i)) {
7632 if (!androidApp) {
7633 return getIntentOld(uri, flags);
7634 } else {
7635 i = -1;
7636 }
7637 }
7638
7639 // new format
7640 Intent intent = new Intent(ACTION_VIEW);
7641 Intent baseIntent = intent;
7642 boolean explicitAction = false;
7643 boolean inSelector = false;
7644
7645 // fetch data part, if present
7646 String scheme = null;
7647 String data;
7648 if (i >= 0) {
7649 data = uri.substring(0, i);
7650 i += 8; // length of "#Intent;"
7651 } else {
7652 data = uri;
7653 }
7654
7655 // loop over contents of Intent, all name=value;
7656 while (i >= 0 && !uri.startsWith("end", i)) {
7657 int eq = uri.indexOf('=', i);
7658 if (eq < 0) eq = i-1;
7659 int semi = uri.indexOf(';', i);
7660 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
7661
7662 // action
7663 if (uri.startsWith("action=", i)) {
7664 intent.setAction(value);
7665 if (!inSelector) {
7666 explicitAction = true;
7667 }
7668 }
7669
7670 // categories
7671 else if (uri.startsWith("category=", i)) {
7672 intent.addCategory(value);
7673 }
7674
7675 // type
7676 else if (uri.startsWith("type=", i)) {
7677 intent.mType = value;
7678 }
7679
7680 // identifier
7681 else if (uri.startsWith("identifier=", i)) {
7682 intent.mIdentifier = value;
7683 }
7684
7685 // launch flags
7686 else if (uri.startsWith("launchFlags=", i)) {
7687 intent.mFlags = Integer.decode(value).intValue();
7688 if ((flags& URI_ALLOW_UNSAFE) == 0) {
7689 intent.mFlags &= ~IMMUTABLE_FLAGS;
7690 }
7691 }
7692
7693 // package
7694 else if (uri.startsWith("package=", i)) {
7695 intent.mPackage = value;
7696 }
7697
7698 // component
7699 else if (uri.startsWith("component=", i)) {
7700 intent.mComponent = ComponentName.unflattenFromString(value);
7701 }
7702
7703 // scheme
7704 else if (uri.startsWith("scheme=", i)) {
7705 if (inSelector) {
7706 intent.mData = Uri.parse(value + ":");
7707 } else {
7708 scheme = value;
7709 }
7710 }
7711
7712 // source bounds
7713 else if (uri.startsWith("sourceBounds=", i)) {
7714 intent.mSourceBounds = Rect.unflattenFromString(value);
7715 }
7716
7717 // selector
7718 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
7719 intent = new Intent();
7720 inSelector = true;
7721 }
7722
7723 // extra
7724 else {
7725 String key = Uri.decode(uri.substring(i + 2, eq));
7726 // create Bundle if it doesn't already exist
7727 if (intent.mExtras == null) intent.mExtras = new Bundle();
7728 Bundle b = intent.mExtras;
7729 // add EXTRA
7730 if (uri.startsWith("S.", i)) b.putString(key, value);
7731 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
7732 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
7733 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
7734 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
7735 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
7736 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
7737 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
7738 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
7739 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
7740 }
7741
7742 // move to the next item
7743 i = semi + 1;
7744 }
7745
7746 if (inSelector) {
7747 // The Intent had a selector; fix it up.
7748 if (baseIntent.mPackage == null) {
7749 baseIntent.setSelector(intent);
7750 }
7751 intent = baseIntent;
7752 }
7753
7754 if (data != null) {
7755 if (data.startsWith("intent:")) {
7756 data = data.substring(7);
7757 if (scheme != null) {
7758 data = scheme + ':' + data;
7759 }
7760 } else if (data.startsWith("android-app:")) {
7761 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
7762 // Correctly formed android-app, first part is package name.
7763 int end = data.indexOf('/', 14);
7764 if (end < 0) {
7765 // All we have is a package name.
7766 intent.mPackage = data.substring(14);
7767 if (!explicitAction) {
7768 intent.setAction(ACTION_MAIN);
7769 }
7770 data = "";
7771 } else {
7772 // Target the Intent at the given package name always.
7773 String authority = null;
7774 intent.mPackage = data.substring(14, end);
7775 int newEnd;
7776 if ((end+1) < data.length()) {
7777 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
7778 // Found a scheme, remember it.
7779 scheme = data.substring(end+1, newEnd);
7780 end = newEnd;
7781 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
7782 // Found a authority, remember it.
7783 authority = data.substring(end+1, newEnd);
7784 end = newEnd;
7785 }
7786 } else {
7787 // All we have is a scheme.
7788 scheme = data.substring(end+1);
7789 }
7790 }
7791 if (scheme == null) {
7792 // If there was no scheme, then this just targets the package.
7793 if (!explicitAction) {
7794 intent.setAction(ACTION_MAIN);
7795 }
7796 data = "";
7797 } else if (authority == null) {
7798 data = scheme + ":";
7799 } else {
7800 data = scheme + "://" + authority + data.substring(end);
7801 }
7802 }
7803 } else {
7804 data = "";
7805 }
7806 }
7807
7808 if (data.length() > 0) {
7809 try {
7810 intent.mData = Uri.parse(data);
7811 } catch (IllegalArgumentException e) {
7812 throw new URISyntaxException(uri, e.getMessage());
7813 }
7814 }
7815 }
7816
7817 return intent;
7818
7819 } catch (IndexOutOfBoundsException e) {
7820 throw new URISyntaxException(uri, "illegal Intent URI format", i);
7821 }
7822 }
7823
7824 public static Intent getIntentOld(String uri) throws URISyntaxException {
7825 Intent intent = getIntentOld(uri, 0);
7826 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI;
7827 return intent;
7828 }
7829
7830 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
7831 Intent intent;
7832
7833 int i = uri.lastIndexOf('#');
7834 if (i >= 0) {
7835 String action = null;
7836 final int intentFragmentStart = i;
7837 boolean isIntentFragment = false;
7838
7839 i++;
7840
7841 if (uri.regionMatches(i, "action(", 0, 7)) {
7842 isIntentFragment = true;
7843 i += 7;
7844 int j = uri.indexOf(')', i);
7845 action = uri.substring(i, j);
7846 i = j + 1;
7847 }
7848
7849 intent = new Intent(action);
7850
7851 if (uri.regionMatches(i, "categories(", 0, 11)) {
7852 isIntentFragment = true;
7853 i += 11;
7854 int j = uri.indexOf(')', i);
7855 while (i < j) {
7856 int sep = uri.indexOf('!', i);
7857 if (sep < 0 || sep > j) sep = j;
7858 if (i < sep) {
7859 intent.addCategory(uri.substring(i, sep));
7860 }
7861 i = sep + 1;
7862 }
7863 i = j + 1;
7864 }
7865
7866 if (uri.regionMatches(i, "type(", 0, 5)) {
7867 isIntentFragment = true;
7868 i += 5;
7869 int j = uri.indexOf(')', i);
7870 intent.mType = uri.substring(i, j);
7871 i = j + 1;
7872 }
7873
7874 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
7875 isIntentFragment = true;
7876 i += 12;
7877 int j = uri.indexOf(')', i);
7878 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
7879 if ((flags& URI_ALLOW_UNSAFE) == 0) {
7880 intent.mFlags &= ~IMMUTABLE_FLAGS;
7881 }
7882 i = j + 1;
7883 }
7884
7885 if (uri.regionMatches(i, "component(", 0, 10)) {
7886 isIntentFragment = true;
7887 i += 10;
7888 int j = uri.indexOf(')', i);
7889 int sep = uri.indexOf('!', i);
7890 if (sep >= 0 && sep < j) {
7891 String pkg = uri.substring(i, sep);
7892 String cls = uri.substring(sep + 1, j);
7893 intent.mComponent = new ComponentName(pkg, cls);
7894 }
7895 i = j + 1;
7896 }
7897
7898 if (uri.regionMatches(i, "extras(", 0, 7)) {
7899 isIntentFragment = true;
7900 i += 7;
7901
7902 final int closeParen = uri.indexOf(')', i);
7903 if (closeParen == -1) throw new URISyntaxException(uri,
7904 "EXTRA missing trailing ')'", i);
7905
7906 while (i < closeParen) {
7907 // fetch the key value
7908 int j = uri.indexOf('=', i);
7909 if (j <= i + 1 || i >= closeParen) {
7910 throw new URISyntaxException(uri, "EXTRA missing '='", i);
7911 }
7912 char type = uri.charAt(i);
7913 i++;
7914 String key = uri.substring(i, j);
7915 i = j + 1;
7916
7917 // get type-value
7918 j = uri.indexOf('!', i);
7919 if (j == -1 || j >= closeParen) j = closeParen;
7920 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7921 String value = uri.substring(i, j);
7922 i = j;
7923
7924 // create Bundle if it doesn't already exist
7925 if (intent.mExtras == null) intent.mExtras = new Bundle();
7926
7927 // add item to bundle
7928 try {
7929 switch (type) {
7930 case 'S':
7931 intent.mExtras.putString(key, Uri.decode(value));
7932 break;
7933 case 'B':
7934 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
7935 break;
7936 case 'b':
7937 intent.mExtras.putByte(key, Byte.parseByte(value));
7938 break;
7939 case 'c':
7940 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
7941 break;
7942 case 'd':
7943 intent.mExtras.putDouble(key, Double.parseDouble(value));
7944 break;
7945 case 'f':
7946 intent.mExtras.putFloat(key, Float.parseFloat(value));
7947 break;
7948 case 'i':
7949 intent.mExtras.putInt(key, Integer.parseInt(value));
7950 break;
7951 case 'l':
7952 intent.mExtras.putLong(key, Long.parseLong(value));
7953 break;
7954 case 's':
7955 intent.mExtras.putShort(key, Short.parseShort(value));
7956 break;
7957 default:
7958 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
7959 }
7960 } catch (NumberFormatException e) {
7961 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
7962 }
7963
7964 char ch = uri.charAt(i);
7965 if (ch == ')') break;
7966 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7967 i++;
7968 }
7969 }
7970
7971 if (isIntentFragment) {
7972 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
7973 } else {
7974 intent.mData = Uri.parse(uri);
7975 }
7976
7977 if (intent.mAction == null) {
7978 // By default, if no action is specified, then use VIEW.
7979 intent.mAction = ACTION_VIEW;
7980 }
7981
7982 } else {
7983 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
7984 }
7985
7986 return intent;
7987 }
7988
7989 /** @hide */
7990 public interface CommandOptionHandler {
7991 boolean handleOption(String opt, ShellCommand cmd);
7992 }
7993
7994 /** @hide */
7995 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
7996 @SuppressWarnings("AndroidFrameworkEfficientCollections")
7997 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
7998 throws URISyntaxException {
7999 Intent intent = new Intent();
8000 Intent baseIntent = intent;
8001 boolean hasIntentInfo = false;
8002
8003 Uri data = null;
8004 String type = null;
8005
8006 String opt;
8007 while ((opt=cmd.getNextOption()) != null) {
8008 switch (opt) {
8009 case "-a":
8010 intent.setAction(cmd.getNextArgRequired());
8011 if (intent == baseIntent) {
8012 hasIntentInfo = true;
8013 }
8014 break;
8015 case "-d":
8016 data = Uri.parse(cmd.getNextArgRequired());
8017 if (intent == baseIntent) {
8018 hasIntentInfo = true;
8019 }
8020 break;
8021 case "-t":
8022 type = cmd.getNextArgRequired();
8023 if (intent == baseIntent) {
8024 hasIntentInfo = true;
8025 }
8026 break;
8027 case "-i":
8028 intent.setIdentifier(cmd.getNextArgRequired());
8029 if (intent == baseIntent) {
8030 hasIntentInfo = true;
8031 }
8032 break;
8033 case "-c":
8034 intent.addCategory(cmd.getNextArgRequired());
8035 if (intent == baseIntent) {
8036 hasIntentInfo = true;
8037 }
8038 break;
8039 case "-e":
8040 case "--es": {
8041 String key = cmd.getNextArgRequired();
8042 String value = cmd.getNextArgRequired();
8043 intent.putExtra(key, value);
8044 }
8045 break;
8046 case "--esn": {
8047 String key = cmd.getNextArgRequired();
8048 intent.putExtra(key, (String) null);
8049 }
8050 break;
8051 case "--ei": {
8052 String key = cmd.getNextArgRequired();
8053 String value = cmd.getNextArgRequired();
8054 intent.putExtra(key, Integer.decode(value));
8055 }
8056 break;
8057 case "--eu": {
8058 String key = cmd.getNextArgRequired();
8059 String value = cmd.getNextArgRequired();
8060 intent.putExtra(key, Uri.parse(value));
8061 }
8062 break;
8063 case "--ecn": {
8064 String key = cmd.getNextArgRequired();
8065 String value = cmd.getNextArgRequired();
8066 ComponentName cn = ComponentName.unflattenFromString(value);
8067 if (cn == null)
8068 throw new IllegalArgumentException("Bad component name: " + value);
8069 intent.putExtra(key, cn);
8070 }
8071 break;
8072 case "--eia": {
8073 String key = cmd.getNextArgRequired();
8074 String value = cmd.getNextArgRequired();
8075 String[] strings = value.split(",");
8076 int[] list = new int[strings.length];
8077 for (int i = 0; i < strings.length; i++) {
8078 list[i] = Integer.decode(strings[i]);
8079 }
8080 intent.putExtra(key, list);
8081 }
8082 break;
8083 case "--eial": {
8084 String key = cmd.getNextArgRequired();
8085 String value = cmd.getNextArgRequired();
8086 String[] strings = value.split(",");
8087 ArrayList<Integer> list = new ArrayList<>(strings.length);
8088 for (int i = 0; i < strings.length; i++) {
8089 list.add(Integer.decode(strings[i]));
8090 }
8091 intent.putExtra(key, list);
8092 }
8093 break;
8094 case "--el": {
8095 String key = cmd.getNextArgRequired();
8096 String value = cmd.getNextArgRequired();
8097 intent.putExtra(key, Long.valueOf(value));
8098 }
8099 break;
8100 case "--ela": {
8101 String key = cmd.getNextArgRequired();
8102 String value = cmd.getNextArgRequired();
8103 String[] strings = value.split(",");
8104 long[] list = new long[strings.length];
8105 for (int i = 0; i < strings.length; i++) {
8106 list[i] = Long.valueOf(strings[i]);
8107 }
8108 intent.putExtra(key, list);
8109 hasIntentInfo = true;
8110 }
8111 break;
8112 case "--elal": {
8113 String key = cmd.getNextArgRequired();
8114 String value = cmd.getNextArgRequired();
8115 String[] strings = value.split(",");
8116 ArrayList<Long> list = new ArrayList<>(strings.length);
8117 for (int i = 0; i < strings.length; i++) {
8118 list.add(Long.valueOf(strings[i]));
8119 }
8120 intent.putExtra(key, list);
8121 hasIntentInfo = true;
8122 }
8123 break;
8124 case "--ef": {
8125 String key = cmd.getNextArgRequired();
8126 String value = cmd.getNextArgRequired();
8127 intent.putExtra(key, Float.valueOf(value));
8128 hasIntentInfo = true;
8129 }
8130 break;
8131 case "--efa": {
8132 String key = cmd.getNextArgRequired();
8133 String value = cmd.getNextArgRequired();
8134 String[] strings = value.split(",");
8135 float[] list = new float[strings.length];
8136 for (int i = 0; i < strings.length; i++) {
8137 list[i] = Float.valueOf(strings[i]);
8138 }
8139 intent.putExtra(key, list);
8140 hasIntentInfo = true;
8141 }
8142 break;
8143 case "--efal": {
8144 String key = cmd.getNextArgRequired();
8145 String value = cmd.getNextArgRequired();
8146 String[] strings = value.split(",");
8147 ArrayList<Float> list = new ArrayList<>(strings.length);
8148 for (int i = 0; i < strings.length; i++) {
8149 list.add(Float.valueOf(strings[i]));
8150 }
8151 intent.putExtra(key, list);
8152 hasIntentInfo = true;
8153 }
8154 break;
8155 case "--ed": {
8156 String key = cmd.getNextArgRequired();
8157 String value = cmd.getNextArgRequired();
8158 intent.putExtra(key, Double.valueOf(value));
8159 hasIntentInfo = true;
8160 }
8161 break;
8162 case "--eda": {
8163 String key = cmd.getNextArgRequired();
8164 String value = cmd.getNextArgRequired();
8165 String[] strings = value.split(",");
8166 double[] list = new double[strings.length];
8167 for (int i = 0; i < strings.length; i++) {
8168 list[i] = Double.valueOf(strings[i]);
8169 }
8170 intent.putExtra(key, list);
8171 hasIntentInfo = true;
8172 }
8173 break;
8174 case "--edal": {
8175 String key = cmd.getNextArgRequired();
8176 String value = cmd.getNextArgRequired();
8177 String[] strings = value.split(",");
8178 ArrayList<Double> list = new ArrayList<>(strings.length);
8179 for (int i = 0; i < strings.length; i++) {
8180 list.add(Double.valueOf(strings[i]));
8181 }
8182 intent.putExtra(key, list);
8183 hasIntentInfo = true;
8184 }
8185 break;
8186 case "--esa": {
8187 String key = cmd.getNextArgRequired();
8188 String value = cmd.getNextArgRequired();
8189 // Split on commas unless they are preceeded by an escape.
8190 // The escape character must be escaped for the string and
8191 // again for the regex, thus four escape characters become one.
8192 String[] strings = value.split("(?<!\\\\),");
8193 intent.putExtra(key, strings);
8194 hasIntentInfo = true;
8195 }
8196 break;
8197 case "--esal": {
8198 String key = cmd.getNextArgRequired();
8199 String value = cmd.getNextArgRequired();
8200 // Split on commas unless they are preceeded by an escape.
8201 // The escape character must be escaped for the string and
8202 // again for the regex, thus four escape characters become one.
8203 String[] strings = value.split("(?<!\\\\),");
8204 ArrayList<String> list = new ArrayList<>(strings.length);
8205 for (int i = 0; i < strings.length; i++) {
8206 list.add(strings[i]);
8207 }
8208 intent.putExtra(key, list);
8209 hasIntentInfo = true;
8210 }
8211 break;
8212 case "--ez": {
8213 String key = cmd.getNextArgRequired();
8214 String value = cmd.getNextArgRequired().toLowerCase();
8215 // Boolean.valueOf() results in false for anything that is not "true", which is
8216 // error-prone in shell commands
8217 boolean arg;
8218 if ("true".equals(value) || "t".equals(value)) {
8219 arg = true;
8220 } else if ("false".equals(value) || "f".equals(value)) {
8221 arg = false;
8222 } else {
8223 try {
8224 arg = Integer.decode(value) != 0;
8225 } catch (NumberFormatException ex) {
8226 throw new IllegalArgumentException("Invalid boolean value: " + value);
8227 }
8228 }
8229
8230 intent.putExtra(key, arg);
8231 }
8232 break;
8233 case "-n": {
8234 String str = cmd.getNextArgRequired();
8235 ComponentName cn = ComponentName.unflattenFromString(str);
8236 if (cn == null)
8237 throw new IllegalArgumentException("Bad component name: " + str);
8238 intent.setComponent(cn);
8239 if (intent == baseIntent) {
8240 hasIntentInfo = true;
8241 }
8242 }
8243 break;
8244 case "-p": {
8245 String str = cmd.getNextArgRequired();
8246 intent.setPackage(str);
8247 if (intent == baseIntent) {
8248 hasIntentInfo = true;
8249 }
8250 }
8251 break;
8252 case "-f":
8253 String str = cmd.getNextArgRequired();
8254 intent.setFlags(Integer.decode(str).intValue());
8255 break;
8256 case "--grant-read-uri-permission":
8257 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
8258 break;
8259 case "--grant-write-uri-permission":
8260 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
8261 break;
8262 case "--grant-persistable-uri-permission":
8263 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
8264 break;
8265 case "--grant-prefix-uri-permission":
8266 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
8267 break;
8268 case "--exclude-stopped-packages":
8269 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
8270 break;
8271 case "--include-stopped-packages":
8272 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
8273 break;
8274 case "--debug-log-resolution":
8275 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
8276 break;
8277 case "--activity-brought-to-front":
8278 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
8279 break;
8280 case "--activity-clear-top":
8281 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
8282 break;
8283 case "--activity-clear-when-task-reset":
8284 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
8285 break;
8286 case "--activity-exclude-from-recents":
8287 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
8288 break;
8289 case "--activity-launched-from-history":
8290 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
8291 break;
8292 case "--activity-multiple-task":
8293 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
8294 break;
8295 case "--activity-no-animation":
8296 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
8297 break;
8298 case "--activity-no-history":
8299 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
8300 break;
8301 case "--activity-no-user-action":
8302 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
8303 break;
8304 case "--activity-previous-is-top":
8305 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
8306 break;
8307 case "--activity-reorder-to-front":
8308 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
8309 break;
8310 case "--activity-reset-task-if-needed":
8311 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
8312 break;
8313 case "--activity-single-top":
8314 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
8315 break;
8316 case "--activity-clear-task":
8317 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
8318 break;
8319 case "--activity-task-on-home":
8320 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
8321 break;
8322 case "--activity-match-external":
8323 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
8324 break;
8325 case "--receiver-registered-only":
8326 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
8327 break;
8328 case "--receiver-replace-pending":
8329 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
8330 break;
8331 case "--receiver-foreground":
8332 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
8333 break;
8334 case "--receiver-no-abort":
8335 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
8336 break;
8337 case "--receiver-include-background":
8338 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
8339 break;
8340 case "--selector":
8341 intent.setDataAndType(data, type);
8342 intent = new Intent();
8343 break;
8344 default:
8345 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
8346 // Okay, caller handled this option.
8347 } else {
8348 throw new IllegalArgumentException("Unknown option: " + opt);
8349 }
8350 break;
8351 }
8352 }
8353 intent.setDataAndType(data, type);
8354
8355 final boolean hasSelector = intent != baseIntent;
8356 if (hasSelector) {
8357 // A selector was specified; fix up.
8358 baseIntent.setSelector(intent);
8359 intent = baseIntent;
8360 }
8361
8362 String arg = cmd.getNextArg();
8363 baseIntent = null;
8364 if (arg == null) {
8365 if (hasSelector) {
8366 // If a selector has been specified, and no arguments
8367 // have been supplied for the main Intent, then we can
8368 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
8369 // need to have a component name specified yet, the
8370 // selector will take care of that.
8371 baseIntent = new Intent(Intent.ACTION_MAIN);
8372 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
8373 }
8374 } else if (arg.indexOf(':') >= 0) {
8375 // The argument is a URI. Fully parse it, and use that result
8376 // to fill in any data not specified so far.
8377 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
8378 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
8379 } else if (arg.indexOf('/') >= 0) {
8380 // The argument is a component name. Build an Intent to launch
8381 // it.
8382 baseIntent = new Intent(Intent.ACTION_MAIN);
8383 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
8384 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
8385 } else {
8386 // Assume the argument is a package name.
8387 baseIntent = new Intent(Intent.ACTION_MAIN);
8388 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
8389 baseIntent.setPackage(arg);
8390 }
8391 if (baseIntent != null) {
8392 Bundle extras = intent.getExtras();
8393 intent.replaceExtras((Bundle)null);
8394 Bundle uriExtras = baseIntent.getExtras();
8395 baseIntent.replaceExtras((Bundle)null);
8396 if (intent.getAction() != null && baseIntent.getCategories() != null) {
8397 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
8398 for (String c : cats) {
8399 baseIntent.removeCategory(c);
8400 }
8401 }
8402 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
8403 if (extras == null) {
8404 extras = uriExtras;
8405 } else if (uriExtras != null) {
8406 uriExtras.putAll(extras);
8407 extras = uriExtras;
8408 }
8409 intent.replaceExtras(extras);
8410 hasIntentInfo = true;
8411 }
8412
8413 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
8414 return intent;
8415 }
8416
8417 /** @hide */
8418 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
8419 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
8420 final String[] lines = new String[] {
8421 "<INTENT> specifications include these flags and arguments:",
8422 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]",
8423 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
8424 " [-n <COMPONENT_NAME>]",
8425 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
8426 " [--esn <EXTRA_KEY> ...]",
8427 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
8428 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
8429 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
8430 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
8431 " [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]",
8432 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
8433 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
8434 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
8435 " (multiple extras passed as Integer[])",
8436 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
8437 " (multiple extras passed as List<Integer>)",
8438 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
8439 " (multiple extras passed as Long[])",
8440 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
8441 " (multiple extras passed as List<Long>)",
8442 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
8443 " (multiple extras passed as Float[])",
8444 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
8445 " (multiple extras passed as List<Float>)",
8446 " [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]",
8447 " (multiple extras passed as Double[])",
8448 " [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]",
8449 " (multiple extras passed as List<Double>)",
8450 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
8451 " (multiple extras passed as String[]; to embed a comma into a string,",
8452 " escape it using \"\\,\")",
8453 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
8454 " (multiple extras passed as List<String>; to embed a comma into a string,",
8455 " escape it using \"\\,\")",
8456 " [-f <FLAG>]",
8457 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
8458 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
8459 " [--debug-log-resolution] [--exclude-stopped-packages]",
8460 " [--include-stopped-packages]",
8461 " [--activity-brought-to-front] [--activity-clear-top]",
8462 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
8463 " [--activity-launched-from-history] [--activity-multiple-task]",
8464 " [--activity-no-animation] [--activity-no-history]",
8465 " [--activity-no-user-action] [--activity-previous-is-top]",
8466 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
8467 " [--activity-single-top] [--activity-clear-task]",
8468 " [--activity-task-on-home] [--activity-match-external]",
8469 " [--receiver-registered-only] [--receiver-replace-pending]",
8470 " [--receiver-foreground] [--receiver-no-abort]",
8471 " [--receiver-include-background]",
8472 " [--selector]",
8473 " [<URI> | <PACKAGE> | <COMPONENT>]"
8474 };
8475 for (String line : lines) {
8476 pw.print(prefix);
8477 pw.println(line);
8478 }
8479 }
8480
8481 /**
8482 * Retrieve the general action to be performed, such as
8483 * {@link #ACTION_VIEW}. The action describes the general way the rest of
8484 * the information in the intent should be interpreted -- most importantly,
8485 * what to do with the data returned by {@link #getData}.
8486 *
8487 * @return The action of this intent or null if none is specified.
8488 *
8489 * @see #setAction
8490 */
8491 public @Nullable String getAction() {
8492 return mAction;
8493 }
8494
8495 /**
8496 * Retrieve data this intent is operating on. This URI specifies the name
8497 * of the data; often it uses the content: scheme, specifying data in a
8498 * content provider. Other schemes may be handled by specific activities,
8499 * such as http: by the web browser.
8500 *
8501 * @return The URI of the data this intent is targeting or null.
8502 *
8503 * @see #getScheme
8504 * @see #setData
8505 */
8506 public @Nullable Uri getData() {
8507 return mData;
8508 }
8509
8510 /**
8511 * The same as {@link #getData()}, but returns the URI as an encoded
8512 * String.
8513 */
8514 public @Nullable String getDataString() {
8515 return mData != null ? mData.toString() : null;
8516 }
8517
8518 /**
8519 * Return the scheme portion of the intent's data. If the data is null or
8520 * does not include a scheme, null is returned. Otherwise, the scheme
8521 * prefix without the final ':' is returned, i.e. "http".
8522 *
8523 * <p>This is the same as calling getData().getScheme() (and checking for
8524 * null data).
8525 *
8526 * @return The scheme of this intent.
8527 *
8528 * @see #getData
8529 */
8530 public @Nullable String getScheme() {
8531 return mData != null ? mData.getScheme() : null;
8532 }
8533
8534 /**
8535 * Retrieve any explicit MIME type included in the intent. This is usually
8536 * null, as the type is determined by the intent data.
8537 *
8538 * @return If a type was manually set, it is returned; else null is
8539 * returned.
8540 *
8541 * @see #resolveType(ContentResolver)
8542 * @see #setType
8543 */
8544 public @Nullable String getType() {
8545 return mType;
8546 }
8547
8548
8549 /**
8550 * @hide For the experimental component alias feature. Do not use, unless you know what it is.
8551 */
8552 @Nullable
8553 public Intent getOriginalIntent() {
8554 return mOriginalIntent;
8555 }
8556
8557 /**
8558 * @hide For the experimental component alias feature. Do not use, unless you know what it is.
8559 */
8560 public void setOriginalIntent(@Nullable Intent originalIntent) {
8561 mOriginalIntent = originalIntent;
8562 }
8563
8564 /**
8565 * Return the MIME data type of this intent. If the type field is
8566 * explicitly set, that is simply returned. Otherwise, if the data is set,
8567 * the type of that data is returned. If neither fields are set, a null is
8568 * returned.
8569 *
8570 * @return The MIME type of this intent.
8571 *
8572 * @see #getType
8573 * @see #resolveType(ContentResolver)
8574 */
8575 public @Nullable String resolveType(@NonNull Context context) {
8576 return resolveType(context.getContentResolver());
8577 }
8578
8579 /**
8580 * Return the MIME data type of this intent. If the type field is
8581 * explicitly set, that is simply returned. Otherwise, if the data is set,
8582 * the type of that data is returned. If neither fields are set, a null is
8583 * returned.
8584 *
8585 * @param resolver A ContentResolver that can be used to determine the MIME
8586 * type of the intent's data.
8587 *
8588 * @return The MIME type of this intent.
8589 *
8590 * @see #getType
8591 * @see #resolveType(Context)
8592 */
8593 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
8594 if (mType != null) {
8595 return mType;
8596 }
8597 if (mData != null) {
8598 if ("content".equals(mData.getScheme())) {
8599 return resolver.getType(mData);
8600 }
8601 }
8602 return null;
8603 }
8604
8605 /**
8606 * Return the MIME data type of this intent, only if it will be needed for
8607 * intent resolution. This is not generally useful for application code;
8608 * it is used by the frameworks for communicating with back-end system
8609 * services.
8610 *
8611 * @param resolver A ContentResolver that can be used to determine the MIME
8612 * type of the intent's data.
8613 *
8614 * @return The MIME type of this intent, or null if it is unknown or not
8615 * needed.
8616 */
8617 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
8618 // Match logic in PackageManagerService#applyEnforceIntentFilterMatching(...)
8619 if (mComponent != null && (Process.myUid() == Process.ROOT_UID
8620 || Process.myUid() == Process.SYSTEM_UID
8621 || mComponent.getPackageName().equals(ActivityThread.currentPackageName()))) {
8622 return mType;
8623 }
8624 return resolveType(resolver);
8625 }
8626
8627 /**
8628 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity
8629 * of the Intent to distinguish it from other Intents.
8630 *
8631 * @return The identifier of this intent or null if none is specified.
8632 *
8633 * @see #setIdentifier
8634 */
8635 public @Nullable String getIdentifier() {
8636 return mIdentifier;
8637 }
8638
8639 /**
8640 * Check if a category exists in the intent.
8641 *
8642 * @param category The category to check.
8643 *
8644 * @return boolean True if the intent contains the category, else false.
8645 *
8646 * @see #getCategories
8647 * @see #addCategory
8648 */
8649 public boolean hasCategory(String category) {
8650 return mCategories != null && mCategories.contains(category);
8651 }
8652
8653 /**
8654 * Return the set of all categories in the intent. If there are no categories,
8655 * returns NULL.
8656 *
8657 * @return The set of categories you can examine. Do not modify!
8658 *
8659 * @see #hasCategory
8660 * @see #addCategory
8661 */
8662 public Set<String> getCategories() {
8663 return mCategories;
8664 }
8665
8666 /**
8667 * Return the specific selector associated with this Intent. If there is
8668 * none, returns null. See {@link #setSelector} for more information.
8669 *
8670 * @see #setSelector
8671 */
8672 public @Nullable Intent getSelector() {
8673 return mSelector;
8674 }
8675
8676 /**
8677 * Return the {@link ClipData} associated with this Intent. If there is
8678 * none, returns null. See {@link #setClipData} for more information.
8679 *
8680 * @see #setClipData
8681 */
8682 public @Nullable ClipData getClipData() {
8683 return mClipData;
8684 }
8685
8686 /** @hide */
8687 public int getContentUserHint() {
8688 return mContentUserHint;
8689 }
8690
8691 /** @hide */
8692 public String getLaunchToken() {
8693 return mLaunchToken;
8694 }
8695
8696 /** @hide */
8697 public void setLaunchToken(String launchToken) {
8698 mLaunchToken = launchToken;
8699 }
8700
8701 /**
8702 * Sets the ClassLoader that will be used when unmarshalling
8703 * any Parcelable values from the extras of this Intent.
8704 *
8705 * @param loader a ClassLoader, or null to use the default loader
8706 * at the time of unmarshalling.
8707 */
8708 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
8709 if (mExtras != null) {
8710 mExtras.setClassLoader(loader);
8711 }
8712 }
8713
8714 /**
8715 * Returns true if an extra value is associated with the given name.
8716 * @param name the extra's name
8717 * @return true if the given extra is present.
8718 */
8719 public boolean hasExtra(String name) {
8720 return mExtras != null && mExtras.containsKey(name);
8721 }
8722
8723 /**
8724 * Returns true if the Intent's extras contain a parcelled file descriptor.
8725 * @return true if the Intent contains a parcelled file descriptor.
8726 */
8727 public boolean hasFileDescriptors() {
8728 return mExtras != null && mExtras.hasFileDescriptors();
8729 }
8730
8731 /** {@hide} */
8732 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
8733 public void setAllowFds(boolean allowFds) {
8734 if (mExtras != null) {
8735 mExtras.setAllowFds(allowFds);
8736 }
8737 }
8738
8739 /** {@hide} */
8740 public void setDefusable(boolean defusable) {
8741 if (mExtras != null) {
8742 mExtras.setDefusable(defusable);
8743 }
8744 }
8745
8746 /**
8747 * Retrieve extended data from the intent.
8748 *
8749 * @param name The name of the desired item.
8750 *
8751 * @return the value of an item previously added with putExtra(),
8752 * or null if none was found.
8753 *
8754 * @deprecated
8755 * @hide
8756 */
8757 @Deprecated
8758 @UnsupportedAppUsage
8759 public Object getExtra(String name) {
8760 return getExtra(name, null);
8761 }
8762
8763 /**
8764 * Retrieve extended data from the intent.
8765 *
8766 * @param name The name of the desired item.
8767 * @param defaultValue the value to be returned if no value of the desired
8768 * type is stored with the given name.
8769 *
8770 * @return the value of an item previously added with putExtra(),
8771 * or the default value if none was found.
8772 *
8773 * @see #putExtra(String, boolean)
8774 */
8775 public boolean getBooleanExtra(String name, boolean defaultValue) {
8776 return mExtras == null ? defaultValue :
8777 mExtras.getBoolean(name, defaultValue);
8778 }
8779
8780 /**
8781 * Retrieve extended data from the intent.
8782 *
8783 * @param name The name of the desired item.
8784 * @param defaultValue the value to be returned if no value of the desired
8785 * type is stored with the given name.
8786 *
8787 * @return the value of an item previously added with putExtra(),
8788 * or the default value if none was found.
8789 *
8790 * @see #putExtra(String, byte)
8791 */
8792 public byte getByteExtra(String name, byte defaultValue) {
8793 return mExtras == null ? defaultValue :
8794 mExtras.getByte(name, defaultValue);
8795 }
8796
8797 /**
8798 * Retrieve extended data from the intent.
8799 *
8800 * @param name The name of the desired item.
8801 * @param defaultValue the value to be returned if no value of the desired
8802 * type is stored with the given name.
8803 *
8804 * @return the value of an item previously added with putExtra(),
8805 * or the default value if none was found.
8806 *
8807 * @see #putExtra(String, short)
8808 */
8809 public short getShortExtra(String name, short defaultValue) {
8810 return mExtras == null ? defaultValue :
8811 mExtras.getShort(name, defaultValue);
8812 }
8813
8814 /**
8815 * Retrieve extended data from the intent.
8816 *
8817 * @param name The name of the desired item.
8818 * @param defaultValue the value to be returned if no value of the desired
8819 * type is stored with the given name.
8820 *
8821 * @return the value of an item previously added with putExtra(),
8822 * or the default value if none was found.
8823 *
8824 * @see #putExtra(String, char)
8825 */
8826 public char getCharExtra(String name, char defaultValue) {
8827 return mExtras == null ? defaultValue :
8828 mExtras.getChar(name, defaultValue);
8829 }
8830
8831 /**
8832 * Retrieve extended data from the intent.
8833 *
8834 * @param name The name of the desired item.
8835 * @param defaultValue the value to be returned if no value of the desired
8836 * type is stored with the given name.
8837 *
8838 * @return the value of an item previously added with putExtra(),
8839 * or the default value if none was found.
8840 *
8841 * @see #putExtra(String, int)
8842 */
8843 public int getIntExtra(String name, int defaultValue) {
8844 return mExtras == null ? defaultValue :
8845 mExtras.getInt(name, defaultValue);
8846 }
8847
8848 /**
8849 * Retrieve extended data from the intent.
8850 *
8851 * @param name The name of the desired item.
8852 * @param defaultValue the value to be returned if no value of the desired
8853 * type is stored with the given name.
8854 *
8855 * @return the value of an item previously added with putExtra(),
8856 * or the default value if none was found.
8857 *
8858 * @see #putExtra(String, long)
8859 */
8860 public long getLongExtra(String name, long defaultValue) {
8861 return mExtras == null ? defaultValue :
8862 mExtras.getLong(name, defaultValue);
8863 }
8864
8865 /**
8866 * Retrieve extended data from the intent.
8867 *
8868 * @param name The name of the desired item.
8869 * @param defaultValue the value to be returned if no value of the desired
8870 * type is stored with the given name.
8871 *
8872 * @return the value of an item previously added with putExtra(),
8873 * or the default value if no such item is present
8874 *
8875 * @see #putExtra(String, float)
8876 */
8877 public float getFloatExtra(String name, float defaultValue) {
8878 return mExtras == null ? defaultValue :
8879 mExtras.getFloat(name, defaultValue);
8880 }
8881
8882 /**
8883 * Retrieve extended data from the intent.
8884 *
8885 * @param name The name of the desired item.
8886 * @param defaultValue the value to be returned if no value of the desired
8887 * type is stored with the given name.
8888 *
8889 * @return the value of an item previously added with putExtra(),
8890 * or the default value if none was found.
8891 *
8892 * @see #putExtra(String, double)
8893 */
8894 public double getDoubleExtra(String name, double defaultValue) {
8895 return mExtras == null ? defaultValue :
8896 mExtras.getDouble(name, defaultValue);
8897 }
8898
8899 /**
8900 * Retrieve extended data from the intent.
8901 *
8902 * @param name The name of the desired item.
8903 *
8904 * @return the value of an item previously added with putExtra(),
8905 * or null if no String value was found.
8906 *
8907 * @see #putExtra(String, String)
8908 */
8909 public @Nullable String getStringExtra(String name) {
8910 return mExtras == null ? null : mExtras.getString(name);
8911 }
8912
8913 /**
8914 * Retrieve extended data from the intent.
8915 *
8916 * @param name The name of the desired item.
8917 *
8918 * @return the value of an item previously added with putExtra(),
8919 * or null if no CharSequence value was found.
8920 *
8921 * @see #putExtra(String, CharSequence)
8922 */
8923 public @Nullable CharSequence getCharSequenceExtra(String name) {
8924 return mExtras == null ? null : mExtras.getCharSequence(name);
8925 }
8926
8927 /**
8928 * Retrieve extended data from the intent.
8929 *
8930 * @param name The name of the desired item.
8931 *
8932 * @return the value of an item previously added with putExtra(),
8933 * or null if no Parcelable value was found.
8934 *
8935 * @deprecated Use the type-safer {@link #getParcelableExtra(String, Class)} starting from
8936 * Android {@link Build.VERSION_CODES#TIRAMISU}.
8937 *
8938 * @see #putExtra(String, Parcelable)
8939 */
8940 @Deprecated
8941 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
8942 return mExtras == null ? null : mExtras.<T>getParcelable(name);
8943 }
8944
8945 /**
8946 * Retrieve extended data from the intent.
8947 *
8948 * @param name The name of the desired item.
8949 * @param clazz The type of the object expected.
8950 *
8951 * @return the value of an item previously added with putExtra(),
8952 * or null if no Parcelable value was found.
8953 *
8954 * @see #putExtra(String, Parcelable)
8955 */
8956 public @Nullable <T> T getParcelableExtra(@Nullable String name, @NonNull Class<T> clazz) {
8957 return mExtras == null ? null : mExtras.getParcelable(name, clazz);
8958 }
8959
8960 /**
8961 * Retrieve extended data from the intent.
8962 *
8963 * @param name The name of the desired item.
8964 *
8965 * @return the value of an item previously added with putExtra(),
8966 * or null if no Parcelable[] value was found.
8967 *
8968 * @deprecated Use the type-safer {@link #getParcelableArrayExtra(String, Class)} starting from
8969 * Android {@link Build.VERSION_CODES#TIRAMISU}.
8970 *
8971 * @see #putExtra(String, Parcelable[])
8972 */
8973 @Deprecated
8974 public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
8975 return mExtras == null ? null : mExtras.getParcelableArray(name);
8976 }
8977
8978 /**
8979 * Retrieve extended data from the intent.
8980 *
8981 * @param name The name of the desired item.
8982 * @param clazz The type of the items inside the array. This is only verified when unparceling.
8983 *
8984 * @return the value of an item previously added with putExtra(),
8985 * or null if no Parcelable[] value was found.
8986 *
8987 * @see #putExtra(String, Parcelable[])
8988 */
8989 @SuppressLint({"ArrayReturn", "NullableCollection"})
8990 public @Nullable <T> T[] getParcelableArrayExtra(@Nullable String name,
8991 @NonNull Class<T> clazz) {
8992 return mExtras == null ? null : mExtras.getParcelableArray(name, clazz);
8993 }
8994
8995 /**
8996 * Retrieve extended data from the intent.
8997 *
8998 * @param name The name of the desired item.
8999 *
9000 * @return the value of an item previously added with
9001 * putParcelableArrayListExtra(), or null if no
9002 * ArrayList<Parcelable> value was found.
9003 *
9004 * @deprecated Use the type-safer {@link #getParcelableArrayListExtra(String, Class)} starting
9005 * from Android {@link Build.VERSION_CODES#TIRAMISU}.
9006 *
9007 * @see #putParcelableArrayListExtra(String, ArrayList)
9008 */
9009 @Deprecated
9010 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
9011 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
9012 }
9013
9014 /**
9015 * Retrieve extended data from the intent.
9016 *
9017 * @param name The name of the desired item.
9018 * @param clazz The type of the items inside the array list. This is only verified when
9019 * unparceling.
9020 *
9021 * @return the value of an item previously added with
9022 * putParcelableArrayListExtra(), or null if no
9023 * ArrayList<Parcelable> value was found.
9024 *
9025 * @see #putParcelableArrayListExtra(String, ArrayList)
9026 */
9027 @SuppressLint({"ConcreteCollection", "NullableCollection"})
9028 public @Nullable <T> ArrayList<T> getParcelableArrayListExtra(@Nullable String name,
9029 @NonNull Class<? extends T> clazz) {
9030 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name, clazz);
9031 }
9032
9033 /**
9034 * Retrieve extended data from the intent.
9035 *
9036 * @param name The name of the desired item.
9037 *
9038 * @return the value of an item previously added with putExtra(),
9039 * or null if no Serializable value was found.
9040 *
9041 * @deprecated Use the type-safer {@link #getSerializableExtra(String, Class)} starting from
9042 * Android {@link Build.VERSION_CODES#TIRAMISU}.
9043 *
9044 * @see #putExtra(String, Serializable)
9045 */
9046 public @Nullable Serializable getSerializableExtra(String name) {
9047 return mExtras == null ? null : mExtras.getSerializable(name);
9048 }
9049
9050 /**
9051 * Retrieve extended data from the intent.
9052 *
9053 * @param name The name of the desired item.
9054 * @param clazz The type of the object expected.
9055 *
9056 * @return the value of an item previously added with putExtra(),
9057 * or null if no Serializable value was found.
9058 *
9059 * @see #putExtra(String, Serializable)
9060 */
9061 public @Nullable <T extends Serializable> T getSerializableExtra(@Nullable String name,
9062 @NonNull Class<T> clazz) {
9063 return mExtras == null ? null : mExtras.getSerializable(name, clazz);
9064 }
9065
9066 /**
9067 * Retrieve extended data from the intent.
9068 *
9069 * @param name The name of the desired item.
9070 *
9071 * @return the value of an item previously added with
9072 * putIntegerArrayListExtra(), or null if no
9073 * ArrayList<Integer> value was found.
9074 *
9075 * @see #putIntegerArrayListExtra(String, ArrayList)
9076 */
9077 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
9078 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
9079 }
9080
9081 /**
9082 * Retrieve extended data from the intent.
9083 *
9084 * @param name The name of the desired item.
9085 *
9086 * @return the value of an item previously added with
9087 * putStringArrayListExtra(), or null if no
9088 * ArrayList<String> value was found.
9089 *
9090 * @see #putStringArrayListExtra(String, ArrayList)
9091 */
9092 public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
9093 return mExtras == null ? null : mExtras.getStringArrayList(name);
9094 }
9095
9096 /**
9097 * Retrieve extended data from the intent.
9098 *
9099 * @param name The name of the desired item.
9100 *
9101 * @return the value of an item previously added with
9102 * putCharSequenceArrayListExtra, or null if no
9103 * ArrayList<CharSequence> value was found.
9104 *
9105 * @see #putCharSequenceArrayListExtra(String, ArrayList)
9106 */
9107 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
9108 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
9109 }
9110
9111 /**
9112 * Retrieve extended data from the intent.
9113 *
9114 * @param name The name of the desired item.
9115 *
9116 * @return the value of an item previously added with putExtra(),
9117 * or null if no boolean array value was found.
9118 *
9119 * @see #putExtra(String, boolean[])
9120 */
9121 public @Nullable boolean[] getBooleanArrayExtra(String name) {
9122 return mExtras == null ? null : mExtras.getBooleanArray(name);
9123 }
9124
9125 /**
9126 * Retrieve extended data from the intent.
9127 *
9128 * @param name The name of the desired item.
9129 *
9130 * @return the value of an item previously added with putExtra(),
9131 * or null if no byte array value was found.
9132 *
9133 * @see #putExtra(String, byte[])
9134 */
9135 public @Nullable byte[] getByteArrayExtra(String name) {
9136 return mExtras == null ? null : mExtras.getByteArray(name);
9137 }
9138
9139 /**
9140 * Retrieve extended data from the intent.
9141 *
9142 * @param name The name of the desired item.
9143 *
9144 * @return the value of an item previously added with putExtra(),
9145 * or null if no short array value was found.
9146 *
9147 * @see #putExtra(String, short[])
9148 */
9149 public @Nullable short[] getShortArrayExtra(String name) {
9150 return mExtras == null ? null : mExtras.getShortArray(name);
9151 }
9152
9153 /**
9154 * Retrieve extended data from the intent.
9155 *
9156 * @param name The name of the desired item.
9157 *
9158 * @return the value of an item previously added with putExtra(),
9159 * or null if no char array value was found.
9160 *
9161 * @see #putExtra(String, char[])
9162 */
9163 public @Nullable char[] getCharArrayExtra(String name) {
9164 return mExtras == null ? null : mExtras.getCharArray(name);
9165 }
9166
9167 /**
9168 * Retrieve extended data from the intent.
9169 *
9170 * @param name The name of the desired item.
9171 *
9172 * @return the value of an item previously added with putExtra(),
9173 * or null if no int array value was found.
9174 *
9175 * @see #putExtra(String, int[])
9176 */
9177 public @Nullable int[] getIntArrayExtra(String name) {
9178 return mExtras == null ? null : mExtras.getIntArray(name);
9179 }
9180
9181 /**
9182 * Retrieve extended data from the intent.
9183 *
9184 * @param name The name of the desired item.
9185 *
9186 * @return the value of an item previously added with putExtra(),
9187 * or null if no long array value was found.
9188 *
9189 * @see #putExtra(String, long[])
9190 */
9191 public @Nullable long[] getLongArrayExtra(String name) {
9192 return mExtras == null ? null : mExtras.getLongArray(name);
9193 }
9194
9195 /**
9196 * Retrieve extended data from the intent.
9197 *
9198 * @param name The name of the desired item.
9199 *
9200 * @return the value of an item previously added with putExtra(),
9201 * or null if no float array value was found.
9202 *
9203 * @see #putExtra(String, float[])
9204 */
9205 public @Nullable float[] getFloatArrayExtra(String name) {
9206 return mExtras == null ? null : mExtras.getFloatArray(name);
9207 }
9208
9209 /**
9210 * Retrieve extended data from the intent.
9211 *
9212 * @param name The name of the desired item.
9213 *
9214 * @return the value of an item previously added with putExtra(),
9215 * or null if no double array value was found.
9216 *
9217 * @see #putExtra(String, double[])
9218 */
9219 public @Nullable double[] getDoubleArrayExtra(String name) {
9220 return mExtras == null ? null : mExtras.getDoubleArray(name);
9221 }
9222
9223 /**
9224 * Retrieve extended data from the intent.
9225 *
9226 * @param name The name of the desired item.
9227 *
9228 * @return the value of an item previously added with putExtra(),
9229 * or null if no String array value was found.
9230 *
9231 * @see #putExtra(String, String[])
9232 */
9233 public @Nullable String[] getStringArrayExtra(String name) {
9234 return mExtras == null ? null : mExtras.getStringArray(name);
9235 }
9236
9237 /**
9238 * Retrieve extended data from the intent.
9239 *
9240 * @param name The name of the desired item.
9241 *
9242 * @return the value of an item previously added with putExtra(),
9243 * or null if no CharSequence array value was found.
9244 *
9245 * @see #putExtra(String, CharSequence[])
9246 */
9247 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
9248 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
9249 }
9250
9251 /**
9252 * Retrieve extended data from the intent.
9253 *
9254 * @param name The name of the desired item.
9255 *
9256 * @return the value of an item previously added with putExtra(),
9257 * or null if no Bundle value was found.
9258 *
9259 * @see #putExtra(String, Bundle)
9260 */
9261 public @Nullable Bundle getBundleExtra(String name) {
9262 return mExtras == null ? null : mExtras.getBundle(name);
9263 }
9264
9265 /**
9266 * Retrieve extended data from the intent.
9267 *
9268 * @param name The name of the desired item.
9269 *
9270 * @return the value of an item previously added with putExtra(),
9271 * or null if no IBinder value was found.
9272 *
9273 * @see #putExtra(String, IBinder)
9274 *
9275 * @deprecated
9276 * @hide
9277 */
9278 @Deprecated
9279 @UnsupportedAppUsage
9280 public IBinder getIBinderExtra(String name) {
9281 return mExtras == null ? null : mExtras.getIBinder(name);
9282 }
9283
9284 /**
9285 * Retrieve extended data from the intent.
9286 *
9287 * @param name The name of the desired item.
9288 * @param defaultValue The default value to return in case no item is
9289 * associated with the key 'name'
9290 *
9291 * @return the value of an item previously added with putExtra(),
9292 * or defaultValue if none was found.
9293 *
9294 * @see #putExtra
9295 *
9296 * @deprecated
9297 * @hide
9298 */
9299 @Deprecated
9300 @UnsupportedAppUsage
9301 public Object getExtra(String name, Object defaultValue) {
9302 Object result = defaultValue;
9303 if (mExtras != null) {
9304 Object result2 = mExtras.get(name);
9305 if (result2 != null) {
9306 result = result2;
9307 }
9308 }
9309
9310 return result;
9311 }
9312
9313 /**
9314 * Retrieves a map of extended data from the intent.
9315 *
9316 * @return the map of all extras previously added with putExtra(),
9317 * or null if none have been added.
9318 */
9319 public @Nullable Bundle getExtras() {
9320 return (mExtras != null)
9321 ? new Bundle(mExtras)
9322 : null;
9323 }
9324
9325 /**
9326 * Returns the total size of the extras in bytes, or 0 if no extras are present.
9327 * @hide
9328 */
9329 public int getExtrasTotalSize() {
9330 return (mExtras != null)
9331 ? mExtras.getSize()
9332 : 0;
9333 }
9334
9335 /**
9336 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
9337 * return itself as-is.
9338 * @hide
9339 */
9340 public boolean canStripForHistory() {
9341 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
9342 }
9343
9344 /**
9345 * Call it when the system needs to keep an intent for logging purposes to remove fields
9346 * that are not needed for logging.
9347 * @hide
9348 */
9349 public Intent maybeStripForHistory() {
9350 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
9351
9352 if (!canStripForHistory()) {
9353 return this;
9354 }
9355 return new Intent(this, COPY_MODE_HISTORY);
9356 }
9357
9358 /**
9359 * Retrieve any special flags associated with this intent. You will
9360 * normally just set them with {@link #setFlags} and let the system
9361 * take the appropriate action with them.
9362 *
9363 * @return The currently set flags.
9364 * @see #setFlags
9365 * @see #addFlags
9366 * @see #removeFlags
9367 */
9368 public @Flags int getFlags() {
9369 return mFlags;
9370 }
9371
9372 /** @hide */
9373 @UnsupportedAppUsage
9374 public boolean isExcludingStopped() {
9375 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
9376 == FLAG_EXCLUDE_STOPPED_PACKAGES;
9377 }
9378
9379 /**
9380 * Retrieve the application package name this Intent is limited to. When
9381 * resolving an Intent, if non-null this limits the resolution to only
9382 * components in the given application package.
9383 *
9384 * @return The name of the application package for the Intent.
9385 *
9386 * @see #resolveActivity
9387 * @see #setPackage
9388 */
9389 public @Nullable String getPackage() {
9390 return mPackage;
9391 }
9392
9393 /**
9394 * Retrieve the concrete component associated with the intent. When receiving
9395 * an intent, this is the component that was found to best handle it (that is,
9396 * yourself) and will always be non-null; in all other cases it will be
9397 * null unless explicitly set.
9398 *
9399 * @return The name of the application component to handle the intent.
9400 *
9401 * @see #resolveActivity
9402 * @see #setComponent
9403 */
9404 public @Nullable ComponentName getComponent() {
9405 return mComponent;
9406 }
9407
9408 /**
9409 * Get the bounds of the sender of this intent, in screen coordinates. This can be
9410 * used as a hint to the receiver for animations and the like. Null means that there
9411 * is no source bounds.
9412 */
9413 public @Nullable Rect getSourceBounds() {
9414 return mSourceBounds;
9415 }
9416
9417 /**
9418 * Return the Activity component that should be used to handle this intent.
9419 * The appropriate component is determined based on the information in the
9420 * intent, evaluated as follows:
9421 *
9422 * <p>If {@link #getComponent} returns an explicit class, that is returned
9423 * without any further consideration.
9424 *
9425 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
9426 * category to be considered.
9427 *
9428 * <p>If {@link #getAction} is non-NULL, the activity must handle this
9429 * action.
9430 *
9431 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
9432 * this type.
9433 *
9434 * <p>If {@link #addCategory} has added any categories, the activity must
9435 * handle ALL of the categories specified.
9436 *
9437 * <p>If {@link #getPackage} is non-NULL, only activity components in
9438 * that application package will be considered.
9439 *
9440 * <p>If there are no activities that satisfy all of these conditions, a
9441 * null string is returned.
9442 *
9443 * <p>If multiple activities are found to satisfy the intent, the one with
9444 * the highest priority will be used. If there are multiple activities
9445 * with the same priority, the system will either pick the best activity
9446 * based on user preference, or resolve to a system class that will allow
9447 * the user to pick an activity and forward from there.
9448 *
9449 * <p>This method is implemented simply by calling
9450 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
9451 * true.</p>
9452 * <p> This API is called for you as part of starting an activity from an
9453 * intent. You do not normally need to call it yourself.</p>
9454 *
9455 * @param pm The package manager with which to resolve the Intent.
9456 *
9457 * @return Name of the component implementing an activity that can
9458 * display the intent.
9459 *
9460 * @see #setComponent
9461 * @see #getComponent
9462 * @see #resolveActivityInfo
9463 */
9464 public ComponentName resolveActivity(@NonNull PackageManager pm) {
9465 if (mComponent != null) {
9466 return mComponent;
9467 }
9468
9469 ResolveInfo info = pm.resolveActivity(
9470 this, PackageManager.MATCH_DEFAULT_ONLY);
9471 if (info != null) {
9472 return new ComponentName(
9473 info.activityInfo.applicationInfo.packageName,
9474 info.activityInfo.name);
9475 }
9476
9477 return null;
9478 }
9479
9480 /**
9481 * Resolve the Intent into an {@link ActivityInfo}
9482 * describing the activity that should execute the intent. Resolution
9483 * follows the same rules as described for {@link #resolveActivity}, but
9484 * you get back the completely information about the resolved activity
9485 * instead of just its class name.
9486 *
9487 * @param pm The package manager with which to resolve the Intent.
9488 * @param flags Addition information to retrieve as per
9489 * {@link PackageManager#getActivityInfo(ComponentName, int)
9490 * PackageManager.getActivityInfo()}.
9491 *
9492 * @return PackageManager.ActivityInfo
9493 *
9494 * @see #resolveActivity
9495 */
9496 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
9497 @PackageManager.ComponentInfoFlagsBits int flags) {
9498 ActivityInfo ai = null;
9499 if (mComponent != null) {
9500 try {
9501 ai = pm.getActivityInfo(mComponent, flags);
9502 } catch (PackageManager.NameNotFoundException e) {
9503 // ignore
9504 }
9505 } else {
9506 ResolveInfo info = pm.resolveActivity(
9507 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
9508 if (info != null) {
9509 ai = info.activityInfo;
9510 }
9511 }
9512
9513 return ai;
9514 }
9515
9516 /**
9517 * Special function for use by the system to resolve service
9518 * intents to system apps. Throws an exception if there are
9519 * multiple potential matches to the Intent. Returns null if
9520 * there are no matches.
9521 * @hide
9522 */
9523 @UnsupportedAppUsage
9524 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
9525 @PackageManager.ComponentInfoFlagsBits int flags) {
9526 if (mComponent != null) {
9527 return mComponent;
9528 }
9529
9530 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
9531 if (results == null) {
9532 return null;
9533 }
9534 ComponentName comp = null;
9535 for (int i=0; i<results.size(); i++) {
9536 ResolveInfo ri = results.get(i);
9537 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
9538 continue;
9539 }
9540 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
9541 ri.serviceInfo.name);
9542 if (comp != null) {
9543 throw new IllegalStateException("Multiple system services handle " + this
9544 + ": " + comp + ", " + foundComp);
9545 }
9546 comp = foundComp;
9547 }
9548 return comp;
9549 }
9550
9551 /**
9552 * Set the general action to be performed.
9553 *
9554 * @param action An action name, such as ACTION_VIEW. Application-specific
9555 * actions should be prefixed with the vendor's package name.
9556 *
9557 * @return Returns the same Intent object, for chaining multiple calls
9558 * into a single statement.
9559 *
9560 * @see #getAction
9561 */
9562 public @NonNull Intent setAction(@Nullable String action) {
9563 mAction = action != null ? action.intern() : null;
9564 return this;
9565 }
9566
9567 /**
9568 * Set the data this intent is operating on. This method automatically
9569 * clears any type that was previously set by {@link #setType} or
9570 * {@link #setTypeAndNormalize}.
9571 *
9572 * <p><em>Note: scheme matching in the Android framework is
9573 * case-sensitive, unlike the formal RFC. As a result,
9574 * you should always write your Uri with a lower case scheme,
9575 * or use {@link Uri#normalizeScheme} or
9576 * {@link #setDataAndNormalize}
9577 * to ensure that the scheme is converted to lower case.</em>
9578 *
9579 * @param data The Uri of the data this intent is now targeting.
9580 *
9581 * @return Returns the same Intent object, for chaining multiple calls
9582 * into a single statement.
9583 *
9584 * @see #getData
9585 * @see #setDataAndNormalize
9586 * @see android.net.Uri#normalizeScheme()
9587 */
9588 public @NonNull Intent setData(@Nullable Uri data) {
9589 mData = data;
9590 mType = null;
9591 return this;
9592 }
9593
9594 /**
9595 * Normalize and set the data this intent is operating on.
9596 *
9597 * <p>This method automatically clears any type that was
9598 * previously set (for example, by {@link #setType}).
9599 *
9600 * <p>The data Uri is normalized using
9601 * {@link android.net.Uri#normalizeScheme} before it is set,
9602 * so really this is just a convenience method for
9603 * <pre>
9604 * setData(data.normalize())
9605 * </pre>
9606 *
9607 * @param data The Uri of the data this intent is now targeting.
9608 *
9609 * @return Returns the same Intent object, for chaining multiple calls
9610 * into a single statement.
9611 *
9612 * @see #getData
9613 * @see #setType
9614 * @see android.net.Uri#normalizeScheme
9615 */
9616 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
9617 return setData(data.normalizeScheme());
9618 }
9619
9620 /**
9621 * Set an explicit MIME data type.
9622 *
9623 * <p>This is used to create intents that only specify a type and not data,
9624 * for example to indicate the type of data to return.
9625 *
9626 * <p>This method automatically clears any data that was
9627 * previously set (for example by {@link #setData}).
9628 *
9629 * <p><em>Note: MIME type matching in the Android framework is
9630 * case-sensitive, unlike formal RFC MIME types. As a result,
9631 * you should always write your MIME types with lower case letters,
9632 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
9633 * to ensure that it is converted to lower case.</em>
9634 *
9635 * @param type The MIME type of the data being handled by this intent.
9636 *
9637 * @return Returns the same Intent object, for chaining multiple calls
9638 * into a single statement.
9639 *
9640 * @see #getType
9641 * @see #setTypeAndNormalize
9642 * @see #setDataAndType
9643 * @see #normalizeMimeType
9644 */
9645 public @NonNull Intent setType(@Nullable String type) {
9646 mData = null;
9647 mType = type;
9648 return this;
9649 }
9650
9651 /**
9652 * Normalize and set an explicit MIME data type.
9653 *
9654 * <p>This is used to create intents that only specify a type and not data,
9655 * for example to indicate the type of data to return.
9656 *
9657 * <p>This method automatically clears any data that was
9658 * previously set (for example by {@link #setData}).
9659 *
9660 * <p>The MIME type is normalized using
9661 * {@link #normalizeMimeType} before it is set,
9662 * so really this is just a convenience method for
9663 * <pre>
9664 * setType(Intent.normalizeMimeType(type))
9665 * </pre>
9666 *
9667 * @param type The MIME type of the data being handled by this intent.
9668 *
9669 * @return Returns the same Intent object, for chaining multiple calls
9670 * into a single statement.
9671 *
9672 * @see #getType
9673 * @see #setData
9674 * @see #normalizeMimeType
9675 */
9676 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
9677 return setType(normalizeMimeType(type));
9678 }
9679
9680 /**
9681 * (Usually optional) Set the data for the intent along with an explicit
9682 * MIME data type. This method should very rarely be used -- it allows you
9683 * to override the MIME type that would ordinarily be inferred from the
9684 * data with your own type given here.
9685 *
9686 * <p><em>Note: MIME type and Uri scheme matching in the
9687 * Android framework is case-sensitive, unlike the formal RFC definitions.
9688 * As a result, you should always write these elements with lower case letters,
9689 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
9690 * {@link #setDataAndTypeAndNormalize}
9691 * to ensure that they are converted to lower case.</em>
9692 *
9693 * @param data The Uri of the data this intent is now targeting.
9694 * @param type The MIME type of the data being handled by this intent.
9695 *
9696 * @return Returns the same Intent object, for chaining multiple calls
9697 * into a single statement.
9698 *
9699 * @see #setType
9700 * @see #setData
9701 * @see #normalizeMimeType
9702 * @see android.net.Uri#normalizeScheme
9703 * @see #setDataAndTypeAndNormalize
9704 */
9705 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
9706 mData = data;
9707 mType = type;
9708 return this;
9709 }
9710
9711 /**
9712 * (Usually optional) Normalize and set both the data Uri and an explicit
9713 * MIME data type. This method should very rarely be used -- it allows you
9714 * to override the MIME type that would ordinarily be inferred from the
9715 * data with your own type given here.
9716 *
9717 * <p>The data Uri and the MIME type are normalize using
9718 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
9719 * before they are set, so really this is just a convenience method for
9720 * <pre>
9721 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
9722 * </pre>
9723 *
9724 * @param data The Uri of the data this intent is now targeting.
9725 * @param type The MIME type of the data being handled by this intent.
9726 *
9727 * @return Returns the same Intent object, for chaining multiple calls
9728 * into a single statement.
9729 *
9730 * @see #setType
9731 * @see #setData
9732 * @see #setDataAndType
9733 * @see #normalizeMimeType
9734 * @see android.net.Uri#normalizeScheme
9735 */
9736 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
9737 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
9738 }
9739
9740 /**
9741 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent,
9742 * allowing it to be unique from other Intents that would otherwise look the same. In
9743 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two
9744 * Intents are the same as with other fields like {@link #setAction}. However, unlike those
9745 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter};
9746 * it is as if the identifier has not been set on the Intent.
9747 *
9748 * <p>This can be used, for example, to make this Intent unique from other Intents that
9749 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware
9750 * however that the receiver of the PendingIntent will see whatever you put in here.) The
9751 * structure of this string is completely undefined by the platform, however if you are going
9752 * to be exposing identifier strings across different applications you may need to define
9753 * your own structure if there is no central party defining the contents of this field.</p>
9754 *
9755 * @param identifier The identifier for this Intent. The contents of the string have no
9756 * meaning to the system, except whether they are exactly the same as
9757 * another identifier.
9758 *
9759 * @return Returns the same Intent object, for chaining multiple calls
9760 * into a single statement.
9761 *
9762 * @see #getIdentifier
9763 */
9764 public @NonNull Intent setIdentifier(@Nullable String identifier) {
9765 mIdentifier = identifier;
9766 return this;
9767 }
9768
9769 /**
9770 * Add a new category to the intent. Categories provide additional detail
9771 * about the action the intent performs. When resolving an intent, only
9772 * activities that provide <em>all</em> of the requested categories will be
9773 * used.
9774 *
9775 * @param category The desired category. This can be either one of the
9776 * predefined Intent categories, or a custom category in your own
9777 * namespace.
9778 *
9779 * @return Returns the same Intent object, for chaining multiple calls
9780 * into a single statement.
9781 *
9782 * @see #hasCategory
9783 * @see #removeCategory
9784 */
9785 public @NonNull Intent addCategory(String category) {
9786 if (mCategories == null) {
9787 mCategories = new ArraySet<String>();
9788 }
9789 mCategories.add(category.intern());
9790 return this;
9791 }
9792
9793 /**
9794 * Remove a category from an intent.
9795 *
9796 * @param category The category to remove.
9797 *
9798 * @see #addCategory
9799 */
9800 public void removeCategory(String category) {
9801 if (mCategories != null) {
9802 mCategories.remove(category);
9803 if (mCategories.size() == 0) {
9804 mCategories = null;
9805 }
9806 }
9807 }
9808
9809 /**
9810 * Set a selector for this Intent. This is a modification to the kinds of
9811 * things the Intent will match. If the selector is set, it will be used
9812 * when trying to find entities that can handle the Intent, instead of the
9813 * main contents of the Intent. This allows you build an Intent containing
9814 * a generic protocol while targeting it more specifically.
9815 *
9816 * <p>An example of where this may be used is with things like
9817 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
9818 * Intent that will launch the Browser application. However, the correct
9819 * main entry point of an application is actually {@link #ACTION_MAIN}
9820 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
9821 * used to specify the actual Activity to launch. If you launch the browser
9822 * with something different, undesired behavior may happen if the user has
9823 * previously or later launches it the normal way, since they do not match.
9824 * Instead, you can build an Intent with the MAIN action (but no ComponentName
9825 * yet specified) and set a selector with {@link #ACTION_MAIN} and
9826 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
9827 *
9828 * <p>Setting a selector does not impact the behavior of
9829 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
9830 * desired behavior of a selector -- it does not impact the base meaning
9831 * of the Intent, just what kinds of things will be matched against it
9832 * when determining who can handle it.</p>
9833 *
9834 * <p>You can not use both a selector and {@link #setPackage(String)} on
9835 * the same base Intent.</p>
9836 *
9837 * @param selector The desired selector Intent; set to null to not use
9838 * a special selector.
9839 */
9840 public void setSelector(@Nullable Intent selector) {
9841 if (selector == this) {
9842 throw new IllegalArgumentException(
9843 "Intent being set as a selector of itself");
9844 }
9845 if (selector != null && mPackage != null) {
9846 throw new IllegalArgumentException(
9847 "Can't set selector when package name is already set");
9848 }
9849 mSelector = selector;
9850 }
9851
9852 /**
9853 * Set a {@link ClipData} associated with this Intent. This replaces any
9854 * previously set ClipData.
9855 *
9856 * <p>The ClipData in an intent is not used for Intent matching or other
9857 * such operations. Semantically it is like extras, used to transmit
9858 * additional data with the Intent. The main feature of using this over
9859 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
9860 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
9861 * items included in the clip data. This is useful, in particular, if
9862 * you want to transmit an Intent containing multiple <code>content:</code>
9863 * URIs for which the recipient may not have global permission to access the
9864 * content provider.
9865 *
9866 * <p>If the ClipData contains items that are themselves Intents, any
9867 * grant flags in those Intents will be ignored. Only the top-level flags
9868 * of the main Intent are respected, and will be applied to all Uri or
9869 * Intent items in the clip (or sub-items of the clip).
9870 *
9871 * <p>The MIME type, label, and icon in the ClipData object are not
9872 * directly used by Intent. Applications should generally rely on the
9873 * MIME type of the Intent itself, not what it may find in the ClipData.
9874 * A common practice is to construct a ClipData for use with an Intent
9875 * with a MIME type of "*&#47;*".
9876 *
9877 * @param clip The new clip to set. May be null to clear the current clip.
9878 */
9879 public void setClipData(@Nullable ClipData clip) {
9880 mClipData = clip;
9881 }
9882
9883 /**
9884 * This is NOT a secure mechanism to identify the user who sent the intent.
9885 * When the intent is sent to a different user, it is used to fix uris by adding the user ID
9886 * who sent the intent.
9887 * @hide
9888 */
9889 public void prepareToLeaveUser(int userId) {
9890 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
9891 // We want mContentUserHint to refer to the original user, so don't do anything.
9892 if (mContentUserHint == UserHandle.USER_CURRENT) {
9893 mContentUserHint = userId;
9894 }
9895 }
9896
9897 /**
9898 * Add extended data to the intent. The name must include a package
9899 * prefix, for example the app com.android.contacts would use names
9900 * like "com.android.contacts.ShowAll".
9901 *
9902 * @param name The name of the extra data, with package prefix.
9903 * @param value The boolean data value.
9904 *
9905 * @return Returns the same Intent object, for chaining multiple calls
9906 * into a single statement.
9907 *
9908 * @see #putExtras
9909 * @see #removeExtra
9910 * @see #getBooleanExtra(String, boolean)
9911 */
9912 public @NonNull Intent putExtra(String name, boolean value) {
9913 if (mExtras == null) {
9914 mExtras = new Bundle();
9915 }
9916 mExtras.putBoolean(name, value);
9917 return this;
9918 }
9919
9920 /**
9921 * Add extended data to the intent. The name must include a package
9922 * prefix, for example the app com.android.contacts would use names
9923 * like "com.android.contacts.ShowAll".
9924 *
9925 * @param name The name of the extra data, with package prefix.
9926 * @param value The byte data value.
9927 *
9928 * @return Returns the same Intent object, for chaining multiple calls
9929 * into a single statement.
9930 *
9931 * @see #putExtras
9932 * @see #removeExtra
9933 * @see #getByteExtra(String, byte)
9934 */
9935 public @NonNull Intent putExtra(String name, byte value) {
9936 if (mExtras == null) {
9937 mExtras = new Bundle();
9938 }
9939 mExtras.putByte(name, value);
9940 return this;
9941 }
9942
9943 /**
9944 * Add extended data to the intent. The name must include a package
9945 * prefix, for example the app com.android.contacts would use names
9946 * like "com.android.contacts.ShowAll".
9947 *
9948 * @param name The name of the extra data, with package prefix.
9949 * @param value The char data value.
9950 *
9951 * @return Returns the same Intent object, for chaining multiple calls
9952 * into a single statement.
9953 *
9954 * @see #putExtras
9955 * @see #removeExtra
9956 * @see #getCharExtra(String, char)
9957 */
9958 public @NonNull Intent putExtra(String name, char value) {
9959 if (mExtras == null) {
9960 mExtras = new Bundle();
9961 }
9962 mExtras.putChar(name, value);
9963 return this;
9964 }
9965
9966 /**
9967 * Add extended data to the intent. The name must include a package
9968 * prefix, for example the app com.android.contacts would use names
9969 * like "com.android.contacts.ShowAll".
9970 *
9971 * @param name The name of the extra data, with package prefix.
9972 * @param value The short data value.
9973 *
9974 * @return Returns the same Intent object, for chaining multiple calls
9975 * into a single statement.
9976 *
9977 * @see #putExtras
9978 * @see #removeExtra
9979 * @see #getShortExtra(String, short)
9980 */
9981 public @NonNull Intent putExtra(String name, short value) {
9982 if (mExtras == null) {
9983 mExtras = new Bundle();
9984 }
9985 mExtras.putShort(name, value);
9986 return this;
9987 }
9988
9989 /**
9990 * Add extended data to the intent. The name must include a package
9991 * prefix, for example the app com.android.contacts would use names
9992 * like "com.android.contacts.ShowAll".
9993 *
9994 * @param name The name of the extra data, with package prefix.
9995 * @param value The integer data value.
9996 *
9997 * @return Returns the same Intent object, for chaining multiple calls
9998 * into a single statement.
9999 *
10000 * @see #putExtras
10001 * @see #removeExtra
10002 * @see #getIntExtra(String, int)
10003 */
10004 public @NonNull Intent putExtra(String name, int value) {
10005 if (mExtras == null) {
10006 mExtras = new Bundle();
10007 }
10008 mExtras.putInt(name, value);
10009 return this;
10010 }
10011
10012 /**
10013 * Add extended data to the intent. The name must include a package
10014 * prefix, for example the app com.android.contacts would use names
10015 * like "com.android.contacts.ShowAll".
10016 *
10017 * @param name The name of the extra data, with package prefix.
10018 * @param value The long data value.
10019 *
10020 * @return Returns the same Intent object, for chaining multiple calls
10021 * into a single statement.
10022 *
10023 * @see #putExtras
10024 * @see #removeExtra
10025 * @see #getLongExtra(String, long)
10026 */
10027 public @NonNull Intent putExtra(String name, long value) {
10028 if (mExtras == null) {
10029 mExtras = new Bundle();
10030 }
10031 mExtras.putLong(name, value);
10032 return this;
10033 }
10034
10035 /**
10036 * Add extended data to the intent. The name must include a package
10037 * prefix, for example the app com.android.contacts would use names
10038 * like "com.android.contacts.ShowAll".
10039 *
10040 * @param name The name of the extra data, with package prefix.
10041 * @param value The float data value.
10042 *
10043 * @return Returns the same Intent object, for chaining multiple calls
10044 * into a single statement.
10045 *
10046 * @see #putExtras
10047 * @see #removeExtra
10048 * @see #getFloatExtra(String, float)
10049 */
10050 public @NonNull Intent putExtra(String name, float value) {
10051 if (mExtras == null) {
10052 mExtras = new Bundle();
10053 }
10054 mExtras.putFloat(name, value);
10055 return this;
10056 }
10057
10058 /**
10059 * Add extended data to the intent. The name must include a package
10060 * prefix, for example the app com.android.contacts would use names
10061 * like "com.android.contacts.ShowAll".
10062 *
10063 * @param name The name of the extra data, with package prefix.
10064 * @param value The double data value.
10065 *
10066 * @return Returns the same Intent object, for chaining multiple calls
10067 * into a single statement.
10068 *
10069 * @see #putExtras
10070 * @see #removeExtra
10071 * @see #getDoubleExtra(String, double)
10072 */
10073 public @NonNull Intent putExtra(String name, double value) {
10074 if (mExtras == null) {
10075 mExtras = new Bundle();
10076 }
10077 mExtras.putDouble(name, value);
10078 return this;
10079 }
10080
10081 /**
10082 * Add extended data to the intent. The name must include a package
10083 * prefix, for example the app com.android.contacts would use names
10084 * like "com.android.contacts.ShowAll".
10085 *
10086 * @param name The name of the extra data, with package prefix.
10087 * @param value The String data value.
10088 *
10089 * @return Returns the same Intent object, for chaining multiple calls
10090 * into a single statement.
10091 *
10092 * @see #putExtras
10093 * @see #removeExtra
10094 * @see #getStringExtra(String)
10095 */
10096 public @NonNull Intent putExtra(String name, @Nullable String value) {
10097 if (mExtras == null) {
10098 mExtras = new Bundle();
10099 }
10100 mExtras.putString(name, value);
10101 return this;
10102 }
10103
10104 /**
10105 * Add extended data to the intent. The name must include a package
10106 * prefix, for example the app com.android.contacts would use names
10107 * like "com.android.contacts.ShowAll".
10108 *
10109 * @param name The name of the extra data, with package prefix.
10110 * @param value The CharSequence data value.
10111 *
10112 * @return Returns the same Intent object, for chaining multiple calls
10113 * into a single statement.
10114 *
10115 * @see #putExtras
10116 * @see #removeExtra
10117 * @see #getCharSequenceExtra(String)
10118 */
10119 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
10120 if (mExtras == null) {
10121 mExtras = new Bundle();
10122 }
10123 mExtras.putCharSequence(name, value);
10124 return this;
10125 }
10126
10127 /**
10128 * Add extended data to the intent. The name must include a package
10129 * prefix, for example the app com.android.contacts would use names
10130 * like "com.android.contacts.ShowAll".
10131 *
10132 * @param name The name of the extra data, with package prefix.
10133 * @param value The Parcelable data value.
10134 *
10135 * @return Returns the same Intent object, for chaining multiple calls
10136 * into a single statement.
10137 *
10138 * @see #putExtras
10139 * @see #removeExtra
10140 * @see #getParcelableExtra(String)
10141 */
10142 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
10143 if (mExtras == null) {
10144 mExtras = new Bundle();
10145 }
10146 mExtras.putParcelable(name, value);
10147 return this;
10148 }
10149
10150 /**
10151 * Add extended data to the intent. The name must include a package
10152 * prefix, for example the app com.android.contacts would use names
10153 * like "com.android.contacts.ShowAll".
10154 *
10155 * @param name The name of the extra data, with package prefix.
10156 * @param value The Parcelable[] data value.
10157 *
10158 * @return Returns the same Intent object, for chaining multiple calls
10159 * into a single statement.
10160 *
10161 * @see #putExtras
10162 * @see #removeExtra
10163 * @see #getParcelableArrayExtra(String)
10164 */
10165 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
10166 if (mExtras == null) {
10167 mExtras = new Bundle();
10168 }
10169 mExtras.putParcelableArray(name, value);
10170 return this;
10171 }
10172
10173 /**
10174 * Add extended data to the intent. The name must include a package
10175 * prefix, for example the app com.android.contacts would use names
10176 * like "com.android.contacts.ShowAll".
10177 *
10178 * @param name The name of the extra data, with package prefix.
10179 * @param value The ArrayList<Parcelable> data value.
10180 *
10181 * @return Returns the same Intent object, for chaining multiple calls
10182 * into a single statement.
10183 *
10184 * @see #putExtras
10185 * @see #removeExtra
10186 * @see #getParcelableArrayListExtra(String)
10187 */
10188 public @NonNull Intent putParcelableArrayListExtra(String name,
10189 @Nullable ArrayList<? extends Parcelable> value) {
10190 if (mExtras == null) {
10191 mExtras = new Bundle();
10192 }
10193 mExtras.putParcelableArrayList(name, value);
10194 return this;
10195 }
10196
10197 /**
10198 * Add extended data to the intent. The name must include a package
10199 * prefix, for example the app com.android.contacts would use names
10200 * like "com.android.contacts.ShowAll".
10201 *
10202 * @param name The name of the extra data, with package prefix.
10203 * @param value The ArrayList<Integer> data value.
10204 *
10205 * @return Returns the same Intent object, for chaining multiple calls
10206 * into a single statement.
10207 *
10208 * @see #putExtras
10209 * @see #removeExtra
10210 * @see #getIntegerArrayListExtra(String)
10211 */
10212 public @NonNull Intent putIntegerArrayListExtra(String name,
10213 @Nullable ArrayList<Integer> value) {
10214 if (mExtras == null) {
10215 mExtras = new Bundle();
10216 }
10217 mExtras.putIntegerArrayList(name, value);
10218 return this;
10219 }
10220
10221 /**
10222 * Add extended data to the intent. The name must include a package
10223 * prefix, for example the app com.android.contacts would use names
10224 * like "com.android.contacts.ShowAll".
10225 *
10226 * @param name The name of the extra data, with package prefix.
10227 * @param value The ArrayList<String> data value.
10228 *
10229 * @return Returns the same Intent object, for chaining multiple calls
10230 * into a single statement.
10231 *
10232 * @see #putExtras
10233 * @see #removeExtra
10234 * @see #getStringArrayListExtra(String)
10235 */
10236 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
10237 if (mExtras == null) {
10238 mExtras = new Bundle();
10239 }
10240 mExtras.putStringArrayList(name, value);
10241 return this;
10242 }
10243
10244 /**
10245 * Add extended data to the intent. The name must include a package
10246 * prefix, for example the app com.android.contacts would use names
10247 * like "com.android.contacts.ShowAll".
10248 *
10249 * @param name The name of the extra data, with package prefix.
10250 * @param value The ArrayList<CharSequence> data value.
10251 *
10252 * @return Returns the same Intent object, for chaining multiple calls
10253 * into a single statement.
10254 *
10255 * @see #putExtras
10256 * @see #removeExtra
10257 * @see #getCharSequenceArrayListExtra(String)
10258 */
10259 public @NonNull Intent putCharSequenceArrayListExtra(String name,
10260 @Nullable ArrayList<CharSequence> value) {
10261 if (mExtras == null) {
10262 mExtras = new Bundle();
10263 }
10264 mExtras.putCharSequenceArrayList(name, value);
10265 return this;
10266 }
10267
10268 /**
10269 * Add extended data to the intent. The name must include a package
10270 * prefix, for example the app com.android.contacts would use names
10271 * like "com.android.contacts.ShowAll".
10272 *
10273 * @param name The name of the extra data, with package prefix.
10274 * @param value The Serializable data value.
10275 *
10276 * @return Returns the same Intent object, for chaining multiple calls
10277 * into a single statement.
10278 *
10279 * @see #putExtras
10280 * @see #removeExtra
10281 * @see #getSerializableExtra(String)
10282 */
10283 public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
10284 if (mExtras == null) {
10285 mExtras = new Bundle();
10286 }
10287 mExtras.putSerializable(name, value);
10288 return this;
10289 }
10290
10291 /**
10292 * Add extended data to the intent. The name must include a package
10293 * prefix, for example the app com.android.contacts would use names
10294 * like "com.android.contacts.ShowAll".
10295 *
10296 * @param name The name of the extra data, with package prefix.
10297 * @param value The boolean array data value.
10298 *
10299 * @return Returns the same Intent object, for chaining multiple calls
10300 * into a single statement.
10301 *
10302 * @see #putExtras
10303 * @see #removeExtra
10304 * @see #getBooleanArrayExtra(String)
10305 */
10306 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
10307 if (mExtras == null) {
10308 mExtras = new Bundle();
10309 }
10310 mExtras.putBooleanArray(name, value);
10311 return this;
10312 }
10313
10314 /**
10315 * Add extended data to the intent. The name must include a package
10316 * prefix, for example the app com.android.contacts would use names
10317 * like "com.android.contacts.ShowAll".
10318 *
10319 * @param name The name of the extra data, with package prefix.
10320 * @param value The byte array data value.
10321 *
10322 * @return Returns the same Intent object, for chaining multiple calls
10323 * into a single statement.
10324 *
10325 * @see #putExtras
10326 * @see #removeExtra
10327 * @see #getByteArrayExtra(String)
10328 */
10329 public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
10330 if (mExtras == null) {
10331 mExtras = new Bundle();
10332 }
10333 mExtras.putByteArray(name, value);
10334 return this;
10335 }
10336
10337 /**
10338 * Add extended data to the intent. The name must include a package
10339 * prefix, for example the app com.android.contacts would use names
10340 * like "com.android.contacts.ShowAll".
10341 *
10342 * @param name The name of the extra data, with package prefix.
10343 * @param value The short array data value.
10344 *
10345 * @return Returns the same Intent object, for chaining multiple calls
10346 * into a single statement.
10347 *
10348 * @see #putExtras
10349 * @see #removeExtra
10350 * @see #getShortArrayExtra(String)
10351 */
10352 public @NonNull Intent putExtra(String name, @Nullable short[] value) {
10353 if (mExtras == null) {
10354 mExtras = new Bundle();
10355 }
10356 mExtras.putShortArray(name, value);
10357 return this;
10358 }
10359
10360 /**
10361 * Add extended data to the intent. The name must include a package
10362 * prefix, for example the app com.android.contacts would use names
10363 * like "com.android.contacts.ShowAll".
10364 *
10365 * @param name The name of the extra data, with package prefix.
10366 * @param value The char array data value.
10367 *
10368 * @return Returns the same Intent object, for chaining multiple calls
10369 * into a single statement.
10370 *
10371 * @see #putExtras
10372 * @see #removeExtra
10373 * @see #getCharArrayExtra(String)
10374 */
10375 public @NonNull Intent putExtra(String name, @Nullable char[] value) {
10376 if (mExtras == null) {
10377 mExtras = new Bundle();
10378 }
10379 mExtras.putCharArray(name, value);
10380 return this;
10381 }
10382
10383 /**
10384 * Add extended data to the intent. The name must include a package
10385 * prefix, for example the app com.android.contacts would use names
10386 * like "com.android.contacts.ShowAll".
10387 *
10388 * @param name The name of the extra data, with package prefix.
10389 * @param value The int array data value.
10390 *
10391 * @return Returns the same Intent object, for chaining multiple calls
10392 * into a single statement.
10393 *
10394 * @see #putExtras
10395 * @see #removeExtra
10396 * @see #getIntArrayExtra(String)
10397 */
10398 public @NonNull Intent putExtra(String name, @Nullable int[] value) {
10399 if (mExtras == null) {
10400 mExtras = new Bundle();
10401 }
10402 mExtras.putIntArray(name, value);
10403 return this;
10404 }
10405
10406 /**
10407 * Add extended data to the intent. The name must include a package
10408 * prefix, for example the app com.android.contacts would use names
10409 * like "com.android.contacts.ShowAll".
10410 *
10411 * @param name The name of the extra data, with package prefix.
10412 * @param value The byte array data value.
10413 *
10414 * @return Returns the same Intent object, for chaining multiple calls
10415 * into a single statement.
10416 *
10417 * @see #putExtras
10418 * @see #removeExtra
10419 * @see #getLongArrayExtra(String)
10420 */
10421 public @NonNull Intent putExtra(String name, @Nullable long[] value) {
10422 if (mExtras == null) {
10423 mExtras = new Bundle();
10424 }
10425 mExtras.putLongArray(name, value);
10426 return this;
10427 }
10428
10429 /**
10430 * Add extended data to the intent. The name must include a package
10431 * prefix, for example the app com.android.contacts would use names
10432 * like "com.android.contacts.ShowAll".
10433 *
10434 * @param name The name of the extra data, with package prefix.
10435 * @param value The float array data value.
10436 *
10437 * @return Returns the same Intent object, for chaining multiple calls
10438 * into a single statement.
10439 *
10440 * @see #putExtras
10441 * @see #removeExtra
10442 * @see #getFloatArrayExtra(String)
10443 */
10444 public @NonNull Intent putExtra(String name, @Nullable float[] value) {
10445 if (mExtras == null) {
10446 mExtras = new Bundle();
10447 }
10448 mExtras.putFloatArray(name, value);
10449 return this;
10450 }
10451
10452 /**
10453 * Add extended data to the intent. The name must include a package
10454 * prefix, for example the app com.android.contacts would use names
10455 * like "com.android.contacts.ShowAll".
10456 *
10457 * @param name The name of the extra data, with package prefix.
10458 * @param value The double array data value.
10459 *
10460 * @return Returns the same Intent object, for chaining multiple calls
10461 * into a single statement.
10462 *
10463 * @see #putExtras
10464 * @see #removeExtra
10465 * @see #getDoubleArrayExtra(String)
10466 */
10467 public @NonNull Intent putExtra(String name, @Nullable double[] value) {
10468 if (mExtras == null) {
10469 mExtras = new Bundle();
10470 }
10471 mExtras.putDoubleArray(name, value);
10472 return this;
10473 }
10474
10475 /**
10476 * Add extended data to the intent. The name must include a package
10477 * prefix, for example the app com.android.contacts would use names
10478 * like "com.android.contacts.ShowAll".
10479 *
10480 * @param name The name of the extra data, with package prefix.
10481 * @param value The String array data value.
10482 *
10483 * @return Returns the same Intent object, for chaining multiple calls
10484 * into a single statement.
10485 *
10486 * @see #putExtras
10487 * @see #removeExtra
10488 * @see #getStringArrayExtra(String)
10489 */
10490 public @NonNull Intent putExtra(String name, @Nullable String[] value) {
10491 if (mExtras == null) {
10492 mExtras = new Bundle();
10493 }
10494 mExtras.putStringArray(name, value);
10495 return this;
10496 }
10497
10498 /**
10499 * Add extended data to the intent. The name must include a package
10500 * prefix, for example the app com.android.contacts would use names
10501 * like "com.android.contacts.ShowAll".
10502 *
10503 * @param name The name of the extra data, with package prefix.
10504 * @param value The CharSequence array data value.
10505 *
10506 * @return Returns the same Intent object, for chaining multiple calls
10507 * into a single statement.
10508 *
10509 * @see #putExtras
10510 * @see #removeExtra
10511 * @see #getCharSequenceArrayExtra(String)
10512 */
10513 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
10514 if (mExtras == null) {
10515 mExtras = new Bundle();
10516 }
10517 mExtras.putCharSequenceArray(name, value);
10518 return this;
10519 }
10520
10521 /**
10522 * Add extended data to the intent. The name must include a package
10523 * prefix, for example the app com.android.contacts would use names
10524 * like "com.android.contacts.ShowAll".
10525 *
10526 * @param name The name of the extra data, with package prefix.
10527 * @param value The Bundle data value.
10528 *
10529 * @return Returns the same Intent object, for chaining multiple calls
10530 * into a single statement.
10531 *
10532 * @see #putExtras
10533 * @see #removeExtra
10534 * @see #getBundleExtra(String)
10535 */
10536 public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
10537 if (mExtras == null) {
10538 mExtras = new Bundle();
10539 }
10540 mExtras.putBundle(name, value);
10541 return this;
10542 }
10543
10544 /**
10545 * Add extended data to the intent. The name must include a package
10546 * prefix, for example the app com.android.contacts would use names
10547 * like "com.android.contacts.ShowAll".
10548 *
10549 * @param name The name of the extra data, with package prefix.
10550 * @param value The IBinder data value.
10551 *
10552 * @return Returns the same Intent object, for chaining multiple calls
10553 * into a single statement.
10554 *
10555 * @see #putExtras
10556 * @see #removeExtra
10557 * @see #getIBinderExtra(String)
10558 *
10559 * @deprecated
10560 * @hide
10561 */
10562 @Deprecated
10563 @UnsupportedAppUsage
10564 public @NonNull Intent putExtra(String name, IBinder value) {
10565 if (mExtras == null) {
10566 mExtras = new Bundle();
10567 }
10568 mExtras.putIBinder(name, value);
10569 return this;
10570 }
10571
10572 /**
10573 * Copy all extras in 'src' in to this intent.
10574 *
10575 * @param src Contains the extras to copy.
10576 *
10577 * @see #putExtra
10578 */
10579 public @NonNull Intent putExtras(@NonNull Intent src) {
10580 if (src.mExtras != null) {
10581 if (mExtras == null) {
10582 mExtras = new Bundle(src.mExtras);
10583 } else {
10584 mExtras.putAll(src.mExtras);
10585 }
10586 }
10587 // If the provided Intent was unparceled and this is not an Intent delivered to a protected
10588 // component then mark the extras as unfiltered. An Intent delivered to a protected
10589 // component had to come from a trusted component, and if unfiltered data was copied to the
10590 // delivered Intent then it would have been reported when that Intent left the sending
10591 // process.
10592 if ((src.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0
10593 && (src.mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) {
10594 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS;
10595 }
10596 return this;
10597 }
10598
10599 /**
10600 * Add a set of extended data to the intent. The keys must include a package
10601 * prefix, for example the app com.android.contacts would use names
10602 * like "com.android.contacts.ShowAll".
10603 *
10604 * @param extras The Bundle of extras to add to this intent.
10605 *
10606 * @see #putExtra
10607 * @see #removeExtra
10608 */
10609 public @NonNull Intent putExtras(@NonNull Bundle extras) {
10610 // If the provided Bundle has not yet been unparceled then treat this as unfiltered extras.
10611 if (extras.isParcelled()) {
10612 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS;
10613 }
10614 if (mExtras == null) {
10615 mExtras = new Bundle();
10616 }
10617 mExtras.putAll(extras);
10618 return this;
10619 }
10620
10621 /**
10622 * Completely replace the extras in the Intent with the extras in the
10623 * given Intent.
10624 *
10625 * @param src The exact extras contained in this Intent are copied
10626 * into the target intent, replacing any that were previously there.
10627 */
10628 public @NonNull Intent replaceExtras(@NonNull Intent src) {
10629 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
10630 return this;
10631 }
10632
10633 /**
10634 * Completely replace the extras in the Intent with the given Bundle of
10635 * extras.
10636 *
10637 * @param extras The new set of extras in the Intent, or null to erase
10638 * all extras.
10639 */
10640 public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
10641 mExtras = extras != null ? new Bundle(extras) : null;
10642 return this;
10643 }
10644
10645 /**
10646 * Remove extended data from the intent.
10647 *
10648 * @see #putExtra
10649 */
10650 public void removeExtra(String name) {
10651 if (mExtras != null) {
10652 mExtras.remove(name);
10653 if (mExtras.size() == 0) {
10654 mExtras = null;
10655 }
10656 }
10657 }
10658
10659 /**
10660 * Set special flags controlling how this intent is handled. Most values
10661 * here depend on the type of component being executed by the Intent,
10662 * specifically the FLAG_ACTIVITY_* flags are all for use with
10663 * {@link Context#startActivity Context.startActivity()} and the
10664 * FLAG_RECEIVER_* flags are all for use with
10665 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
10666 *
10667 * <p>See the
10668 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
10669 * Stack</a> documentation for important information on how some of these options impact
10670 * the behavior of your application.
10671 *
10672 * @param flags The desired flags.
10673 * @return Returns the same Intent object, for chaining multiple calls
10674 * into a single statement.
10675 * @see #getFlags
10676 * @see #addFlags
10677 * @see #removeFlags
10678 */
10679 public @NonNull Intent setFlags(@Flags int flags) {
10680 mFlags = flags;
10681 return this;
10682 }
10683
10684 /**
10685 * Add additional flags to the intent (or with existing flags value).
10686 *
10687 * @param flags The new flags to set.
10688 * @return Returns the same Intent object, for chaining multiple calls into
10689 * a single statement.
10690 * @see #setFlags
10691 * @see #getFlags
10692 * @see #removeFlags
10693 */
10694 public @NonNull Intent addFlags(@Flags int flags) {
10695 mFlags |= flags;
10696 return this;
10697 }
10698
10699 /**
10700 * Remove these flags from the intent.
10701 *
10702 * @param flags The flags to remove.
10703 * @see #setFlags
10704 * @see #getFlags
10705 * @see #addFlags
10706 */
10707 public void removeFlags(@Flags int flags) {
10708 mFlags &= ~flags;
10709 }
10710
10711 /**
10712 * (Usually optional) Set an explicit application package name that limits
10713 * the components this Intent will resolve to. If left to the default
10714 * value of null, all components in all applications will considered.
10715 * If non-null, the Intent can only match the components in the given
10716 * application package.
10717 *
10718 * @param packageName The name of the application package to handle the
10719 * intent, or null to allow any application package.
10720 *
10721 * @return Returns the same Intent object, for chaining multiple calls
10722 * into a single statement.
10723 *
10724 * @see #getPackage
10725 * @see #resolveActivity
10726 */
10727 public @NonNull Intent setPackage(@Nullable String packageName) {
10728 if (packageName != null && mSelector != null) {
10729 throw new IllegalArgumentException(
10730 "Can't set package name when selector is already set");
10731 }
10732 mPackage = packageName;
10733 return this;
10734 }
10735
10736 /**
10737 * (Usually optional) Explicitly set the component to handle the intent.
10738 * If left with the default value of null, the system will determine the
10739 * appropriate class to use based on the other fields (action, data,
10740 * type, categories) in the Intent. If this class is defined, the
10741 * specified class will always be used regardless of the other fields. You
10742 * should only set this value when you know you absolutely want a specific
10743 * class to be used; otherwise it is better to let the system find the
10744 * appropriate class so that you will respect the installed applications
10745 * and user preferences.
10746 *
10747 * @param component The name of the application component to handle the
10748 * intent, or null to let the system find one for you.
10749 *
10750 * @return Returns the same Intent object, for chaining multiple calls
10751 * into a single statement.
10752 *
10753 * @see #setClass
10754 * @see #setClassName(Context, String)
10755 * @see #setClassName(String, String)
10756 * @see #getComponent
10757 * @see #resolveActivity
10758 */
10759 public @NonNull Intent setComponent(@Nullable ComponentName component) {
10760 mComponent = component;
10761 return this;
10762 }
10763
10764 /**
10765 * Convenience for calling {@link #setComponent} with an
10766 * explicit class name.
10767 *
10768 * @param packageContext A Context of the application package implementing
10769 * this class.
10770 * @param className The name of a class inside of the application package
10771 * that will be used as the component for this Intent.
10772 *
10773 * @return Returns the same Intent object, for chaining multiple calls
10774 * into a single statement.
10775 *
10776 * @see #setComponent
10777 * @see #setClass
10778 */
10779 public @NonNull Intent setClassName(@NonNull Context packageContext,
10780 @NonNull String className) {
10781 mComponent = new ComponentName(packageContext, className);
10782 return this;
10783 }
10784
10785 /**
10786 * Convenience for calling {@link #setComponent} with an
10787 * explicit application package name and class name.
10788 *
10789 * @param packageName The name of the package implementing the desired
10790 * component.
10791 * @param className The name of a class inside of the application package
10792 * that will be used as the component for this Intent.
10793 *
10794 * @return Returns the same Intent object, for chaining multiple calls
10795 * into a single statement.
10796 *
10797 * @see #setComponent
10798 * @see #setClass
10799 */
10800 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
10801 mComponent = new ComponentName(packageName, className);
10802 return this;
10803 }
10804
10805 /**
10806 * Convenience for calling {@link #setComponent(ComponentName)} with the
10807 * name returned by a {@link Class} object.
10808 *
10809 * @param packageContext A Context of the application package implementing
10810 * this class.
10811 * @param cls The class name to set, equivalent to
10812 * <code>setClassName(context, cls.getName())</code>.
10813 *
10814 * @return Returns the same Intent object, for chaining multiple calls
10815 * into a single statement.
10816 *
10817 * @see #setComponent
10818 */
10819 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
10820 mComponent = new ComponentName(packageContext, cls);
10821 return this;
10822 }
10823
10824 /**
10825 * Set the bounds of the sender of this intent, in screen coordinates. This can be
10826 * used as a hint to the receiver for animations and the like. Null means that there
10827 * is no source bounds.
10828 */
10829 public void setSourceBounds(@Nullable Rect r) {
10830 if (r != null) {
10831 mSourceBounds = new Rect(r);
10832 } else {
10833 mSourceBounds = null;
10834 }
10835 }
10836
10837 /** @hide */
10838 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
10839 FILL_IN_ACTION,
10840 FILL_IN_DATA,
10841 FILL_IN_CATEGORIES,
10842 FILL_IN_COMPONENT,
10843 FILL_IN_PACKAGE,
10844 FILL_IN_SOURCE_BOUNDS,
10845 FILL_IN_SELECTOR,
10846 FILL_IN_CLIP_DATA
10847 })
10848 @Retention(RetentionPolicy.SOURCE)
10849 public @interface FillInFlags {}
10850
10851 /**
10852 * Use with {@link #fillIn} to allow the current action value to be
10853 * overwritten, even if it is already set.
10854 */
10855 public static final int FILL_IN_ACTION = 1<<0;
10856
10857 /**
10858 * Use with {@link #fillIn} to allow the current data or type value
10859 * overwritten, even if it is already set.
10860 */
10861 public static final int FILL_IN_DATA = 1<<1;
10862
10863 /**
10864 * Use with {@link #fillIn} to allow the current categories to be
10865 * overwritten, even if they are already set.
10866 */
10867 public static final int FILL_IN_CATEGORIES = 1<<2;
10868
10869 /**
10870 * Use with {@link #fillIn} to allow the current component value to be
10871 * overwritten, even if it is already set.
10872 */
10873 public static final int FILL_IN_COMPONENT = 1<<3;
10874
10875 /**
10876 * Use with {@link #fillIn} to allow the current package value to be
10877 * overwritten, even if it is already set.
10878 */
10879 public static final int FILL_IN_PACKAGE = 1<<4;
10880
10881 /**
10882 * Use with {@link #fillIn} to allow the current bounds rectangle to be
10883 * overwritten, even if it is already set.
10884 */
10885 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
10886
10887 /**
10888 * Use with {@link #fillIn} to allow the current selector to be
10889 * overwritten, even if it is already set.
10890 */
10891 public static final int FILL_IN_SELECTOR = 1<<6;
10892
10893 /**
10894 * Use with {@link #fillIn} to allow the current ClipData to be
10895 * overwritten, even if it is already set.
10896 */
10897 public static final int FILL_IN_CLIP_DATA = 1<<7;
10898
10899 /**
10900 * Use with {@link #fillIn} to allow the current identifier value to be
10901 * overwritten, even if it is already set.
10902 */
10903 public static final int FILL_IN_IDENTIFIER = 1<<8;
10904
10905 /**
10906 * Copy the contents of <var>other</var> in to this object, but only
10907 * where fields are not defined by this object. For purposes of a field
10908 * being defined, the following pieces of data in the Intent are
10909 * considered to be separate fields:
10910 *
10911 * <ul>
10912 * <li> action, as set by {@link #setAction}.
10913 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
10914 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
10915 * <li> identifier, as set by {@link #setIdentifier}.
10916 * <li> categories, as set by {@link #addCategory}.
10917 * <li> package, as set by {@link #setPackage}.
10918 * <li> component, as set by {@link #setComponent(ComponentName)} or
10919 * related methods.
10920 * <li> source bounds, as set by {@link #setSourceBounds}.
10921 * <li> selector, as set by {@link #setSelector(Intent)}.
10922 * <li> clip data, as set by {@link #setClipData(ClipData)}.
10923 * <li> each top-level name in the associated extras.
10924 * </ul>
10925 *
10926 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
10927 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES},
10928 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10929 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
10930 * the restriction where the corresponding field will not be replaced if
10931 * it is already set.
10932 *
10933 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
10934 * is explicitly specified. The selector will only be copied if
10935 * {@link #FILL_IN_SELECTOR} is explicitly specified.
10936 *
10937 * <p>For example, consider Intent A with {data="foo", categories="bar"}
10938 * and Intent B with {action="gotit", data-type="some/thing",
10939 * categories="one","two"}.
10940 *
10941 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
10942 * containing: {action="gotit", data-type="some/thing",
10943 * categories="bar"}.
10944 *
10945 * @param other Another Intent whose values are to be used to fill in
10946 * the current one.
10947 * @param flags Options to control which fields can be filled in.
10948 *
10949 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
10950 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
10951 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10952 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
10953 * changed.
10954 */
10955 @FillInFlags
10956 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
10957 int changes = 0;
10958 boolean mayHaveCopiedUris = false;
10959 if (other.mAction != null
10960 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
10961 mAction = other.mAction;
10962 changes |= FILL_IN_ACTION;
10963 }
10964 if ((other.mData != null || other.mType != null)
10965 && ((mData == null && mType == null)
10966 || (flags&FILL_IN_DATA) != 0)) {
10967 mData = other.mData;
10968 mType = other.mType;
10969 changes |= FILL_IN_DATA;
10970 mayHaveCopiedUris = true;
10971 }
10972 if (other.mIdentifier != null
10973 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) {
10974 mIdentifier = other.mIdentifier;
10975 changes |= FILL_IN_IDENTIFIER;
10976 }
10977 if (other.mCategories != null
10978 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
10979 if (other.mCategories != null) {
10980 mCategories = new ArraySet<String>(other.mCategories);
10981 }
10982 changes |= FILL_IN_CATEGORIES;
10983 }
10984 if (other.mPackage != null
10985 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
10986 // Only do this if mSelector is not set.
10987 if (mSelector == null) {
10988 mPackage = other.mPackage;
10989 changes |= FILL_IN_PACKAGE;
10990 }
10991 }
10992 // Selector is special: it can only be set if explicitly allowed,
10993 // for the same reason as the component name.
10994 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
10995 if (mPackage == null) {
10996 mSelector = new Intent(other.mSelector);
10997 mPackage = null;
10998 changes |= FILL_IN_SELECTOR;
10999 }
11000 }
11001 if (other.mClipData != null
11002 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
11003 mClipData = other.mClipData;
11004 changes |= FILL_IN_CLIP_DATA;
11005 mayHaveCopiedUris = true;
11006 }
11007 // Component is special: it can -only- be set if explicitly allowed,
11008 // since otherwise the sender could force the intent somewhere the
11009 // originator didn't intend.
11010 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
11011 mComponent = other.mComponent;
11012 changes |= FILL_IN_COMPONENT;
11013 }
11014 mFlags |= other.mFlags;
11015 if (other.mSourceBounds != null
11016 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
11017 mSourceBounds = new Rect(other.mSourceBounds);
11018 changes |= FILL_IN_SOURCE_BOUNDS;
11019 }
11020 if (mExtras == null) {
11021 if (other.mExtras != null) {
11022 mExtras = new Bundle(other.mExtras);
11023 mayHaveCopiedUris = true;
11024 }
11025 } else if (other.mExtras != null) {
11026 try {
11027 Bundle newb = new Bundle(other.mExtras);
11028 newb.putAll(mExtras);
11029 mExtras = newb;
11030 mayHaveCopiedUris = true;
11031 } catch (RuntimeException e) {
11032 // Modifying the extras can cause us to unparcel the contents
11033 // of the bundle, and if we do this in the system process that
11034 // may fail. We really should handle this (i.e., the Bundle
11035 // impl shouldn't be on top of a plain map), but for now just
11036 // ignore it and keep the original contents. :(
11037 Log.w(TAG, "Failure filling in extras", e);
11038 }
11039 }
11040 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
11041 && other.mContentUserHint != UserHandle.USER_CURRENT) {
11042 mContentUserHint = other.mContentUserHint;
11043 }
11044 return changes;
11045 }
11046
11047 /**
11048 * Wrapper class holding an Intent and implementing comparisons on it for
11049 * the purpose of filtering. The class implements its
11050 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
11051 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
11052 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
11053 * on the wrapped Intent.
11054 */
11055 public static final class FilterComparison {
11056 private final Intent mIntent;
11057 private final int mHashCode;
11058
11059 public FilterComparison(Intent intent) {
11060 mIntent = intent;
11061 mHashCode = intent.filterHashCode();
11062 }
11063
11064 /**
11065 * Return the Intent that this FilterComparison represents.
11066 * @return Returns the Intent held by the FilterComparison. Do
11067 * not modify!
11068 */
11069 public Intent getIntent() {
11070 return mIntent;
11071 }
11072
11073 @Override
11074 public boolean equals(@Nullable Object obj) {
11075 if (obj instanceof FilterComparison) {
11076 Intent other = ((FilterComparison)obj).mIntent;
11077 return mIntent.filterEquals(other);
11078 }
11079 return false;
11080 }
11081
11082 @Override
11083 public int hashCode() {
11084 return mHashCode;
11085 }
11086 }
11087
11088 /**
11089 * Determine if two intents are the same for the purposes of intent
11090 * resolution (filtering). That is, if their action, data, type, identity,
11091 * class, and categories are the same. This does <em>not</em> compare
11092 * any extra data included in the intents. Note that technically when actually
11093 * matching against an {@link IntentFilter} the identifier is ignored, while here
11094 * it is directly compared for equality like the other fields.
11095 *
11096 * @param other The other Intent to compare against.
11097 *
11098 * @return Returns true if action, data, type, class, and categories
11099 * are the same.
11100 */
11101 public boolean filterEquals(Intent other) {
11102 if (other == null) {
11103 return false;
11104 }
11105 if (!Objects.equals(this.mAction, other.mAction)) return false;
11106 if (!Objects.equals(this.mData, other.mData)) return false;
11107 if (!Objects.equals(this.mType, other.mType)) return false;
11108 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false;
11109 if (!(this.hasPackageEquivalentComponent() && other.hasPackageEquivalentComponent())
11110 && !Objects.equals(this.mPackage, other.mPackage)) {
11111 return false;
11112 }
11113 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
11114 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
11115
11116 return true;
11117 }
11118
11119 /**
11120 * Return {@code true} if the component name is not null and is in the same package that this
11121 * intent limited to. otherwise return {@code false}.
11122 */
11123 private boolean hasPackageEquivalentComponent() {
11124 return mComponent != null
11125 && (mPackage == null || mPackage.equals(mComponent.getPackageName()));
11126 }
11127
11128 /**
11129 * Generate hash code that matches semantics of filterEquals().
11130 *
11131 * @return Returns the hash value of the action, data, type, class, and
11132 * categories.
11133 *
11134 * @see #filterEquals
11135 */
11136 public int filterHashCode() {
11137 int code = 0;
11138 if (mAction != null) {
11139 code += mAction.hashCode();
11140 }
11141 if (mData != null) {
11142 code += mData.hashCode();
11143 }
11144 if (mType != null) {
11145 code += mType.hashCode();
11146 }
11147 if (mIdentifier != null) {
11148 code += mIdentifier.hashCode();
11149 }
11150 if (mPackage != null) {
11151 code += mPackage.hashCode();
11152 }
11153 if (mComponent != null) {
11154 code += mComponent.hashCode();
11155 }
11156 if (mCategories != null) {
11157 code += mCategories.hashCode();
11158 }
11159 return code;
11160 }
11161
11162 @Override
11163 public String toString() {
11164 StringBuilder b = new StringBuilder(128);
11165
11166 b.append("Intent { ");
11167 toShortString(b, true, true, true, false);
11168 b.append(" }");
11169
11170 return b.toString();
11171 }
11172
11173 /** @hide */
11174 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
11175 public String toInsecureString() {
11176 StringBuilder b = new StringBuilder(128);
11177
11178 b.append("Intent { ");
11179 toShortString(b, false, true, true, false);
11180 b.append(" }");
11181
11182 return b.toString();
11183 }
11184
11185 /** @hide */
11186 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
11187 StringBuilder b = new StringBuilder(128);
11188 toShortString(b, secure, comp, extras, clip);
11189 return b.toString();
11190 }
11191
11192 /** @hide */
11193 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
11194 boolean clip) {
11195 boolean first = true;
11196 if (mAction != null) {
11197 b.append("act=").append(mAction);
11198 first = false;
11199 }
11200 if (mCategories != null) {
11201 if (!first) {
11202 b.append(' ');
11203 }
11204 first = false;
11205 b.append("cat=[");
11206 for (int i=0; i<mCategories.size(); i++) {
11207 if (i > 0) b.append(',');
11208 b.append(mCategories.valueAt(i));
11209 }
11210 b.append("]");
11211 }
11212 if (mData != null) {
11213 if (!first) {
11214 b.append(' ');
11215 }
11216 first = false;
11217 b.append("dat=");
11218 if (secure) {
11219 b.append(mData.toSafeString());
11220 } else {
11221 b.append(mData);
11222 }
11223 }
11224 if (mType != null) {
11225 if (!first) {
11226 b.append(' ');
11227 }
11228 first = false;
11229 b.append("typ=").append(mType);
11230 }
11231 if (mIdentifier != null) {
11232 if (!first) {
11233 b.append(' ');
11234 }
11235 first = false;
11236 b.append("id=").append(mIdentifier);
11237 }
11238 if (mFlags != 0) {
11239 if (!first) {
11240 b.append(' ');
11241 }
11242 first = false;
11243 b.append("flg=0x").append(Integer.toHexString(mFlags));
11244 }
11245 if (mPackage != null) {
11246 if (!first) {
11247 b.append(' ');
11248 }
11249 first = false;
11250 b.append("pkg=").append(mPackage);
11251 }
11252 if (comp && mComponent != null) {
11253 if (!first) {
11254 b.append(' ');
11255 }
11256 first = false;
11257 b.append("cmp=").append(mComponent.flattenToShortString());
11258 }
11259 if (mSourceBounds != null) {
11260 if (!first) {
11261 b.append(' ');
11262 }
11263 first = false;
11264 b.append("bnds=").append(mSourceBounds.toShortString());
11265 }
11266 if (mClipData != null) {
11267 if (!first) {
11268 b.append(' ');
11269 }
11270 b.append("clip={");
11271 mClipData.toShortString(b, !clip || secure);
11272 first = false;
11273 b.append('}');
11274 }
11275 if (extras && mExtras != null) {
11276 if (!first) {
11277 b.append(' ');
11278 }
11279 first = false;
11280 b.append("(has extras)");
11281 }
11282 if (mContentUserHint != UserHandle.USER_CURRENT) {
11283 if (!first) {
11284 b.append(' ');
11285 }
11286 first = false;
11287 b.append("u=").append(mContentUserHint);
11288 }
11289 if (mSelector != null) {
11290 b.append(" sel=");
11291 mSelector.toShortString(b, secure, comp, extras, clip);
11292 b.append("}");
11293 }
11294 if (mOriginalIntent != null) {
11295 b.append(" org={");
11296 mOriginalIntent.toShortString(b, secure, comp, extras, clip);
11297 b.append("}");
11298 }
11299 }
11300
11301 /** @hide */
11302 public void dumpDebug(ProtoOutputStream proto, long fieldId) {
11303 // Same input parameters that toString() gives to toShortString().
11304 dumpDebug(proto, fieldId, true, true, true, false);
11305 }
11306
11307 /** @hide */
11308 public void dumpDebug(ProtoOutputStream proto) {
11309 // Same input parameters that toString() gives to toShortString().
11310 dumpDebugWithoutFieldId(proto, true, true, true, false);
11311 }
11312
11313 /** @hide */
11314 public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
11315 boolean extras, boolean clip) {
11316 long token = proto.start(fieldId);
11317 dumpDebugWithoutFieldId(proto, secure, comp, extras, clip);
11318 proto.end(token);
11319 }
11320
11321 private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
11322 boolean extras, boolean clip) {
11323 if (mAction != null) {
11324 proto.write(IntentProto.ACTION, mAction);
11325 }
11326 if (mCategories != null) {
11327 for (String category : mCategories) {
11328 proto.write(IntentProto.CATEGORIES, category);
11329 }
11330 }
11331 if (mData != null) {
11332 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
11333 }
11334 if (mType != null) {
11335 proto.write(IntentProto.TYPE, mType);
11336 }
11337 if (mIdentifier != null) {
11338 proto.write(IntentProto.IDENTIFIER, mIdentifier);
11339 }
11340 if (mFlags != 0) {
11341 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
11342 }
11343 if (mPackage != null) {
11344 proto.write(IntentProto.PACKAGE, mPackage);
11345 }
11346 if (comp && mComponent != null) {
11347 mComponent.dumpDebug(proto, IntentProto.COMPONENT);
11348 }
11349 if (mSourceBounds != null) {
11350 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
11351 }
11352 if (mClipData != null) {
11353 StringBuilder b = new StringBuilder();
11354 mClipData.toShortString(b, !clip || secure);
11355 proto.write(IntentProto.CLIP_DATA, b.toString());
11356 }
11357 if (extras && mExtras != null) {
11358 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
11359 }
11360 if (mContentUserHint != 0) {
11361 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
11362 }
11363 if (mSelector != null) {
11364 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
11365 }
11366 }
11367
11368 /**
11369 * Call {@link #toUri} with 0 flags.
11370 * @deprecated Use {@link #toUri} instead.
11371 */
11372 @Deprecated
11373 public String toURI() {
11374 return toUri(0);
11375 }
11376
11377 /**
11378 * Convert this Intent into a String holding a URI representation of it.
11379 * The returned URI string has been properly URI encoded, so it can be
11380 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
11381 * Intent's data as the base URI, with an additional fragment describing
11382 * the action, categories, type, flags, package, component, and extras.
11383 *
11384 * <p>You can convert the returned string back to an Intent with
11385 * {@link #getIntent}.
11386 *
11387 * @param flags Additional operating flags.
11388 *
11389 * @return Returns a URI encoding URI string describing the entire contents
11390 * of the Intent.
11391 */
11392 public String toUri(@UriFlags int flags) {
11393 StringBuilder uri = new StringBuilder(128);
11394 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
11395 if (mPackage == null) {
11396 throw new IllegalArgumentException(
11397 "Intent must include an explicit package name to build an android-app: "
11398 + this);
11399 }
11400 uri.append("android-app://");
11401 uri.append(mPackage);
11402 String scheme = null;
11403 if (mData != null) {
11404 scheme = mData.getScheme();
11405 if (scheme != null) {
11406 uri.append('/');
11407 uri.append(scheme);
11408 String authority = mData.getEncodedAuthority();
11409 if (authority != null) {
11410 uri.append('/');
11411 uri.append(authority);
11412 String path = mData.getEncodedPath();
11413 if (path != null) {
11414 uri.append(path);
11415 }
11416 String queryParams = mData.getEncodedQuery();
11417 if (queryParams != null) {
11418 uri.append('?');
11419 uri.append(queryParams);
11420 }
11421 String fragment = mData.getEncodedFragment();
11422 if (fragment != null) {
11423 uri.append('#');
11424 uri.append(fragment);
11425 }
11426 }
11427 }
11428 }
11429 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
11430 mPackage, flags);
11431 return uri.toString();
11432 }
11433 String scheme = null;
11434 if (mData != null) {
11435 String data = mData.toString();
11436 if ((flags&URI_INTENT_SCHEME) != 0) {
11437 final int N = data.length();
11438 for (int i=0; i<N; i++) {
11439 char c = data.charAt(i);
11440 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
11441 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
11442 continue;
11443 }
11444 if (c == ':' && i > 0) {
11445 // Valid scheme.
11446 scheme = data.substring(0, i);
11447 uri.append("intent:");
11448 data = data.substring(i+1);
11449 break;
11450 }
11451
11452 // No scheme.
11453 break;
11454 }
11455 }
11456 uri.append(data);
11457
11458 } else if ((flags&URI_INTENT_SCHEME) != 0) {
11459 uri.append("intent:");
11460 }
11461
11462 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
11463
11464 return uri.toString();
11465 }
11466
11467 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
11468 String defPackage, int flags) {
11469 StringBuilder frag = new StringBuilder(128);
11470
11471 toUriInner(frag, scheme, defAction, defPackage, flags);
11472 if (mSelector != null) {
11473 frag.append("SEL;");
11474 // Note that for now we are not going to try to handle the
11475 // data part; not clear how to represent this as a URI, and
11476 // not much utility in it.
11477 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
11478 null, null, flags);
11479 }
11480
11481 if (frag.length() > 0) {
11482 uri.append("#Intent;");
11483 uri.append(frag);
11484 uri.append("end");
11485 }
11486 }
11487
11488 private void toUriInner(StringBuilder uri, String scheme, String defAction,
11489 String defPackage, int flags) {
11490 if (scheme != null) {
11491 uri.append("scheme=").append(Uri.encode(scheme)).append(';');
11492 }
11493 if (mAction != null && !mAction.equals(defAction)) {
11494 uri.append("action=").append(Uri.encode(mAction)).append(';');
11495 }
11496 if (mCategories != null) {
11497 for (int i=0; i<mCategories.size(); i++) {
11498 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
11499 }
11500 }
11501 if (mType != null) {
11502 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
11503 }
11504 if (mIdentifier != null) {
11505 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';');
11506 }
11507 if (mFlags != 0) {
11508 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
11509 }
11510 if (mPackage != null && !mPackage.equals(defPackage)) {
11511 uri.append("package=").append(Uri.encode(mPackage)).append(';');
11512 }
11513 if (mComponent != null) {
11514 uri.append("component=").append(Uri.encode(
11515 mComponent.flattenToShortString(), "/")).append(';');
11516 }
11517 if (mSourceBounds != null) {
11518 uri.append("sourceBounds=")
11519 .append(Uri.encode(mSourceBounds.flattenToString()))
11520 .append(';');
11521 }
11522 if (mExtras != null) {
11523 for (String key : mExtras.keySet()) {
11524 final Object value = mExtras.get(key);
11525 char entryType =
11526 value instanceof String ? 'S' :
11527 value instanceof Boolean ? 'B' :
11528 value instanceof Byte ? 'b' :
11529 value instanceof Character ? 'c' :
11530 value instanceof Double ? 'd' :
11531 value instanceof Float ? 'f' :
11532 value instanceof Integer ? 'i' :
11533 value instanceof Long ? 'l' :
11534 value instanceof Short ? 's' :
11535 '\0';
11536
11537 if (entryType != '\0') {
11538 uri.append(entryType);
11539 uri.append('.');
11540 uri.append(Uri.encode(key));
11541 uri.append('=');
11542 uri.append(Uri.encode(value.toString()));
11543 uri.append(';');
11544 }
11545 }
11546 }
11547 }
11548
11549 public int describeContents() {
11550 return (mExtras != null) ? mExtras.describeContents() : 0;
11551 }
11552
11553 public void writeToParcel(Parcel out, int flags) {
11554 out.writeString8(mAction);
11555 Uri.writeToParcel(out, mData);
11556 out.writeString8(mType);
11557 out.writeString8(mIdentifier);
11558 out.writeInt(mFlags);
11559 out.writeString8(mPackage);
11560 ComponentName.writeToParcel(mComponent, out);
11561
11562 if (mSourceBounds != null) {
11563 out.writeInt(1);
11564 mSourceBounds.writeToParcel(out, flags);
11565 } else {
11566 out.writeInt(0);
11567 }
11568
11569 if (mCategories != null) {
11570 final int N = mCategories.size();
11571 out.writeInt(N);
11572 for (int i=0; i<N; i++) {
11573 out.writeString8(mCategories.valueAt(i));
11574 }
11575 } else {
11576 out.writeInt(0);
11577 }
11578
11579 if (mSelector != null) {
11580 out.writeInt(1);
11581 mSelector.writeToParcel(out, flags);
11582 } else {
11583 out.writeInt(0);
11584 }
11585
11586 if (mClipData != null) {
11587 out.writeInt(1);
11588 mClipData.writeToParcel(out, flags);
11589 } else {
11590 out.writeInt(0);
11591 }
11592 out.writeInt(mContentUserHint);
11593 out.writeBundle(mExtras);
11594
11595 if (mOriginalIntent != null) {
11596 out.writeInt(1);
11597 mOriginalIntent.writeToParcel(out, flags);
11598 } else {
11599 out.writeInt(0);
11600 }
11601 }
11602
11603 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR
11604 = new Parcelable.Creator<Intent>() {
11605 public Intent createFromParcel(Parcel in) {
11606 return new Intent(in);
11607 }
11608 public Intent[] newArray(int size) {
11609 return new Intent[size];
11610 }
11611 };
11612
11613 /** @hide */
11614 protected Intent(Parcel in) {
11615 // Remember that we came from a remote process to help detect security
11616 // issues caused by later unsafe launches
11617 mLocalFlags = LOCAL_FLAG_FROM_PARCEL;
11618 readFromParcel(in);
11619 }
11620
11621 public void readFromParcel(Parcel in) {
11622 setAction(in.readString8());
11623 mData = Uri.CREATOR.createFromParcel(in);
11624 mType = in.readString8();
11625 mIdentifier = in.readString8();
11626 mFlags = in.readInt();
11627 mPackage = in.readString8();
11628 mComponent = ComponentName.readFromParcel(in);
11629
11630 if (in.readInt() != 0) {
11631 mSourceBounds = Rect.CREATOR.createFromParcel(in);
11632 }
11633
11634 int N = in.readInt();
11635 if (N > 0) {
11636 mCategories = new ArraySet<String>();
11637 int i;
11638 for (i=0; i<N; i++) {
11639 mCategories.add(in.readString8().intern());
11640 }
11641 } else {
11642 mCategories = null;
11643 }
11644
11645 if (in.readInt() != 0) {
11646 mSelector = new Intent(in);
11647 }
11648
11649 if (in.readInt() != 0) {
11650 mClipData = new ClipData(in);
11651 }
11652 mContentUserHint = in.readInt();
11653 mExtras = in.readBundle();
11654 if (in.readInt() != 0) {
11655 mOriginalIntent = new Intent(in);
11656 }
11657 }
11658
11659 /**
11660 * Parses the "intent" element (and its children) from XML and instantiates
11661 * an Intent object. The given XML parser should be located at the tag
11662 * where parsing should start (often named "intent"), from which the
11663 * basic action, data, type, and package and class name will be
11664 * retrieved. The function will then parse in to any child elements,
11665 * looking for <category android:name="xxx"> tags to add categories and
11666 * <extra android:name="xxx" android:value="yyy"> to attach extra data
11667 * to the intent.
11668 *
11669 * @param resources The Resources to use when inflating resources.
11670 * @param parser The XML parser pointing at an "intent" tag.
11671 * @param attrs The AttributeSet interface for retrieving extended
11672 * attribute data at the current <var>parser</var> location.
11673 * @return An Intent object matching the XML data.
11674 * @throws XmlPullParserException If there was an XML parsing error.
11675 * @throws IOException If there was an I/O error.
11676 */
11677 public static @NonNull Intent parseIntent(@NonNull Resources resources,
11678 @NonNull XmlPullParser parser, AttributeSet attrs)
11679 throws XmlPullParserException, IOException {
11680 Intent intent = new Intent();
11681
11682 TypedArray sa = resources.obtainAttributes(attrs,
11683 com.android.internal.R.styleable.Intent);
11684
11685 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
11686
11687 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
11688 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
11689 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
11690
11691 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier));
11692
11693 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
11694 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
11695 if (packageName != null && className != null) {
11696 intent.setComponent(new ComponentName(packageName, className));
11697 }
11698
11699 sa.recycle();
11700
11701 int outerDepth = parser.getDepth();
11702 int type;
11703 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
11704 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
11705 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
11706 continue;
11707 }
11708
11709 String nodeName = parser.getName();
11710 if (nodeName.equals(TAG_CATEGORIES)) {
11711 sa = resources.obtainAttributes(attrs,
11712 com.android.internal.R.styleable.IntentCategory);
11713 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
11714 sa.recycle();
11715
11716 if (cat != null) {
11717 intent.addCategory(cat);
11718 }
11719 XmlUtils.skipCurrentTag(parser);
11720
11721 } else if (nodeName.equals(TAG_EXTRA)) {
11722 if (intent.mExtras == null) {
11723 intent.mExtras = new Bundle();
11724 }
11725 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
11726 XmlUtils.skipCurrentTag(parser);
11727
11728 } else {
11729 XmlUtils.skipCurrentTag(parser);
11730 }
11731 }
11732
11733 return intent;
11734 }
11735
11736 /** @hide */
11737 public void saveToXml(XmlSerializer out) throws IOException {
11738 if (mAction != null) {
11739 out.attribute(null, ATTR_ACTION, mAction);
11740 }
11741 if (mData != null) {
11742 out.attribute(null, ATTR_DATA, mData.toString());
11743 }
11744 if (mType != null) {
11745 out.attribute(null, ATTR_TYPE, mType);
11746 }
11747 if (mIdentifier != null) {
11748 out.attribute(null, ATTR_IDENTIFIER, mIdentifier);
11749 }
11750 if (mComponent != null) {
11751 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
11752 }
11753 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
11754
11755 if (mCategories != null) {
11756 out.startTag(null, TAG_CATEGORIES);
11757 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
11758 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
11759 }
11760 out.endTag(null, TAG_CATEGORIES);
11761 }
11762 }
11763
11764 /** @hide */
11765 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
11766 XmlPullParserException {
11767 Intent intent = new Intent();
11768 final int outerDepth = in.getDepth();
11769
11770 int attrCount = in.getAttributeCount();
11771 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11772 final String attrName = in.getAttributeName(attrNdx);
11773 final String attrValue = in.getAttributeValue(attrNdx);
11774 if (ATTR_ACTION.equals(attrName)) {
11775 intent.setAction(attrValue);
11776 } else if (ATTR_DATA.equals(attrName)) {
11777 intent.setData(Uri.parse(attrValue));
11778 } else if (ATTR_TYPE.equals(attrName)) {
11779 intent.setType(attrValue);
11780 } else if (ATTR_IDENTIFIER.equals(attrName)) {
11781 intent.setIdentifier(attrValue);
11782 } else if (ATTR_COMPONENT.equals(attrName)) {
11783 intent.setComponent(ComponentName.unflattenFromString(attrValue));
11784 } else if (ATTR_FLAGS.equals(attrName)) {
11785 intent.setFlags(Integer.parseInt(attrValue, 16));
11786 } else {
11787 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
11788 }
11789 }
11790
11791 int event;
11792 String name;
11793 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
11794 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
11795 if (event == XmlPullParser.START_TAG) {
11796 name = in.getName();
11797 if (TAG_CATEGORIES.equals(name)) {
11798 attrCount = in.getAttributeCount();
11799 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11800 intent.addCategory(in.getAttributeValue(attrNdx));
11801 }
11802 } else {
11803 Log.w(TAG, "restoreFromXml: unknown name=" + name);
11804 XmlUtils.skipCurrentTag(in);
11805 }
11806 }
11807 }
11808
11809 return intent;
11810 }
11811
11812 /**
11813 * Normalize a MIME data type.
11814 *
11815 * <p>A normalized MIME type has white-space trimmed,
11816 * content-type parameters removed, and is lower-case.
11817 * This aligns the type with Android best practices for
11818 * intent filtering.
11819 *
11820 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
11821 * "text/x-vCard" becomes "text/x-vcard".
11822 *
11823 * <p>All MIME types received from outside Android (such as user input,
11824 * or external sources like Bluetooth, NFC, or the Internet) should
11825 * be normalized before they are used to create an Intent.
11826 *
11827 * @param type MIME data type to normalize
11828 * @return normalized MIME data type, or null if the input was null
11829 * @see #setType
11830 * @see #setTypeAndNormalize
11831 */
11832 public static @Nullable String normalizeMimeType(@Nullable String type) {
11833 if (type == null) {
11834 return null;
11835 }
11836
11837 type = type.trim().toLowerCase(Locale.ROOT);
11838
11839 final int semicolonIndex = type.indexOf(';');
11840 if (semicolonIndex != -1) {
11841 type = type.substring(0, semicolonIndex);
11842 }
11843 return type;
11844 }
11845
11846 /**
11847 * Prepare this {@link Intent} to leave an app process.
11848 *
11849 * @hide
11850 */
11851 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
11852 public void prepareToLeaveProcess(Context context) {
11853 final boolean leavingPackage;
11854 if (mComponent != null) {
11855 leavingPackage = !Objects.equals(mComponent.getPackageName(), context.getPackageName());
11856 } else if (mPackage != null) {
11857 leavingPackage = !Objects.equals(mPackage, context.getPackageName());
11858 } else {
11859 // When no specific component or package has been defined, we have
11860 // to assume that we might be routed through an intent
11861 // disambiguation dialog which might leave our package
11862 leavingPackage = true;
11863 }
11864 prepareToLeaveProcess(leavingPackage);
11865 }
11866
11867 /**
11868 * Prepare this {@link Intent} to leave an app process.
11869 *
11870 * @hide
11871 */
11872 public void prepareToLeaveProcess(boolean leavingPackage) {
11873 setAllowFds(false);
11874
11875 if (mSelector != null) {
11876 mSelector.prepareToLeaveProcess(leavingPackage);
11877 }
11878 if (mClipData != null) {
11879 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
11880 }
11881 if (mOriginalIntent != null) {
11882 mOriginalIntent.prepareToLeaveProcess(leavingPackage);
11883 }
11884
11885 if (mExtras != null && !mExtras.isParcelled()) {
11886 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
11887 if (intent instanceof Intent) {
11888 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
11889 }
11890 }
11891
11892 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
11893 && leavingPackage) {
11894 switch (mAction) {
11895 case ACTION_MEDIA_REMOVED:
11896 case ACTION_MEDIA_UNMOUNTED:
11897 case ACTION_MEDIA_CHECKING:
11898 case ACTION_MEDIA_NOFS:
11899 case ACTION_MEDIA_MOUNTED:
11900 case ACTION_MEDIA_SHARED:
11901 case ACTION_MEDIA_UNSHARED:
11902 case ACTION_MEDIA_BAD_REMOVAL:
11903 case ACTION_MEDIA_UNMOUNTABLE:
11904 case ACTION_MEDIA_EJECT:
11905 case ACTION_MEDIA_SCANNER_STARTED:
11906 case ACTION_MEDIA_SCANNER_FINISHED:
11907 case ACTION_MEDIA_SCANNER_SCAN_FILE:
11908 case ACTION_PACKAGE_NEEDS_VERIFICATION:
11909 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION:
11910 case ACTION_PACKAGE_VERIFIED:
11911 case ACTION_PACKAGE_ENABLE_ROLLBACK:
11912 // Ignore legacy actions
11913 break;
11914 default:
11915 mData.checkFileUriExposed("Intent.getData()");
11916 }
11917 }
11918
11919 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
11920 && leavingPackage) {
11921 switch (mAction) {
11922 case ACTION_PROVIDER_CHANGED:
11923 case QuickContact.ACTION_QUICK_CONTACT:
11924 // Ignore actions that don't need to grant
11925 break;
11926 default:
11927 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
11928 }
11929 }
11930
11931 // Translate raw filesystem paths out of storage sandbox
11932 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
11933 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
11934 final StorageManager sm = AppGlobals.getInitialApplication()
11935 .getSystemService(StorageManager.class);
11936 final File before = new File(mData.getPath());
11937 final File after = sm.translateAppToSystem(before,
11938 android.os.Process.myPid(), android.os.Process.myUid());
11939 if (!Objects.equals(before, after)) {
11940 Log.v(TAG, "Translated " + before + " to " + after);
11941 mData = Uri.fromFile(after);
11942 }
11943 }
11944
11945 // Detect cases where we're about to launch a potentially unsafe intent
11946 if (StrictMode.vmUnsafeIntentLaunchEnabled()) {
11947 if ((mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0
11948 && (mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) {
11949 StrictMode.onUnsafeIntentLaunch(this);
11950 } else if ((mLocalFlags & LOCAL_FLAG_UNFILTERED_EXTRAS) != 0) {
11951 StrictMode.onUnsafeIntentLaunch(this);
11952 } else if ((mLocalFlags & LOCAL_FLAG_FROM_URI) != 0
11953 && !(mCategories != null && mCategories.contains(CATEGORY_BROWSABLE)
11954 && mComponent == null)) {
11955 // Since the docs for #URI_ALLOW_UNSAFE recommend setting the category to browsable
11956 // for an implicit Intent parsed from a URI a violation should be reported if these
11957 // conditions are not met.
11958 StrictMode.onUnsafeIntentLaunch(this);
11959 }
11960 }
11961 }
11962
11963 /**
11964 * @hide
11965 */
11966 public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) {
11967 // We just entered destination process, so we should be able to read all
11968 // parcelables inside.
11969 setDefusable(true);
11970
11971 if (mSelector != null) {
11972 // We can't recursively claim that this data is from a protected
11973 // component, since it may have been filled in by a malicious app
11974 mSelector.prepareToEnterProcess(false, source);
11975 }
11976 if (mClipData != null) {
11977 mClipData.prepareToEnterProcess(source);
11978 }
11979 if (mOriginalIntent != null) {
11980 mOriginalIntent.prepareToEnterProcess(false, source);
11981 }
11982
11983 if (mContentUserHint != UserHandle.USER_CURRENT) {
11984 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
11985 fixUris(mContentUserHint);
11986 mContentUserHint = UserHandle.USER_CURRENT;
11987 }
11988 }
11989
11990 if (fromProtectedComponent) {
11991 mLocalFlags |= LOCAL_FLAG_FROM_PROTECTED_COMPONENT;
11992 }
11993
11994 // Special attribution fix-up logic for any BluetoothDevice extras
11995 // passed via Bluetooth intents
11996 if (mAction != null && mAction.startsWith("android.bluetooth.")
11997 && hasExtra(BluetoothDevice.EXTRA_DEVICE)) {
11998 final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
11999 if (device != null) {
12000 device.prepareToEnterProcess(source);
12001 }
12002 }
12003 }
12004
12005 /** @hide */
12006 public boolean hasWebURI() {
12007 if (getData() == null) {
12008 return false;
12009 }
12010 final String scheme = getScheme();
12011 if (TextUtils.isEmpty(scheme)) {
12012 return false;
12013 }
12014 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
12015 }
12016
12017 /** @hide */
12018 public boolean isWebIntent() {
12019 return ACTION_VIEW.equals(mAction)
12020 && hasWebURI();
12021 }
12022
12023 private boolean isImageCaptureIntent() {
12024 return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction)
12025 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction)
12026 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction));
12027 }
12028
12029 /** @hide */
12030 public boolean isImplicitImageCaptureIntent() {
12031 return mPackage == null && mComponent == null && isImageCaptureIntent();
12032 }
12033
12034 /**
12035 * @hide
12036 */
12037 public void fixUris(int contentUserHint) {
12038 Uri data = getData();
12039 if (data != null) {
12040 mData = maybeAddUserId(data, contentUserHint);
12041 }
12042 if (mClipData != null) {
12043 mClipData.fixUris(contentUserHint);
12044 }
12045 String action = getAction();
12046 if (ACTION_SEND.equals(action)) {
12047 final Uri stream = getParcelableExtra(EXTRA_STREAM);
12048 if (stream != null) {
12049 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
12050 }
12051 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
12052 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
12053 if (streams != null) {
12054 ArrayList<Uri> newStreams = new ArrayList<Uri>();
12055 for (int i = 0; i < streams.size(); i++) {
12056 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
12057 }
12058 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
12059 }
12060 } else if (isImageCaptureIntent()) {
12061 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
12062 if (output != null) {
12063 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
12064 }
12065 }
12066 }
12067
12068 /**
12069 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
12070 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
12071 * intents in {@link #ACTION_CHOOSER}.
12072 *
12073 * @return Whether any contents were migrated.
12074 * @hide
12075 */
12076 public boolean migrateExtraStreamToClipData() {
12077 return migrateExtraStreamToClipData(AppGlobals.getInitialApplication());
12078 }
12079
12080 /**
12081 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
12082 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
12083 * intents in {@link #ACTION_CHOOSER}.
12084 *
12085 * @param context app context
12086 * @return Whether any contents were migrated.
12087 * @hide
12088 */
12089 public boolean migrateExtraStreamToClipData(Context context) {
12090 // Refuse to touch if extras already parcelled
12091 if (mExtras != null && mExtras.isParcelled()) return false;
12092
12093 // Bail when someone already gave us ClipData
12094 if (getClipData() != null) return false;
12095
12096 final String action = getAction();
12097 if (ACTION_CHOOSER.equals(action)) {
12098 // Inspect contained intents to see if we need to migrate extras. We
12099 // don't promote ClipData to the parent, since ChooserActivity will
12100 // already start the picked item as the caller, and we can't combine
12101 // the flags in a safe way.
12102
12103 boolean migrated = false;
12104 try {
12105 final Intent intent = getParcelableExtra(EXTRA_INTENT);
12106 if (intent != null) {
12107 migrated |= intent.migrateExtraStreamToClipData(context);
12108 }
12109 } catch (ClassCastException e) {
12110 }
12111 try {
12112 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
12113 if (intents != null) {
12114 for (int i = 0; i < intents.length; i++) {
12115 final Intent intent = (Intent) intents[i];
12116 if (intent != null) {
12117 migrated |= intent.migrateExtraStreamToClipData(context);
12118 }
12119 }
12120 }
12121 } catch (ClassCastException e) {
12122 }
12123 return migrated;
12124
12125 } else if (ACTION_SEND.equals(action)) {
12126 try {
12127 final Uri stream = getParcelableExtra(EXTRA_STREAM);
12128 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
12129 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
12130 if (stream != null || text != null || htmlText != null) {
12131 final ClipData clipData = new ClipData(
12132 null, new String[] { getType() },
12133 new ClipData.Item(text, htmlText, null, stream));
12134 setClipData(clipData);
12135 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
12136 return true;
12137 }
12138 } catch (ClassCastException e) {
12139 }
12140
12141 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
12142 try {
12143 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
12144 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
12145 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
12146 int num = -1;
12147 if (streams != null) {
12148 num = streams.size();
12149 }
12150 if (texts != null) {
12151 if (num >= 0 && num != texts.size()) {
12152 // Wha...! F- you.
12153 return false;
12154 }
12155 num = texts.size();
12156 }
12157 if (htmlTexts != null) {
12158 if (num >= 0 && num != htmlTexts.size()) {
12159 // Wha...! F- you.
12160 return false;
12161 }
12162 num = htmlTexts.size();
12163 }
12164 if (num > 0) {
12165 final ClipData clipData = new ClipData(
12166 null, new String[] { getType() },
12167 makeClipItem(streams, texts, htmlTexts, 0));
12168
12169 for (int i = 1; i < num; i++) {
12170 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
12171 }
12172
12173 setClipData(clipData);
12174 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
12175 return true;
12176 }
12177 } catch (ClassCastException e) {
12178 }
12179 } else if (isImageCaptureIntent()) {
12180 Uri output;
12181 try {
12182 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
12183 } catch (ClassCastException e) {
12184 return false;
12185 }
12186
12187 if (output != null) {
12188 output = maybeConvertFileToContentUri(context, output);
12189 putExtra(MediaStore.EXTRA_OUTPUT, output);
12190
12191 setClipData(ClipData.newRawUri("", output));
12192 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
12193 return true;
12194 }
12195 }
12196
12197 return false;
12198 }
12199
12200 private Uri maybeConvertFileToContentUri(Context context, Uri uri) {
12201 if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())
12202 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) {
12203 File file = new File(uri.getPath());
12204 try {
12205 if (!file.exists()) file.createNewFile();
12206 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath()));
12207 if (uri != null) {
12208 return uri;
12209 }
12210 } catch (IOException e) {
12211 Log.e(TAG, "Ignoring failure to create file " + file, e);
12212 }
12213 }
12214 return uri;
12215 }
12216
12217 /**
12218 * Convert the dock state to a human readable format.
12219 * @hide
12220 */
12221 public static String dockStateToString(int dock) {
12222 switch (dock) {
12223 case EXTRA_DOCK_STATE_HE_DESK:
12224 return "EXTRA_DOCK_STATE_HE_DESK";
12225 case EXTRA_DOCK_STATE_LE_DESK:
12226 return "EXTRA_DOCK_STATE_LE_DESK";
12227 case EXTRA_DOCK_STATE_CAR:
12228 return "EXTRA_DOCK_STATE_CAR";
12229 case EXTRA_DOCK_STATE_DESK:
12230 return "EXTRA_DOCK_STATE_DESK";
12231 case EXTRA_DOCK_STATE_UNDOCKED:
12232 return "EXTRA_DOCK_STATE_UNDOCKED";
12233 default:
12234 return Integer.toString(dock);
12235 }
12236 }
12237
12238 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
12239 ArrayList<String> htmlTexts, int which) {
12240 Uri uri = streams != null ? streams.get(which) : null;
12241 CharSequence text = texts != null ? texts.get(which) : null;
12242 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
12243 return new ClipData.Item(text, htmlText, null, uri);
12244 }
12245
12246 /** @hide */
12247 public boolean isDocument() {
12248 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
12249 }
12250 }