blob: baaf8f76797a66dbf42e7c9f9285df7070803603 [file] [log] [blame]
Alan Viverette3da604b2020-06-10 18:34:39 +00001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
19import static android.content.ContentProvider.maybeAddUserId;
20
21import android.annotation.AnyRes;
22import android.annotation.BroadcastBehavior;
23import android.annotation.IntDef;
24import android.annotation.NonNull;
25import android.annotation.Nullable;
26import android.annotation.RequiresPermission;
27import android.annotation.SdkConstant;
28import android.annotation.SdkConstant.SdkConstantType;
29import android.annotation.SuppressLint;
30import android.annotation.SystemApi;
31import android.annotation.TestApi;
32import android.app.AppGlobals;
33import android.compat.annotation.UnsupportedAppUsage;
34import android.content.pm.ActivityInfo;
35import android.content.pm.ApplicationInfo;
36import android.content.pm.ComponentInfo;
37import android.content.pm.PackageManager;
38import android.content.pm.ResolveInfo;
39import android.content.pm.ShortcutInfo;
40import android.content.pm.SuspendDialogInfo;
41import android.content.res.Resources;
42import android.content.res.TypedArray;
43import android.graphics.Rect;
44import android.net.Uri;
45import android.os.Build;
46import android.os.Bundle;
47import android.os.IBinder;
48import android.os.IncidentManager;
49import android.os.Parcel;
50import android.os.Parcelable;
51import android.os.PersistableBundle;
52import android.os.Process;
53import android.os.ResultReceiver;
54import android.os.ShellCommand;
55import android.os.StrictMode;
56import android.os.UserHandle;
57import android.os.storage.StorageManager;
58import android.provider.ContactsContract.QuickContact;
59import android.provider.DocumentsContract;
60import android.provider.DocumentsProvider;
61import android.provider.MediaStore;
62import android.provider.OpenableColumns;
63import android.telecom.PhoneAccount;
64import android.telecom.TelecomManager;
65import android.text.TextUtils;
66import android.util.ArraySet;
67import android.util.AttributeSet;
68import android.util.Log;
69import android.util.proto.ProtoOutputStream;
70
71import com.android.internal.util.XmlUtils;
72
73import org.xmlpull.v1.XmlPullParser;
74import org.xmlpull.v1.XmlPullParserException;
75import org.xmlpull.v1.XmlSerializer;
76
77import java.io.File;
78import java.io.IOException;
79import java.io.PrintWriter;
80import java.io.Serializable;
81import java.lang.annotation.Retention;
82import java.lang.annotation.RetentionPolicy;
83import java.net.URISyntaxException;
84import java.util.ArrayList;
85import java.util.HashSet;
86import java.util.List;
87import java.util.Locale;
88import java.util.Objects;
89import java.util.Set;
90import java.util.TimeZone;
91
92/**
93 * An intent is an abstract description of an operation to be performed. It
94 * can be used with {@link Context#startActivity(Intent) startActivity} to
95 * launch an {@link android.app.Activity},
96 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
97 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
98 * and {@link android.content.Context#startService} or
99 * {@link android.content.Context#bindService} to communicate with a
100 * background {@link android.app.Service}.
101 *
102 * <p>An Intent provides a facility for performing late runtime binding between the code in
103 * different applications. Its most significant use is in the launching of activities, where it
104 * can be thought of as the glue between activities. It is basically a passive data structure
105 * holding an abstract description of an action to be performed.</p>
106 *
107 * <div class="special reference">
108 * <h3>Developer Guides</h3>
109 * <p>For information about how to create and resolve intents, read the
110 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
111 * developer guide.</p>
112 * </div>
113 *
114 * <a name="IntentStructure"></a>
115 * <h3>Intent Structure</h3>
116 * <p>The primary pieces of information in an intent are:</p>
117 *
118 * <ul>
119 * <li> <p><b>action</b> -- The general action to be performed, such as
120 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
121 * etc.</p>
122 * </li>
123 * <li> <p><b>data</b> -- The data to operate on, such as a person record
124 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
125 * </li>
126 * </ul>
127 *
128 *
129 * <p>Some examples of action/data pairs are:</p>
130 *
131 * <ul>
132 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
133 * information about the person whose identifier is "1".</p>
134 * </li>
135 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
136 * the phone dialer with the person filled in.</p>
137 * </li>
138 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
139 * the phone dialer with the given number filled in. Note how the
140 * VIEW action does what is considered the most reasonable thing for
141 * a particular URI.</p>
142 * </li>
143 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
144 * the phone dialer with the given number filled in.</p>
145 * </li>
146 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
147 * information about the person whose identifier is "1".</p>
148 * </li>
149 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
150 * a list of people, which the user can browse through. This example is a
151 * typical top-level entry into the Contacts application, showing you the
152 * list of people. Selecting a particular person to view would result in a
153 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
154 * being used to start an activity to display that person.</p>
155 * </li>
156 * </ul>
157 *
158 * <p>In addition to these primary attributes, there are a number of secondary
159 * attributes that you can also include with an intent:</p>
160 *
161 * <ul>
162 * <li> <p><b>category</b> -- Gives additional information about the action
163 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
164 * appear in the Launcher as a top-level application, while
165 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
166 * of alternative actions the user can perform on a piece of data.</p>
167 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
168 * intent data. Normally the type is inferred from the data itself.
169 * By setting this attribute, you disable that evaluation and force
170 * an explicit type.</p>
171 * <li> <p><b>component</b> -- Specifies an explicit name of a component
172 * class to use for the intent. Normally this is determined by looking
173 * at the other information in the intent (the action, data/type, and
174 * categories) and matching that with a component that can handle it.
175 * If this attribute is set then none of the evaluation is performed,
176 * and this component is used exactly as is. By specifying this attribute,
177 * all of the other Intent attributes become optional.</p>
178 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
179 * This can be used to provide extended information to the component.
180 * For example, if we have a action to send an e-mail message, we could
181 * also include extra pieces of data here to supply a subject, body,
182 * etc.</p>
183 * </ul>
184 *
185 * <p>Here are some examples of other operations you can specify as intents
186 * using these additional parameters:</p>
187 *
188 * <ul>
189 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
190 * Launch the home screen.</p>
191 * </li>
192 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
193 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
194 * vnd.android.cursor.item/phone}</i></b>
195 * -- Display the list of people's phone numbers, allowing the user to
196 * browse through them and pick one and return it to the parent activity.</p>
197 * </li>
198 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
199 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
200 * -- Display all pickers for data that can be opened with
201 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
202 * allowing the user to pick one of them and then some data inside of it
203 * and returning the resulting URI to the caller. This can be used,
204 * for example, in an e-mail application to allow the user to pick some
205 * data to include as an attachment.</p>
206 * </li>
207 * </ul>
208 *
209 * <p>There are a variety of standard Intent action and category constants
210 * defined in the Intent class, but applications can also define their own.
211 * These strings use Java-style scoping, to ensure they are unique -- for
212 * example, the standard {@link #ACTION_VIEW} is called
213 * "android.intent.action.VIEW".</p>
214 *
215 * <p>Put together, the set of actions, data types, categories, and extra data
216 * defines a language for the system allowing for the expression of phrases
217 * such as "call john smith's cell". As applications are added to the system,
218 * they can extend this language by adding new actions, types, and categories, or
219 * they can modify the behavior of existing phrases by supplying their own
220 * activities that handle them.</p>
221 *
222 * <a name="IntentResolution"></a>
223 * <h3>Intent Resolution</h3>
224 *
225 * <p>There are two primary forms of intents you will use.
226 *
227 * <ul>
228 * <li> <p><b>Explicit Intents</b> have specified a component (via
229 * {@link #setComponent} or {@link #setClass}), which provides the exact
230 * class to be run. Often these will not include any other information,
231 * simply being a way for an application to launch various internal
232 * activities it has as the user interacts with the application.
233 *
234 * <li> <p><b>Implicit Intents</b> have not specified a component;
235 * instead, they must include enough information for the system to
236 * determine which of the available components is best to run for that
237 * intent.
238 * </ul>
239 *
240 * <p>When using implicit intents, given such an arbitrary intent we need to
241 * know what to do with it. This is handled by the process of <em>Intent
242 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
243 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
244 * more activities/receivers) that can handle it.</p>
245 *
246 * <p>The intent resolution mechanism basically revolves around matching an
247 * Intent against all of the &lt;intent-filter&gt; descriptions in the
248 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
249 * objects explicitly registered with {@link Context#registerReceiver}.) More
250 * details on this can be found in the documentation on the {@link
251 * IntentFilter} class.</p>
252 *
253 * <p>There are three pieces of information in the Intent that are used for
254 * resolution: the action, type, and category. Using this information, a query
255 * is done on the {@link PackageManager} for a component that can handle the
256 * intent. The appropriate component is determined based on the intent
257 * information supplied in the <code>AndroidManifest.xml</code> file as
258 * follows:</p>
259 *
260 * <ul>
261 * <li> <p>The <b>action</b>, if given, must be listed by the component as
262 * one it handles.</p>
263 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
264 * already supplied in the Intent. Like the action, if a type is
265 * included in the intent (either explicitly or implicitly in its
266 * data), then this must be listed by the component as one it handles.</p>
267 * <li> For data that is not a <code>content:</code> URI and where no explicit
268 * type is included in the Intent, instead the <b>scheme</b> of the
269 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
270 * considered. Again like the action, if we are matching a scheme it
271 * must be listed by the component as one it can handle.
272 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
273 * by the activity as categories it handles. That is, if you include
274 * the categories {@link #CATEGORY_LAUNCHER} and
275 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
276 * with an intent that lists <em>both</em> of those categories.
277 * Activities will very often need to support the
278 * {@link #CATEGORY_DEFAULT} so that they can be found by
279 * {@link Context#startActivity Context.startActivity()}.</p>
280 * </ul>
281 *
282 * <p>For example, consider the Note Pad sample application that
283 * allows a user to browse through a list of notes data and view details about
284 * individual items. Text in italics indicates places where you would replace a
285 * name with one specific to your own package.</p>
286 *
287 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
288 * package="<i>com.android.notepad</i>"&gt;
289 * &lt;application android:icon="@drawable/app_notes"
290 * android:label="@string/app_name"&gt;
291 *
292 * &lt;provider class=".NotePadProvider"
293 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
294 *
295 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
296 * &lt;intent-filter&gt;
297 * &lt;action android:name="android.intent.action.MAIN" /&gt;
298 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
299 * &lt;/intent-filter&gt;
300 * &lt;intent-filter&gt;
301 * &lt;action android:name="android.intent.action.VIEW" /&gt;
302 * &lt;action android:name="android.intent.action.EDIT" /&gt;
303 * &lt;action android:name="android.intent.action.PICK" /&gt;
304 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
306 * &lt;/intent-filter&gt;
307 * &lt;intent-filter&gt;
308 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
309 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
310 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
311 * &lt;/intent-filter&gt;
312 * &lt;/activity&gt;
313 *
314 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
315 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
316 * &lt;action android:name="android.intent.action.VIEW" /&gt;
317 * &lt;action android:name="android.intent.action.EDIT" /&gt;
318 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
319 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
320 * &lt;/intent-filter&gt;
321 *
322 * &lt;intent-filter&gt;
323 * &lt;action android:name="android.intent.action.INSERT" /&gt;
324 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
325 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
326 * &lt;/intent-filter&gt;
327 *
328 * &lt;/activity&gt;
329 *
330 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
331 * android:theme="@android:style/Theme.Dialog"&gt;
332 * &lt;intent-filter android:label="@string/resolve_title"&gt;
333 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
334 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
335 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
336 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
337 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
338 * &lt;/intent-filter&gt;
339 * &lt;/activity&gt;
340 *
341 * &lt;/application&gt;
342 * &lt;/manifest&gt;</pre>
343 *
344 * <p>The first activity,
345 * <code>com.android.notepad.NotesList</code>, serves as our main
346 * entry into the app. It can do three things as described by its three intent
347 * templates:
348 * <ol>
349 * <li><pre>
350 * &lt;intent-filter&gt;
351 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
352 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
353 * &lt;/intent-filter&gt;</pre>
354 * <p>This provides a top-level entry into the NotePad application: the standard
355 * MAIN action is a main entry point (not requiring any other information in
356 * the Intent), and the LAUNCHER category says that this entry point should be
357 * listed in the application launcher.</p>
358 * <li><pre>
359 * &lt;intent-filter&gt;
360 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
361 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
362 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
363 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
364 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
365 * &lt;/intent-filter&gt;</pre>
366 * <p>This declares the things that the activity can do on a directory of
367 * notes. The type being supported is given with the &lt;type&gt; tag, where
368 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
369 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
370 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
371 * The activity allows the user to view or edit the directory of data (via
372 * the VIEW and EDIT actions), or to pick a particular note and return it
373 * to the caller (via the PICK action). Note also the DEFAULT category
374 * supplied here: this is <em>required</em> for the
375 * {@link Context#startActivity Context.startActivity} method to resolve your
376 * activity when its component name is not explicitly specified.</p>
377 * <li><pre>
378 * &lt;intent-filter&gt;
379 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
380 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
381 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
382 * &lt;/intent-filter&gt;</pre>
383 * <p>This filter describes the ability to return to the caller a note selected by
384 * the user without needing to know where it came from. The data type
385 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
386 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
387 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
388 * The GET_CONTENT action is similar to the PICK action, where the activity
389 * will return to its caller a piece of data selected by the user. Here,
390 * however, the caller specifies the type of data they desire instead of
391 * the type of data the user will be picking from.</p>
392 * </ol>
393 *
394 * <p>Given these capabilities, the following intents will resolve to the
395 * NotesList activity:</p>
396 *
397 * <ul>
398 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
399 * activities that can be used as top-level entry points into an
400 * application.</p>
401 * <li> <p><b>{ action=android.app.action.MAIN,
402 * category=android.app.category.LAUNCHER }</b> is the actual intent
403 * used by the Launcher to populate its top-level list.</p>
404 * <li> <p><b>{ action=android.intent.action.VIEW
405 * data=content://com.google.provider.NotePad/notes }</b>
406 * displays a list of all the notes under
407 * "content://com.google.provider.NotePad/notes", which
408 * the user can browse through and see the details on.</p>
409 * <li> <p><b>{ action=android.app.action.PICK
410 * data=content://com.google.provider.NotePad/notes }</b>
411 * provides a list of the notes under
412 * "content://com.google.provider.NotePad/notes", from which
413 * the user can pick a note whose data URL is returned back to the caller.</p>
414 * <li> <p><b>{ action=android.app.action.GET_CONTENT
415 * type=vnd.android.cursor.item/vnd.google.note }</b>
416 * is similar to the pick action, but allows the caller to specify the
417 * kind of data they want back so that the system can find the appropriate
418 * activity to pick something of that data type.</p>
419 * </ul>
420 *
421 * <p>The second activity,
422 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
423 * note entry and allows them to edit it. It can do two things as described
424 * by its two intent templates:
425 * <ol>
426 * <li><pre>
427 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
428 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
429 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
430 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
431 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
432 * &lt;/intent-filter&gt;</pre>
433 * <p>The first, primary, purpose of this activity is to let the user interact
434 * with a single note, as decribed by the MIME type
435 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
436 * either VIEW a note or allow the user to EDIT it. Again we support the
437 * DEFAULT category to allow the activity to be launched without explicitly
438 * specifying its component.</p>
439 * <li><pre>
440 * &lt;intent-filter&gt;
441 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
442 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
443 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
444 * &lt;/intent-filter&gt;</pre>
445 * <p>The secondary use of this activity is to insert a new note entry into
446 * an existing directory of notes. This is used when the user creates a new
447 * note: the INSERT action is executed on the directory of notes, causing
448 * this activity to run and have the user create the new note data which
449 * it then adds to the content provider.</p>
450 * </ol>
451 *
452 * <p>Given these capabilities, the following intents will resolve to the
453 * NoteEditor activity:</p>
454 *
455 * <ul>
456 * <li> <p><b>{ action=android.intent.action.VIEW
457 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
458 * shows the user the content of note <var>{ID}</var>.</p>
459 * <li> <p><b>{ action=android.app.action.EDIT
460 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
461 * allows the user to edit the content of note <var>{ID}</var>.</p>
462 * <li> <p><b>{ action=android.app.action.INSERT
463 * data=content://com.google.provider.NotePad/notes }</b>
464 * creates a new, empty note in the notes list at
465 * "content://com.google.provider.NotePad/notes"
466 * and allows the user to edit it. If they keep their changes, the URI
467 * of the newly created note is returned to the caller.</p>
468 * </ul>
469 *
470 * <p>The last activity,
471 * <code>com.android.notepad.TitleEditor</code>, allows the user to
472 * edit the title of a note. This could be implemented as a class that the
473 * application directly invokes (by explicitly setting its component in
474 * the Intent), but here we show a way you can publish alternative
475 * operations on existing data:</p>
476 *
477 * <pre>
478 * &lt;intent-filter android:label="@string/resolve_title"&gt;
479 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
480 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
481 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
482 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
483 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
484 * &lt;/intent-filter&gt;</pre>
485 *
486 * <p>In the single intent template here, we
487 * have created our own private action called
488 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
489 * edit the title of a note. It must be invoked on a specific note
490 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
491 * view and edit actions, but here displays and edits the title contained
492 * in the note data.
493 *
494 * <p>In addition to supporting the default category as usual, our title editor
495 * also supports two other standard categories: ALTERNATIVE and
496 * SELECTED_ALTERNATIVE. Implementing
497 * these categories allows others to find the special action it provides
498 * without directly knowing about it, through the
499 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
500 * more often to build dynamic menu items with
501 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
502 * template here was also supply an explicit name for the template
503 * (via <code>android:label="@string/resolve_title"</code>) to better control
504 * what the user sees when presented with this activity as an alternative
505 * action to the data they are viewing.
506 *
507 * <p>Given these capabilities, the following intent will resolve to the
508 * TitleEditor activity:</p>
509 *
510 * <ul>
511 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
512 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
513 * displays and allows the user to edit the title associated
514 * with note <var>{ID}</var>.</p>
515 * </ul>
516 *
517 * <h3>Standard Activity Actions</h3>
518 *
519 * <p>These are the current standard actions that Intent defines for launching
520 * activities (usually through {@link Context#startActivity}. The most
521 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
522 * {@link #ACTION_EDIT}.
523 *
524 * <ul>
525 * <li> {@link #ACTION_MAIN}
526 * <li> {@link #ACTION_VIEW}
527 * <li> {@link #ACTION_ATTACH_DATA}
528 * <li> {@link #ACTION_EDIT}
529 * <li> {@link #ACTION_PICK}
530 * <li> {@link #ACTION_CHOOSER}
531 * <li> {@link #ACTION_GET_CONTENT}
532 * <li> {@link #ACTION_DIAL}
533 * <li> {@link #ACTION_CALL}
534 * <li> {@link #ACTION_SEND}
535 * <li> {@link #ACTION_SENDTO}
536 * <li> {@link #ACTION_ANSWER}
537 * <li> {@link #ACTION_INSERT}
538 * <li> {@link #ACTION_DELETE}
539 * <li> {@link #ACTION_RUN}
540 * <li> {@link #ACTION_SYNC}
541 * <li> {@link #ACTION_PICK_ACTIVITY}
542 * <li> {@link #ACTION_SEARCH}
543 * <li> {@link #ACTION_WEB_SEARCH}
544 * <li> {@link #ACTION_FACTORY_TEST}
545 * </ul>
546 *
547 * <h3>Standard Broadcast Actions</h3>
548 *
549 * <p>These are the current standard actions that Intent defines for receiving
550 * broadcasts (usually through {@link Context#registerReceiver} or a
551 * &lt;receiver&gt; tag in a manifest).
552 *
553 * <ul>
554 * <li> {@link #ACTION_TIME_TICK}
555 * <li> {@link #ACTION_TIME_CHANGED}
556 * <li> {@link #ACTION_TIMEZONE_CHANGED}
557 * <li> {@link #ACTION_BOOT_COMPLETED}
558 * <li> {@link #ACTION_PACKAGE_ADDED}
559 * <li> {@link #ACTION_PACKAGE_CHANGED}
560 * <li> {@link #ACTION_PACKAGE_REMOVED}
561 * <li> {@link #ACTION_PACKAGE_RESTARTED}
562 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
563 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
564 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
565 * <li> {@link #ACTION_UID_REMOVED}
566 * <li> {@link #ACTION_BATTERY_CHANGED}
567 * <li> {@link #ACTION_POWER_CONNECTED}
568 * <li> {@link #ACTION_POWER_DISCONNECTED}
569 * <li> {@link #ACTION_SHUTDOWN}
570 * </ul>
571 *
572 * <h3>Standard Categories</h3>
573 *
574 * <p>These are the current standard categories that can be used to further
575 * clarify an Intent via {@link #addCategory}.
576 *
577 * <ul>
578 * <li> {@link #CATEGORY_DEFAULT}
579 * <li> {@link #CATEGORY_BROWSABLE}
580 * <li> {@link #CATEGORY_TAB}
581 * <li> {@link #CATEGORY_ALTERNATIVE}
582 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
583 * <li> {@link #CATEGORY_LAUNCHER}
584 * <li> {@link #CATEGORY_INFO}
585 * <li> {@link #CATEGORY_HOME}
586 * <li> {@link #CATEGORY_PREFERENCE}
587 * <li> {@link #CATEGORY_TEST}
588 * <li> {@link #CATEGORY_CAR_DOCK}
589 * <li> {@link #CATEGORY_DESK_DOCK}
590 * <li> {@link #CATEGORY_LE_DESK_DOCK}
591 * <li> {@link #CATEGORY_HE_DESK_DOCK}
592 * <li> {@link #CATEGORY_CAR_MODE}
593 * <li> {@link #CATEGORY_APP_MARKET}
594 * <li> {@link #CATEGORY_VR_HOME}
595 * </ul>
596 *
597 * <h3>Standard Extra Data</h3>
598 *
599 * <p>These are the current standard fields that can be used as extra data via
600 * {@link #putExtra}.
601 *
602 * <ul>
603 * <li> {@link #EXTRA_ALARM_COUNT}
604 * <li> {@link #EXTRA_BCC}
605 * <li> {@link #EXTRA_CC}
606 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
607 * <li> {@link #EXTRA_DATA_REMOVED}
608 * <li> {@link #EXTRA_DOCK_STATE}
609 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
610 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
611 * <li> {@link #EXTRA_DOCK_STATE_CAR}
612 * <li> {@link #EXTRA_DOCK_STATE_DESK}
613 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
614 * <li> {@link #EXTRA_DONT_KILL_APP}
615 * <li> {@link #EXTRA_EMAIL}
616 * <li> {@link #EXTRA_INITIAL_INTENTS}
617 * <li> {@link #EXTRA_INTENT}
618 * <li> {@link #EXTRA_KEY_EVENT}
619 * <li> {@link #EXTRA_ORIGINATING_URI}
620 * <li> {@link #EXTRA_PHONE_NUMBER}
621 * <li> {@link #EXTRA_REFERRER}
622 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
623 * <li> {@link #EXTRA_REPLACING}
624 * <li> {@link #EXTRA_SHORTCUT_ICON}
625 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
626 * <li> {@link #EXTRA_SHORTCUT_INTENT}
627 * <li> {@link #EXTRA_STREAM}
628 * <li> {@link #EXTRA_SHORTCUT_NAME}
629 * <li> {@link #EXTRA_SUBJECT}
630 * <li> {@link #EXTRA_TEMPLATE}
631 * <li> {@link #EXTRA_TEXT}
632 * <li> {@link #EXTRA_TITLE}
633 * <li> {@link #EXTRA_UID}
634 * </ul>
635 *
636 * <h3>Flags</h3>
637 *
638 * <p>These are the possible flags that can be used in the Intent via
639 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
640 * of all possible flags.
641 */
642public class Intent implements Parcelable, Cloneable {
643 private static final String TAG = "Intent";
644
645 private static final String ATTR_ACTION = "action";
646 private static final String TAG_CATEGORIES = "categories";
647 private static final String ATTR_CATEGORY = "category";
648 private static final String TAG_EXTRA = "extra";
649 private static final String ATTR_TYPE = "type";
650 private static final String ATTR_IDENTIFIER = "ident";
651 private static final String ATTR_COMPONENT = "component";
652 private static final String ATTR_DATA = "data";
653 private static final String ATTR_FLAGS = "flags";
654
655 // ---------------------------------------------------------------------
656 // ---------------------------------------------------------------------
657 // Standard intent activity actions (see action variable).
658
659 /**
660 * Activity Action: Start as a main entry point, does not expect to
661 * receive data.
662 * <p>Input: nothing
663 * <p>Output: nothing
664 */
665 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
666 public static final String ACTION_MAIN = "android.intent.action.MAIN";
667
668 /**
669 * Activity Action: Display the data to the user. This is the most common
670 * action performed on data -- it is the generic action you can use on
671 * a piece of data to get the most reasonable thing to occur. For example,
672 * when used on a contacts entry it will view the entry; when used on a
673 * mailto: URI it will bring up a compose window filled with the information
674 * supplied by the URI; when used with a tel: URI it will invoke the
675 * dialer.
676 * <p>Input: {@link #getData} is URI from which to retrieve data.
677 * <p>Output: nothing.
678 */
679 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
680 public static final String ACTION_VIEW = "android.intent.action.VIEW";
681
682 /**
683 * Extra that can be included on activity intents coming from the storage UI
684 * when it launches sub-activities to manage various types of storage. For example,
685 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
686 * the images on the device, and in that case also include this extra to tell the
687 * app it is coming from the storage UI so should help the user manage storage of
688 * this type.
689 */
690 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
691
692 /**
693 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
694 * performed on a piece of data.
695 */
696 public static final String ACTION_DEFAULT = ACTION_VIEW;
697
698 /**
699 * Activity Action: Quick view the data. Launches a quick viewer for
700 * a URI or a list of URIs.
701 * <p>Activities handling this intent action should handle the vast majority of
702 * MIME types rather than only specific ones.
703 * <p>Quick viewers must render the quick view image locally, and must not send
704 * file content outside current device.
705 * <p>Input: {@link #getData} is a mandatory content URI of the item to
706 * preview. {@link #getClipData} contains an optional list of content URIs
707 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
708 * optional index of the URI in the clip data to show first.
709 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
710 * that can be shown in the quick view UI.
711 * <p>Output: nothing.
712 * @see #EXTRA_INDEX
713 * @see #EXTRA_QUICK_VIEW_FEATURES
714 */
715 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
716 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
717
718 /**
719 * Used to indicate that some piece of data should be attached to some other
720 * place. For example, image data could be attached to a contact. It is up
721 * to the recipient to decide where the data should be attached; the intent
722 * does not specify the ultimate destination.
723 * <p>Input: {@link #getData} is URI of data to be attached.
724 * <p>Output: nothing.
725 */
726 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
727 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
728
729 /**
730 * Activity Action: Provide explicit editable access to the given data.
731 * <p>Input: {@link #getData} is URI of data to be edited.
732 * <p>Output: nothing.
733 */
734 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
735 public static final String ACTION_EDIT = "android.intent.action.EDIT";
736
737 /**
738 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
739 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
740 * The extras can contain type specific data to pass through to the editing/creating
741 * activity.
742 * <p>Output: The URI of the item that was picked. This must be a content:
743 * URI so that any receiver can access it.
744 */
745 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
746 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
747
748 /**
749 * Activity Action: Pick an item from the data, returning what was selected.
750 * <p>Input: {@link #getData} is URI containing a directory of data
751 * (vnd.android.cursor.dir/*) from which to pick an item.
752 * <p>Output: The URI of the item that was picked.
753 */
754 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
755 public static final String ACTION_PICK = "android.intent.action.PICK";
756
757 /**
758 * Activity Action: Creates a reminder.
759 * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user.
760 * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at
761 * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will be shown
762 * to the user. The time is specified in milliseconds since the Epoch (optional).
763 * </p>
764 * <p>Output: Nothing.</p>
765 *
766 * @see #EXTRA_TITLE
767 * @see #EXTRA_TEXT
768 * @see #EXTRA_TIME
769 */
770 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
771 public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER";
772
773 /**
774 * Activity Action: Creates a shortcut.
775 * <p>Input: Nothing.</p>
776 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
777 * <p>For compatibility with older versions of android the intent may also contain three
778 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
779 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
780 * (value: ShortcutIconResource).</p>
781 *
782 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
783 * @see #EXTRA_SHORTCUT_INTENT
784 * @see #EXTRA_SHORTCUT_NAME
785 * @see #EXTRA_SHORTCUT_ICON
786 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
787 * @see android.content.Intent.ShortcutIconResource
788 */
789 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
790 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
791
792 /**
793 * The name of the extra used to define the Intent of a shortcut.
794 *
795 * @see #ACTION_CREATE_SHORTCUT
796 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
797 */
798 @Deprecated
799 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
800 /**
801 * The name of the extra used to define the name of a shortcut.
802 *
803 * @see #ACTION_CREATE_SHORTCUT
804 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
805 */
806 @Deprecated
807 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
808 /**
809 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
810 *
811 * @see #ACTION_CREATE_SHORTCUT
812 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
813 */
814 @Deprecated
815 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
816 /**
817 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
818 *
819 * @see #ACTION_CREATE_SHORTCUT
820 * @see android.content.Intent.ShortcutIconResource
821 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
822 */
823 @Deprecated
824 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
825 "android.intent.extra.shortcut.ICON_RESOURCE";
826
827 /**
828 * An activity that provides a user interface for adjusting application preferences.
829 * Optional but recommended settings for all applications which have settings.
830 */
831 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
832 public static final String ACTION_APPLICATION_PREFERENCES
833 = "android.intent.action.APPLICATION_PREFERENCES";
834
835 /**
836 * Activity Action: Launch an activity showing the app information.
837 * For applications which install other applications (such as app stores), it is recommended
838 * to handle this action for providing the app information to the user.
839 *
840 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
841 * to be displayed.
842 * <p>Output: Nothing.
843 */
844 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
845 public static final String ACTION_SHOW_APP_INFO
846 = "android.intent.action.SHOW_APP_INFO";
847
848 /**
849 * Represents a shortcut/live folder icon resource.
850 *
851 * @see Intent#ACTION_CREATE_SHORTCUT
852 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
853 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
854 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
855 */
856 public static class ShortcutIconResource implements Parcelable {
857 /**
858 * The package name of the application containing the icon.
859 */
860 public String packageName;
861
862 /**
863 * The resource name of the icon, including package, name and type.
864 */
865 public String resourceName;
866
867 /**
868 * Creates a new ShortcutIconResource for the specified context and resource
869 * identifier.
870 *
871 * @param context The context of the application.
872 * @param resourceId The resource identifier for the icon.
873 * @return A new ShortcutIconResource with the specified's context package name
874 * and icon resource identifier.``
875 */
876 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
877 ShortcutIconResource icon = new ShortcutIconResource();
878 icon.packageName = context.getPackageName();
879 icon.resourceName = context.getResources().getResourceName(resourceId);
880 return icon;
881 }
882
883 /**
884 * Used to read a ShortcutIconResource from a Parcel.
885 */
886 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR =
887 new Parcelable.Creator<ShortcutIconResource>() {
888
889 public ShortcutIconResource createFromParcel(Parcel source) {
890 ShortcutIconResource icon = new ShortcutIconResource();
891 icon.packageName = source.readString8();
892 icon.resourceName = source.readString8();
893 return icon;
894 }
895
896 public ShortcutIconResource[] newArray(int size) {
897 return new ShortcutIconResource[size];
898 }
899 };
900
901 /**
902 * No special parcel contents.
903 */
904 public int describeContents() {
905 return 0;
906 }
907
908 public void writeToParcel(Parcel dest, int flags) {
909 dest.writeString8(packageName);
910 dest.writeString8(resourceName);
911 }
912
913 @Override
914 public String toString() {
915 return resourceName;
916 }
917 }
918
919 /**
920 * Activity Action: Display an activity chooser, allowing the user to pick
921 * what they want to before proceeding. This can be used as an alternative
922 * to the standard activity picker that is displayed by the system when
923 * you try to start an activity with multiple possible matches, with these
924 * differences in behavior:
925 * <ul>
926 * <li>You can specify the title that will appear in the activity chooser.
927 * <li>The user does not have the option to make one of the matching
928 * activities a preferred activity, and all possible activities will
929 * always be shown even if one of them is currently marked as the
930 * preferred activity.
931 * </ul>
932 * <p>
933 * This action should be used when the user will naturally expect to
934 * select an activity in order to proceed. An example if when not to use
935 * it is when the user clicks on a "mailto:" link. They would naturally
936 * expect to go directly to their mail app, so startActivity() should be
937 * called directly: it will
938 * either launch the current preferred app, or put up a dialog allowing the
939 * user to pick an app to use and optionally marking that as preferred.
940 * <p>
941 * In contrast, if the user is selecting a menu item to send a picture
942 * they are viewing to someone else, there are many different things they
943 * may want to do at this point: send it through e-mail, upload it to a
944 * web service, etc. In this case the CHOOSER action should be used, to
945 * always present to the user a list of the things they can do, with a
946 * nice title given by the caller such as "Send this photo with:".
947 * <p>
948 * If you need to grant URI permissions through a chooser, you must specify
949 * the permissions to be granted on the ACTION_CHOOSER Intent
950 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
951 * {@link #setClipData} to specify the URIs to be granted as well as
952 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
953 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
954 * <p>
955 * As a convenience, an Intent of this form can be created with the
956 * {@link #createChooser} function.
957 * <p>
958 * Input: No data should be specified. get*Extra must have
959 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
960 * and can optionally have a {@link #EXTRA_TITLE} field containing the
961 * title text to display in the chooser.
962 * <p>
963 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
964 */
965 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
966 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
967
968 /**
969 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
970 *
971 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
972 * target intent, also optionally supplying a title. If the target
973 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
974 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
975 * set in the returned chooser intent, with its ClipData set appropriately:
976 * either a direct reflection of {@link #getClipData()} if that is non-null,
977 * or a new ClipData built from {@link #getData()}.
978 *
979 * @param target The Intent that the user will be selecting an activity
980 * to perform.
981 * @param title Optional title that will be displayed in the chooser,
982 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
983 * @return Return a new Intent object that you can hand to
984 * {@link Context#startActivity(Intent) Context.startActivity()} and
985 * related methods.
986 */
987 public static Intent createChooser(Intent target, CharSequence title) {
988 return createChooser(target, title, null);
989 }
990
991 /**
992 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
993 *
994 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
995 * target intent, also optionally supplying a title. If the target
996 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
997 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
998 * set in the returned chooser intent, with its ClipData set appropriately:
999 * either a direct reflection of {@link #getClipData()} if that is non-null,
1000 * or a new ClipData built from {@link #getData()}.</p>
1001 *
1002 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
1003 * when the user makes a choice. This can be useful if the calling application wants
1004 * to remember the last chosen target and surface it as a more prominent or one-touch
1005 * affordance elsewhere in the UI for next time.</p>
1006 *
1007 * @param target The Intent that the user will be selecting an activity
1008 * to perform.
1009 * @param title Optional title that will be displayed in the chooser,
1010 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1011 * @param sender Optional IntentSender to be called when a choice is made.
1012 * @return Return a new Intent object that you can hand to
1013 * {@link Context#startActivity(Intent) Context.startActivity()} and
1014 * related methods.
1015 */
1016 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
1017 Intent intent = new Intent(ACTION_CHOOSER);
1018 intent.putExtra(EXTRA_INTENT, target);
1019 if (title != null) {
1020 intent.putExtra(EXTRA_TITLE, title);
1021 }
1022
1023 if (sender != null) {
1024 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
1025 }
1026
1027 // Migrate any clip data and flags from target.
1028 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1029 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1030 | FLAG_GRANT_PREFIX_URI_PERMISSION);
1031 if (permFlags != 0) {
1032 ClipData targetClipData = target.getClipData();
1033 if (targetClipData == null && target.getData() != null) {
1034 ClipData.Item item = new ClipData.Item(target.getData());
1035 String[] mimeTypes;
1036 if (target.getType() != null) {
1037 mimeTypes = new String[] { target.getType() };
1038 } else {
1039 mimeTypes = new String[] { };
1040 }
1041 targetClipData = new ClipData(null, mimeTypes, item);
1042 }
1043 if (targetClipData != null) {
1044 intent.setClipData(targetClipData);
1045 intent.addFlags(permFlags);
1046 }
1047 }
1048
1049 return intent;
1050 }
1051
1052 /**
1053 * Activity Action: Allow the user to select a particular kind of data and
1054 * return it. This is different than {@link #ACTION_PICK} in that here we
1055 * just say what kind of data is desired, not a URI of existing data from
1056 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
1057 * create the data as it runs (for example taking a picture or recording a
1058 * sound), let them browse over the web and download the desired data,
1059 * etc.
1060 * <p>
1061 * There are two main ways to use this action: if you want a specific kind
1062 * of data, such as a person contact, you set the MIME type to the kind of
1063 * data you want and launch it with {@link Context#startActivity(Intent)}.
1064 * The system will then launch the best application to select that kind
1065 * of data for you.
1066 * <p>
1067 * You may also be interested in any of a set of types of content the user
1068 * can pick. For example, an e-mail application that wants to allow the
1069 * user to add an attachment to an e-mail message can use this action to
1070 * bring up a list of all of the types of content the user can attach.
1071 * <p>
1072 * In this case, you should wrap the GET_CONTENT intent with a chooser
1073 * (through {@link #createChooser}), which will give the proper interface
1074 * for the user to pick how to send your data and allow you to specify
1075 * a prompt indicating what they are doing. You will usually specify a
1076 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1077 * broad range of content types the user can select from.
1078 * <p>
1079 * When using such a broad GET_CONTENT action, it is often desirable to
1080 * only pick from data that can be represented as a stream. This is
1081 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1082 * <p>
1083 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
1084 * the launched content chooser only returns results representing data that
1085 * is locally available on the device. For example, if this extra is set
1086 * to true then an image picker should not show any pictures that are available
1087 * from a remote server but not already on the local device (thus requiring
1088 * they be downloaded when opened).
1089 * <p>
1090 * If the caller can handle multiple returned items (the user performing
1091 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1092 * to indicate this.
1093 * <p>
1094 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1095 * that no URI is supplied in the intent, as there are no constraints on
1096 * where the returned data originally comes from. You may also include the
1097 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
1098 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
1099 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1100 * allow the user to select multiple items.
1101 * <p>
1102 * Output: The URI of the item that was picked. This must be a content:
1103 * URI so that any receiver can access it.
1104 */
1105 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1106 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1107 /**
1108 * Activity Action: Dial a number as specified by the data. This shows a
1109 * UI with the number being dialed, allowing the user to explicitly
1110 * initiate the call.
1111 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1112 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1113 * number.
1114 * <p>Output: nothing.
1115 */
1116 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1117 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1118 /**
1119 * Activity Action: Perform a call to someone specified by the data.
1120 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1121 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1122 * number.
1123 * <p>Output: nothing.
1124 *
1125 * <p>Note: there will be restrictions on which applications can initiate a
1126 * call; most applications should use the {@link #ACTION_DIAL}.
1127 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1128 * numbers. Applications can <strong>dial</strong> emergency numbers using
1129 * {@link #ACTION_DIAL}, however.
1130 *
1131 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
1132 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
1133 * permission which is not granted, then attempting to use this action will
1134 * result in a {@link java.lang.SecurityException}.
1135 */
1136 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1137 public static final String ACTION_CALL = "android.intent.action.CALL";
1138 /**
1139 * Activity Action: Perform a call to an emergency number specified by the
1140 * data.
1141 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1142 * tel: URI of an explicit phone number.
1143 * <p>Output: nothing.
1144 *
1145 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on
1146 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
1147 * extra (if specified) and may be placed on another {@link PhoneAccount} with the
1148 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external
1149 * factors, such as network conditions and Modem/SIM status.
1150 * @hide
1151 */
1152 @SystemApi
1153 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1154 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1155 /**
1156 * Activity Action: Dial a emergency number specified by the data. This shows a
1157 * UI with the number being dialed, allowing the user to explicitly
1158 * initiate the call.
1159 * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData}
1160 * is a tel: URI of an explicit emergency phone number.
1161 * <p>Output: nothing.
1162 * @hide
1163 */
1164 @SystemApi
1165 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1166 public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY";
1167 /**
1168 * Activity action: Perform a call to any number (emergency or not)
1169 * specified by the data.
1170 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1171 * tel: URI of an explicit phone number.
1172 * <p>Output: nothing.
1173 * @hide
1174 */
1175 @SystemApi
1176 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1177 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1178
1179 /**
1180 * Activity Action: Main entry point for carrier setup apps.
1181 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1182 * carrier service and typically require
1183 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1184 * fulfill their duties.
1185 */
1186 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1188 /**
1189 * Activity Action: Send a message to someone specified by the data.
1190 * <p>Input: {@link #getData} is URI describing the target.
1191 * <p>Output: nothing.
1192 */
1193 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1194 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1195 /**
1196 * Activity Action: Deliver some data to someone else. Who the data is
1197 * being delivered to is not specified; it is up to the receiver of this
1198 * action to ask the user where the data should be sent.
1199 * <p>
1200 * When launching a SEND intent, you should usually wrap it in a chooser
1201 * (through {@link #createChooser}), which will give the proper interface
1202 * for the user to pick how to send your data and allow you to specify
1203 * a prompt indicating what they are doing.
1204 * <p>
1205 * Input: {@link #getType} is the MIME type of the data being sent.
1206 * get*Extra can have either a {@link #EXTRA_TEXT}
1207 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1208 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1209 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1210 * if the MIME type is unknown (this will only allow senders that can
1211 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1212 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1213 * your text with HTML formatting.
1214 * <p>
1215 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1216 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1217 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1218 * content: URIs and other advanced features of {@link ClipData}. If
1219 * using this approach, you still must supply the same data through the
1220 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1221 * for compatibility with old applications. If you don't set a ClipData,
1222 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1223 * <p>
1224 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1225 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1226 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1227 * be openable only as asset typed files using
1228 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1229 * <p>
1230 * Optional standard extras, which may be interpreted by some recipients as
1231 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1232 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1233 * <p>
1234 * Output: nothing.
1235 */
1236 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237 public static final String ACTION_SEND = "android.intent.action.SEND";
1238 /**
1239 * Activity Action: Deliver multiple data to someone else.
1240 * <p>
1241 * Like {@link #ACTION_SEND}, except the data is multiple.
1242 * <p>
1243 * Input: {@link #getType} is the MIME type of the data being sent.
1244 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
1245 * #EXTRA_STREAM} field, containing the data to be sent. If using
1246 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1247 * for clients to retrieve your text with HTML formatting.
1248 * <p>
1249 * Multiple types are supported, and receivers should handle mixed types
1250 * whenever possible. The right way for the receiver to check them is to
1251 * use the content resolver on each URI. The intent sender should try to
1252 * put the most concrete mime type in the intent type, but it can fall
1253 * back to {@literal <type>/*} or {@literal *}/* as needed.
1254 * <p>
1255 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1256 * be image/jpg, but if you are sending image/jpg and image/png, then the
1257 * intent's type should be image/*.
1258 * <p>
1259 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1260 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1261 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1262 * content: URIs and other advanced features of {@link ClipData}. If
1263 * using this approach, you still must supply the same data through the
1264 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1265 * for compatibility with old applications. If you don't set a ClipData,
1266 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1267 * <p>
1268 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1269 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1270 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1271 * be openable only as asset typed files using
1272 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1273 * <p>
1274 * Optional standard extras, which may be interpreted by some recipients as
1275 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1276 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1277 * <p>
1278 * Output: nothing.
1279 */
1280 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1281 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1282 /**
1283 * Activity Action: Handle an incoming phone call.
1284 * <p>Input: nothing.
1285 * <p>Output: nothing.
1286 */
1287 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1289 /**
1290 * Activity Action: Insert an empty item into the given container.
1291 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1292 * in which to place the data.
1293 * <p>Output: URI of the new data that was created.
1294 */
1295 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1296 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1297 /**
1298 * Activity Action: Create a new item in the given container, initializing it
1299 * from the current contents of the clipboard.
1300 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1301 * in which to place the data.
1302 * <p>Output: URI of the new data that was created.
1303 */
1304 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1305 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1306 /**
1307 * Activity Action: Delete the given data from its container.
1308 * <p>Input: {@link #getData} is URI of data to be deleted.
1309 * <p>Output: nothing.
1310 */
1311 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1312 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1313 /**
1314 * Activity Action: Run the data, whatever that means.
1315 * <p>Input: ? (Note: this is currently specific to the test harness.)
1316 * <p>Output: nothing.
1317 */
1318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_RUN = "android.intent.action.RUN";
1320 /**
1321 * Activity Action: Perform a data synchronization.
1322 * <p>Input: ?
1323 * <p>Output: ?
1324 */
1325 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1326 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1327 /**
1328 * Activity Action: Pick an activity given an intent, returning the class
1329 * selected.
1330 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1331 * used with {@link PackageManager#queryIntentActivities} to determine the
1332 * set of activities from which to pick.
1333 * <p>Output: Class name of the activity that was selected.
1334 */
1335 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1336 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1337 /**
1338 * Activity Action: Perform a search.
1339 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1340 * is the text to search for. If empty, simply
1341 * enter your search results Activity with the search UI activated.
1342 * <p>Output: nothing.
1343 */
1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1346 /**
1347 * Activity Action: Start the platform-defined tutorial
1348 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1349 * is the text to search for. If empty, simply
1350 * enter your search results Activity with the search UI activated.
1351 * <p>Output: nothing.
1352 */
1353 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1354 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1355 /**
1356 * Activity Action: Perform a web search.
1357 * <p>
1358 * Input: {@link android.app.SearchManager#QUERY
1359 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1360 * a url starts with http or https, the site will be opened. If it is plain
1361 * text, Google search will be applied.
1362 * <p>
1363 * Output: nothing.
1364 */
1365 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1367
1368 /**
1369 * Activity Action: Perform assist action.
1370 * <p>
1371 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1372 * additional optional contextual information about where the user was when they
1373 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1374 * information.
1375 * Output: nothing.
1376 */
1377 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1378 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1379
1380 /**
1381 * Activity Action: Perform voice assist action.
1382 * <p>
1383 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1384 * additional optional contextual information about where the user was when they
1385 * requested the voice assist.
1386 * Output: nothing.
1387 * @hide
1388 */
1389 @SystemApi
1390 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1391 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1392
1393 /**
1394 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1395 * application package at the time the assist was invoked.
1396 */
1397 public static final String EXTRA_ASSIST_PACKAGE
1398 = "android.intent.extra.ASSIST_PACKAGE";
1399
1400 /**
1401 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1402 * application package at the time the assist was invoked.
1403 */
1404 public static final String EXTRA_ASSIST_UID
1405 = "android.intent.extra.ASSIST_UID";
1406
1407 /**
1408 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1409 * information supplied by the current foreground app at the time of the assist request.
1410 * This is a {@link Bundle} of additional data.
1411 */
1412 public static final String EXTRA_ASSIST_CONTEXT
1413 = "android.intent.extra.ASSIST_CONTEXT";
1414
1415 /**
1416 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1417 * keyboard as the primary input device for assistance.
1418 */
1419 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1420 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1421
1422 /**
1423 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1424 * that was used to invoke the assist.
1425 */
1426 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1427 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1428
1429 /**
1430 * Activity Action: List all available applications.
1431 * <p>Input: Nothing.
1432 * <p>Output: nothing.
1433 */
1434 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1435 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1436 /**
1437 * Activity Action: Show settings for choosing wallpaper.
1438 * <p>Input: Nothing.
1439 * <p>Output: Nothing.
1440 */
1441 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1442 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1443
1444 /**
1445 * Activity Action: Show activity for reporting a bug.
1446 * <p>Input: Nothing.
1447 * <p>Output: Nothing.
1448 */
1449 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1450 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1451
1452 /**
1453 * Activity Action: Main entry point for factory tests. Only used when
1454 * the device is booting in factory test node. The implementing package
1455 * must be installed in the system image.
1456 * <p>Input: nothing
1457 * <p>Output: nothing
1458 */
1459 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1460 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1461
1462 /**
1463 * Activity Action: The user pressed the "call" button to go to the dialer
1464 * or other appropriate UI for placing a call.
1465 * <p>Input: Nothing.
1466 * <p>Output: Nothing.
1467 */
1468 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1469 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1470
1471 /**
1472 * Activity Action: Start Voice Command.
1473 * <p>Input: Nothing.
1474 * <p>Output: Nothing.
1475 * <p class="note">
1476 * In some cases, a matching Activity may not exist, so ensure you
1477 * safeguard against this.
1478 */
1479 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1480 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1481
1482 /**
1483 * Activity Action: Start action associated with long pressing on the
1484 * search key.
1485 * <p>Input: Nothing.
1486 * <p>Output: Nothing.
1487 */
1488 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1489 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1490
1491 /**
1492 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1493 * This intent is delivered to the package which installed the application, usually
1494 * Google Play.
1495 * <p>Input: No data is specified. The bug report is passed in using
1496 * an {@link #EXTRA_BUG_REPORT} field.
1497 * <p>Output: Nothing.
1498 *
1499 * @see #EXTRA_BUG_REPORT
1500 */
1501 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1502 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1503
1504 /**
1505 * An incident or bug report has been taken, and a system app has requested it to be shared,
1506 * so trigger the confirmation screen.
1507 *
1508 * This will be sent directly to the registered receiver with the
1509 * android.permission.APPROVE_INCIDENT_REPORTS permission.
1510 * @hide
1511 */
1512 @SystemApi
1513 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1514 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1515
1516 /**
1517 * An incident report has been taken, and the user has approved it for sharing.
1518 * <p>
1519 * This will be sent directly to the registered receiver, which must have
1520 * both the DUMP and USAGE_STATS permissions.
1521 * <p>
1522 * After receiving this, the application should wait until a suitable time
1523 * (e.g. network available), get the list of available reports with
1524 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1525 * and then when the reports have been successfully uploaded, call
1526 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1527 *
1528 * @hide
1529 */
1530 @SystemApi
1531 public static final String ACTION_INCIDENT_REPORT_READY =
1532 "android.intent.action.INCIDENT_REPORT_READY";
1533
1534 /**
1535 * Activity Action: Show power usage information to the user.
1536 * <p>Input: Nothing.
1537 * <p>Output: Nothing.
1538 */
1539 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1540 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1541
1542 /**
1543 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1544 * to run.
1545 * <p>Input: Nothing.
1546 * <p>Output: Nothing.
1547 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1548 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1549 * @hide
1550 * @removed
1551 */
1552 @Deprecated
1553 @SystemApi
1554 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1555 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1556
1557 /**
1558 * Activity Action: Setup wizard to launch after a platform update. This
1559 * activity should have a string meta-data field associated with it,
1560 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1561 * the platform for setup. The activity will be launched only if
1562 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1563 * same value.
1564 * <p>Input: Nothing.
1565 * <p>Output: Nothing.
1566 * @hide
1567 */
1568 @SystemApi
1569 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1570 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1571
1572 /**
1573 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1574 * <p>Input: Nothing.
1575 * <p>Output: Nothing.
1576 * @hide
1577 */
1578 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1579 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1580 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1581
1582 /**
1583 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1584 * <p>Input: Nothing.
1585 * <p>Output: Nothing.
1586 * @hide
1587 */
1588 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1589 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1590 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1591
1592 /**
1593 * Activity Action: Show settings for managing network data usage of a
1594 * specific application. Applications should define an activity that offers
1595 * options to control data usage.
1596 */
1597 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1598 public static final String ACTION_MANAGE_NETWORK_USAGE =
1599 "android.intent.action.MANAGE_NETWORK_USAGE";
1600
1601 /**
1602 * Activity Action: Launch application installer.
1603 * <p>
1604 * Input: The data must be a content: URI at which the application
1605 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1606 * you can also use "package:<package-name>" to install an application for the
1607 * current user that is already installed for another user. You can optionally supply
1608 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1609 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1610 * <p>
1611 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1612 * succeeded.
1613 * <p>
1614 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
1615 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1616 * in order to launch the application installer.
1617 * </p>
1618 *
1619 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1620 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1621 * @see #EXTRA_RETURN_RESULT
1622 *
1623 * @deprecated use {@link android.content.pm.PackageInstaller} instead
1624 */
1625 @Deprecated
1626 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1627 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1628
1629 /**
1630 * Activity Action: Activity to handle split installation failures.
1631 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1632 * but the split that contains the application isn't installed. When a split is
1633 * installed in this manner, the containing package usually doesn't know this is
1634 * happening. However, if an error occurs during installation, the containing
1635 * package can define a single activity handling this action to deal with such
1636 * failures.
1637 * <p>The activity handling this action must be in the base package.
1638 * <p>
1639 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1640 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1641 */
1642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1643 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1644
1645 /**
1646 * Activity Action: Launch instant application installer.
1647 * <p class="note">
1648 * This is a protected intent that can only be sent by the system.
1649 * </p>
1650 *
1651 * @hide
1652 */
1653 @SystemApi
1654 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1655 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1656 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
1657
1658 /**
1659 * Service Action: Resolve instant application.
1660 * <p>
1661 * The system will have a persistent connection to this service.
1662 * This is a protected intent that can only be sent by the system.
1663 * </p>
1664 *
1665 * @hide
1666 */
1667 @SystemApi
1668 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1669 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1670 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
1671
1672 /**
1673 * Activity Action: Launch instant app settings.
1674 *
1675 * <p class="note">
1676 * This is a protected intent that can only be sent by the system.
1677 * </p>
1678 *
1679 * @hide
1680 */
1681 @SystemApi
1682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1683 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1684 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
1685
1686 /**
1687 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1688 * package. Specifies the installer package name; this package will receive the
1689 * {@link #ACTION_APP_ERROR} intent.
1690 */
1691 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1692 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1693
1694 /**
1695 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1696 * package. Specifies that the application being installed should not be
1697 * treated as coming from an unknown source, but as coming from the app
1698 * invoking the Intent. For this to work you must start the installer with
1699 * startActivityForResult().
1700 */
1701 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1702 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1703
1704 /**
1705 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1706 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
1707 * data field originated from.
1708 */
1709 public static final String EXTRA_ORIGINATING_URI
1710 = "android.intent.extra.ORIGINATING_URI";
1711
1712 /**
1713 * This extra can be used with any Intent used to launch an activity, supplying information
1714 * about who is launching that activity. This field contains a {@link android.net.Uri}
1715 * object, typically an http: or https: URI of the web site that the referral came from;
1716 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1717 * a native application that it came from.
1718 *
1719 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1720 * instead of directly retrieving the extra. It is also valid for applications to
1721 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1722 * a string, not a Uri; the field here, if supplied, will always take precedence,
1723 * however.</p>
1724 *
1725 * @see #EXTRA_REFERRER_NAME
1726 */
1727 public static final String EXTRA_REFERRER
1728 = "android.intent.extra.REFERRER";
1729
1730 /**
1731 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1732 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1733 * not be created, in particular when Intent extras are supplied through the
1734 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1735 * schemes.
1736 *
1737 * @see #EXTRA_REFERRER
1738 */
1739 public static final String EXTRA_REFERRER_NAME
1740 = "android.intent.extra.REFERRER_NAME";
1741
1742 /**
1743 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1744 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
1745 * Currently only a system app that hosts the provider authority "downloads" or holds the
1746 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
1747 * @hide
1748 */
1749 @SystemApi
1750 @TestApi
1751 public static final String EXTRA_ORIGINATING_UID
1752 = "android.intent.extra.ORIGINATING_UID";
1753
1754 /**
1755 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1756 * package. Tells the installer UI to skip the confirmation with the user
1757 * if the .apk is replacing an existing one.
1758 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1759 * will no longer show an interstitial message about updating existing
1760 * applications so this is no longer needed.
1761 */
1762 @Deprecated
1763 public static final String EXTRA_ALLOW_REPLACE
1764 = "android.intent.extra.ALLOW_REPLACE";
1765
1766 /**
1767 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1768 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1769 * return to the application the result code of the install/uninstall. The returned result
1770 * code will be {@link android.app.Activity#RESULT_OK} on success or
1771 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1772 */
1773 public static final String EXTRA_RETURN_RESULT
1774 = "android.intent.extra.RETURN_RESULT";
1775
1776 /**
1777 * Package manager install result code. @hide because result codes are not
1778 * yet ready to be exposed.
1779 */
1780 public static final String EXTRA_INSTALL_RESULT
1781 = "android.intent.extra.INSTALL_RESULT";
1782
1783 /**
1784 * Activity Action: Launch application uninstaller.
1785 * <p>
1786 * Input: The data must be a package: URI whose scheme specific part is
1787 * the package name of the current installed package to be uninstalled.
1788 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1789 * <p>
1790 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1791 * succeeded.
1792 * <p>
1793 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1794 * since {@link Build.VERSION_CODES#P}.
1795 *
1796 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1797 * instead
1798 */
1799 @Deprecated
1800 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1801 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1802
1803 /**
1804 * Specify whether the package should be uninstalled for all users.
1805 * @hide because these should not be part of normal application flow.
1806 */
1807 public static final String EXTRA_UNINSTALL_ALL_USERS
1808 = "android.intent.extra.UNINSTALL_ALL_USERS";
1809
1810 /**
1811 * A string that associates with a metadata entry, indicating the last run version of the
1812 * platform that was setup.
1813 *
1814 * @see #ACTION_UPGRADE_SETUP
1815 *
1816 * @hide
1817 */
1818 @SystemApi
1819 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1820
1821 /**
1822 * Activity action: Launch UI to manage the permissions of an app.
1823 * <p>
1824 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1825 * will be managed by the launched UI.
1826 * </p>
1827 * <p>
1828 * Output: Nothing.
1829 * </p>
1830 *
1831 * @see #EXTRA_PACKAGE_NAME
1832 *
1833 * @hide
1834 */
1835 @SystemApi
1836 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1837 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1838 "android.intent.action.MANAGE_APP_PERMISSIONS";
1839
1840 /**
1841 * Activity action: Launch UI to manage a specific permissions of an app.
1842 * <p>
1843 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1844 * will be managed by the launched UI.
1845 * </p>
1846 * <p>
1847 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1848 * that should be managed by the launched UI.
1849 * </p>
1850 * <p>
1851 * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1852 * </p>
1853 * <p>
1854 * Output: Nothing.
1855 * </p>
1856 *
1857 * @see #EXTRA_PACKAGE_NAME
1858 * @see #EXTRA_PERMISSION_NAME
1859 * @see #EXTRA_USER
1860 *
1861 * @hide
1862 */
1863 @SystemApi
1864 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1865 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1866 public static final String ACTION_MANAGE_APP_PERMISSION =
1867 "android.intent.action.MANAGE_APP_PERMISSION";
1868
1869 /**
1870 * Activity action: Launch UI to manage permissions.
1871 * <p>
1872 * Input: Nothing.
1873 * </p>
1874 * <p>
1875 * Output: Nothing.
1876 * </p>
1877 *
1878 * @hide
1879 */
1880 @SystemApi
1881 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1882 public static final String ACTION_MANAGE_PERMISSIONS =
1883 "android.intent.action.MANAGE_PERMISSIONS";
1884
1885 /**
1886 * Activity action: Launch UI to manage auto-revoke state.
1887 * <p>
1888 * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with
1889 * a package name, whose auto-revoke state will be reviewed (mandatory).
1890 * E.g. {@code Uri.fromParts("package", packageName, null) }
1891 * </p>
1892 * <p>
1893 * Output: Nothing.
1894 * </p>
1895 */
1896 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1897 public static final String ACTION_AUTO_REVOKE_PERMISSIONS =
1898 "android.intent.action.AUTO_REVOKE_PERMISSIONS";
1899
1900 /**
1901 * Activity action: Launch UI to review permissions for an app.
1902 * The system uses this intent if permission review for apps not
1903 * supporting the new runtime permissions model is enabled. In
1904 * this mode a permission review is required before any of the
1905 * app components can run.
1906 * <p>
1907 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1908 * permissions will be reviewed (mandatory).
1909 * </p>
1910 * <p>
1911 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1912 * be fired after the permission review (optional).
1913 * </p>
1914 * <p>
1915 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1916 * be invoked after the permission review (optional).
1917 * </p>
1918 * <p>
1919 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1920 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1921 * </p>
1922 * <p>
1923 * Output: Nothing.
1924 * </p>
1925 *
1926 * @see #EXTRA_PACKAGE_NAME
1927 * @see #EXTRA_INTENT
1928 * @see #EXTRA_REMOTE_CALLBACK
1929 * @see #EXTRA_RESULT_NEEDED
1930 *
1931 * @hide
1932 */
1933 @SystemApi
1934 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1935 public static final String ACTION_REVIEW_PERMISSIONS =
1936 "android.intent.action.REVIEW_PERMISSIONS";
1937
1938 /**
1939 * Activity action: Launch UI to show information about the usage
1940 * of a given permission. This action would be handled by apps that
1941 * want to show details about how and why given permission is being
1942 * used.
1943 * <p>
1944 * <strong>Important:</strong>You must protect the activity that handles
1945 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE
1946 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the
1947 * system can launch this activity. The system will not launch
1948 * activities that are not properly protected.
1949 *
1950 * <p>
1951 * Input: {@code android.intent.extra.PERMISSION_NAME} specifies the permission
1952 * for which the launched UI would be targeted.
1953 * </p>
1954 * <p>
1955 * Output: Nothing.
1956 * </p>
1957 */
1958 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1959 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
1960 public static final String ACTION_VIEW_PERMISSION_USAGE =
1961 "android.intent.action.VIEW_PERMISSION_USAGE";
1962
1963 /**
1964 * Activity action: Launch UI to manage a default app.
1965 * <p>
1966 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
1967 * by the launched UI.
1968 * </p>
1969 * <p>
1970 * Output: Nothing.
1971 * </p>
1972 *
1973 * @hide
1974 */
1975 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1976 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1977 @SystemApi
1978 @TestApi
1979 public static final String ACTION_MANAGE_DEFAULT_APP =
1980 "android.intent.action.MANAGE_DEFAULT_APP";
1981
1982 /**
1983 * Intent extra: A role name.
1984 * <p>
1985 * Type: String
1986 * </p>
1987 *
1988 * @see android.app.role.RoleManager
1989 *
1990 * @hide
1991 */
1992 @SystemApi
1993 @TestApi
1994 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
1995
1996 /**
1997 * Activity action: Launch UI to manage special app accesses.
1998 * <p>
1999 * Input: Nothing.
2000 * </p>
2001 * <p>
2002 * Output: Nothing.
2003 * </p>
2004 *
2005 * @hide
2006 */
2007 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2008 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2009 @SystemApi
2010 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
2011 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
2012
2013 /**
2014 * Intent extra: A callback for reporting remote result as a bundle.
2015 * <p>
2016 * Type: IRemoteCallback
2017 * </p>
2018 *
2019 * @hide
2020 */
2021 @SystemApi
2022 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
2023
2024 /**
2025 * Intent extra: An app package name.
2026 * <p>
2027 * Type: String
2028 * </p>
2029 *
2030 */
2031 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
2032
2033 /**
2034 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
2035 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
2036 *
2037 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
2038 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
2039 * This is meant to enable the suspended app to better handle the state of being suspended.
2040 *
2041 * @see #ACTION_MY_PACKAGE_SUSPENDED
2042 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2043 * @see PackageManager#isPackageSuspended()
2044 * @see PackageManager#getSuspendedPackageAppExtras()
2045 */
2046 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
2047
2048 /**
2049 * Intent extra: An app split name.
2050 * <p>
2051 * Type: String
2052 * </p>
2053 */
2054 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
2055
2056 /**
2057 * Intent extra: A {@link ComponentName} value.
2058 * <p>
2059 * Type: String
2060 * </p>
2061 */
2062 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
2063
2064 /**
2065 * Intent extra: An extra for specifying whether a result is needed.
2066 * <p>
2067 * Type: boolean
2068 * </p>
2069 *
2070 * @hide
2071 */
2072 @SystemApi
2073 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
2074
2075 /**
2076 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with
2077 * {@link #ACTION_SEND}.
2078 *
2079 * @see ShortcutInfo#getId()
2080 *
2081 * <p>
2082 * Type: String
2083 * </p>
2084 */
2085 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2086
2087 /**
2088 * Activity action: Launch UI to manage which apps have a given permission.
2089 * <p>
2090 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
2091 * which will be managed by the launched UI.
2092 * </p>
2093 * <p>
2094 * Output: Nothing.
2095 * </p>
2096 *
2097 * @see #EXTRA_PERMISSION_NAME
2098 *
2099 * @hide
2100 */
2101 @SystemApi
2102 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2103 public static final String ACTION_MANAGE_PERMISSION_APPS =
2104 "android.intent.action.MANAGE_PERMISSION_APPS";
2105
2106 /**
2107 * Intent extra: The name of a permission.
2108 * <p>
2109 * Type: String
2110 * </p>
2111 *
2112 * @hide
2113 */
2114 @SystemApi
2115 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2116
2117 /**
2118 * Intent extra: The name of a permission group.
2119 * <p>
2120 * Type: String
2121 * </p>
2122 *
2123 * @hide
2124 */
2125 @SystemApi
2126 public static final String EXTRA_PERMISSION_GROUP_NAME =
2127 "android.intent.extra.PERMISSION_GROUP_NAME";
2128
2129 /**
2130 * Intent extra: The number of milliseconds.
2131 * <p>
2132 * Type: long
2133 * </p>
2134 */
2135 public static final String EXTRA_DURATION_MILLIS =
2136 "android.intent.extra.DURATION_MILLIS";
2137
2138 /**
2139 * Activity action: Launch UI to review app uses of permissions.
2140 * <p>
2141 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
2142 * that will be displayed by the launched UI. Do not pass both this and
2143 * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2144 * </p>
2145 * <p>
2146 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2147 * that will be displayed by the launched UI. Do not pass both this and
2148 * {@link #EXTRA_PERMISSION_NAME}.
2149 * </p>
2150 * <p>
2151 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2152 * activity to show (optional). Must be non-negative.
2153 * </p>
2154 * <p>
2155 * Output: Nothing.
2156 * </p>
2157 * <p class="note">
2158 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2159 * </p>
2160 *
2161 * @see #EXTRA_PERMISSION_NAME
2162 * @see #EXTRA_PERMISSION_GROUP_NAME
2163 * @see #EXTRA_DURATION_MILLIS
2164 *
2165 * @hide
2166 */
2167 @SystemApi
2168 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2169 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2170 public static final String ACTION_REVIEW_PERMISSION_USAGE =
2171 "android.intent.action.REVIEW_PERMISSION_USAGE";
2172
2173 /**
2174 * Activity action: Launch UI to review ongoing app uses of permissions.
2175 * <p>
2176 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2177 * activity to show (optional). Must be non-negative.
2178 * </p>
2179 * <p>
2180 * Output: Nothing.
2181 * </p>
2182 * <p class="note">
2183 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2184 * </p>
2185 *
2186 * @see #EXTRA_DURATION_MILLIS
2187 *
2188 * @hide
2189 */
2190 @SystemApi
2191 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2192 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2193 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE =
2194 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE";
2195
2196 /**
2197 * Activity action: Launch UI to review running accessibility services.
2198 * <p>
2199 * Input: Nothing.
2200 * </p>
2201 * <p>
2202 * Output: Nothing.
2203 * </p>
2204 *
2205 * @hide
2206 */
2207 @SystemApi
2208 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES)
2209 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2210 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2211 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2212
2213 // ---------------------------------------------------------------------
2214 // ---------------------------------------------------------------------
2215 // Standard intent broadcast actions (see action variable).
2216
2217 /**
2218 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2219 * <p>
2220 * For historical reasons, the name of this broadcast action refers to the power
2221 * state of the screen but it is actually sent in response to changes in the
2222 * overall interactive state of the device.
2223 * </p><p>
2224 * This broadcast is sent when the device becomes non-interactive which may have
2225 * nothing to do with the screen turning off. To determine the
2226 * actual state of the screen, use {@link android.view.Display#getState}.
2227 * </p><p>
2228 * See {@link android.os.PowerManager#isInteractive} for details.
2229 * </p>
2230 * You <em>cannot</em> receive this through components declared in
2231 * manifests, only by explicitly registering for it with
2232 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2233 * Context.registerReceiver()}.
2234 *
2235 * <p class="note">This is a protected intent that can only be sent
2236 * by the system.
2237 */
2238 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2239 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
2240
2241 /**
2242 * Broadcast Action: Sent when the device wakes up and becomes interactive.
2243 * <p>
2244 * For historical reasons, the name of this broadcast action refers to the power
2245 * state of the screen but it is actually sent in response to changes in the
2246 * overall interactive state of the device.
2247 * </p><p>
2248 * This broadcast is sent when the device becomes interactive which may have
2249 * nothing to do with the screen turning on. To determine the
2250 * actual state of the screen, use {@link android.view.Display#getState}.
2251 * </p><p>
2252 * See {@link android.os.PowerManager#isInteractive} for details.
2253 * </p>
2254 * You <em>cannot</em> receive this through components declared in
2255 * manifests, only by explicitly registering for it with
2256 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2257 * Context.registerReceiver()}.
2258 *
2259 * <p class="note">This is a protected intent that can only be sent
2260 * by the system.
2261 */
2262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2263 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
2264
2265 /**
2266 * Broadcast Action: Sent after the system stops dreaming.
2267 *
2268 * <p class="note">This is a protected intent that can only be sent by the system.
2269 * It is only sent to registered receivers.</p>
2270 */
2271 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2272 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2273
2274 /**
2275 * Broadcast Action: Sent after the system starts dreaming.
2276 *
2277 * <p class="note">This is a protected intent that can only be sent by the system.
2278 * It is only sent to registered receivers.</p>
2279 */
2280 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2281 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2282
2283 /**
2284 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
2285 * keyguard is gone).
2286 *
2287 * <p class="note">This is a protected intent that can only be sent
2288 * by the system.
2289 */
2290 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2291 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
2292
2293 /**
2294 * Broadcast Action: The current time has changed. Sent every
2295 * minute. You <em>cannot</em> receive this through components declared
2296 * in manifests, only by explicitly registering for it with
2297 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2298 * Context.registerReceiver()}.
2299 *
2300 * <p class="note">This is a protected intent that can only be sent
2301 * by the system.
2302 */
2303 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2304 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2305 /**
2306 * Broadcast Action: The time was set.
2307 */
2308 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2309 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2310 /**
2311 * Broadcast Action: The date has changed.
2312 */
2313 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2314 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2315 /**
2316 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2317 * <ul>
2318 * <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new
2319 * time zone.</li>
2320 * </ul>
2321 *
2322 * <p class="note">This is a protected intent that can only be sent
2323 * by the system.
2324 */
2325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2326 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2327 /**
2328 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2329 * DNS entries should be tossed.
2330 * @hide
2331 */
2332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2333 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2334 /**
2335 * Alarm Changed Action: This is broadcast when the AlarmClock
2336 * application's alarm is set or unset. It is used by the
2337 * AlarmClock application and the StatusBar service.
2338 * @hide
2339 */
2340 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2341 @UnsupportedAppUsage
2342 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
2343
2344 /**
2345 * Broadcast Action: This is broadcast once, after the user has finished
2346 * booting, but while still in the "locked" state. It can be used to perform
2347 * application-specific initialization, such as installing alarms. You must
2348 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2349 * permission in order to receive this broadcast.
2350 * <p>
2351 * This broadcast is sent immediately at boot by all devices (regardless of
2352 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2353 * higher. Upon receipt of this broadcast, the user is still locked and only
2354 * device-protected storage can be accessed safely. If you want to access
2355 * credential-protected storage, you need to wait for the user to be
2356 * unlocked (typically by entering their lock pattern or PIN for the first
2357 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2358 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2359 * <p>
2360 * To receive this broadcast, your receiver component must be marked as
2361 * being {@link ComponentInfo#directBootAware}.
2362 * <p class="note">
2363 * This is a protected intent that can only be sent by the system.
2364 *
2365 * @see Context#createDeviceProtectedStorageContext()
2366 */
2367 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2368 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2369
2370 /**
2371 * Broadcast Action: This is broadcast once, after the user has finished
2372 * booting. It can be used to perform application-specific initialization,
2373 * such as installing alarms. You must hold the
2374 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2375 * order to receive this broadcast.
2376 * <p>
2377 * This broadcast is sent at boot by all devices (both with and without
2378 * direct boot support). Upon receipt of this broadcast, the user is
2379 * unlocked and both device-protected and credential-protected storage can
2380 * accessed safely.
2381 * <p>
2382 * If you need to run while the user is still locked (before they've entered
2383 * their lock pattern or PIN for the first time), you can listen for the
2384 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2385 * <p class="note">
2386 * This is a protected intent that can only be sent by the system.
2387 */
2388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2389 @BroadcastBehavior(includeBackground = true)
2390 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
2391
2392 /**
2393 * Broadcast Action: This is broadcast when a user action should request a
2394 * temporary system dialog to dismiss. Some examples of temporary system
2395 * dialogs are the notification window-shade and the recent tasks dialog.
2396 */
2397 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2398 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2399 /**
2400 * Broadcast Action: Trigger the download and eventual installation
2401 * of a package.
2402 * <p>Input: {@link #getData} is the URI of the package file to download.
2403 *
2404 * <p class="note">This is a protected intent that can only be sent
2405 * by the system.
2406 *
2407 * @deprecated This constant has never been used.
2408 */
2409 @Deprecated
2410 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2411 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2412 /**
2413 * Broadcast Action: A new application package has been installed on the
2414 * device. The data contains the name of the package. Note that the
2415 * newly installed package does <em>not</em> receive this broadcast.
2416 * <p>May include the following extras:
2417 * <ul>
2418 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2419 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2420 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2421 * </ul>
2422 *
2423 * <p class="note">This is a protected intent that can only be sent
2424 * by the system.
2425 */
2426 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2427 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2428 /**
2429 * Broadcast Action: A new version of an application package has been
2430 * installed, replacing an existing version that was previously installed.
2431 * The data contains the name of the package.
2432 * <p>May include the following extras:
2433 * <ul>
2434 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2435 * </ul>
2436 *
2437 * <p class="note">This is a protected intent that can only be sent
2438 * by the system.
2439 */
2440 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2441 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2442 /**
2443 * Broadcast Action: A new version of your application has been installed
2444 * over an existing one. This is only sent to the application that was
2445 * replaced. It does not contain any additional data; to receive it, just
2446 * use an intent filter for this action.
2447 *
2448 * <p class="note">This is a protected intent that can only be sent
2449 * by the system.
2450 */
2451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2452 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2453 /**
2454 * Broadcast Action: An existing application package has been removed from
2455 * the device. The data contains the name of the package. The package
2456 * that is being removed does <em>not</em> receive this Intent.
2457 * <ul>
2458 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2459 * to the package.
2460 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2461 * application -- data and code -- is being removed.
2462 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2463 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2464 * </ul>
2465 *
2466 * <p class="note">This is a protected intent that can only be sent
2467 * by the system.
2468 */
2469 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2470 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2471 /**
2472 * Broadcast Action: An existing application package has been completely
2473 * removed from the device. The data contains the name of the package.
2474 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2475 * {@link #EXTRA_DATA_REMOVED} is true and
2476 * {@link #EXTRA_REPLACING} is false of that broadcast.
2477 *
2478 * <ul>
2479 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2480 * to the package.
2481 * </ul>
2482 *
2483 * <p class="note">This is a protected intent that can only be sent
2484 * by the system.
2485 */
2486 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2487 public static final String ACTION_PACKAGE_FULLY_REMOVED
2488 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2489 /**
2490 * Broadcast Action: An existing application package has been changed (for
2491 * example, a component has been enabled or disabled). The data contains
2492 * the name of the package.
2493 * <ul>
2494 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2495 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
2496 * of the changed components (or the package name itself).
2497 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2498 * default action of restarting the application.
2499 * </ul>
2500 *
2501 * <p class="note">This is a protected intent that can only be sent
2502 * by the system.
2503 */
2504 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2505 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2506 /**
2507 * Broadcast Action: Sent to the system rollback manager when a package
2508 * needs to have rollback enabled.
2509 * <p class="note">
2510 * This is a protected intent that can only be sent by the system.
2511 * </p>
2512 *
2513 * @hide This broadcast is used internally by the system.
2514 */
2515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2516 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2517 "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2518 /**
2519 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain
2520 * package needs to be cancelled.
2521 *
2522 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager
2523 * that enabling a specific rollback has timed out.
2524 *
2525 * @hide
2526 */
2527 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2528 public static final String ACTION_CANCEL_ENABLE_ROLLBACK =
2529 "android.intent.action.CANCEL_ENABLE_ROLLBACK";
2530 /**
2531 * Broadcast Action: A rollback has been committed.
2532 *
2533 * <p class="note">This is a protected intent that can only be sent
2534 * by the system. The receiver must hold MANAGE_ROLLBACK permission.
2535 *
2536 * @hide
2537 */
2538 @SystemApi @TestApi
2539 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2540 public static final String ACTION_ROLLBACK_COMMITTED =
2541 "android.intent.action.ROLLBACK_COMMITTED";
2542 /**
2543 * @hide
2544 * Broadcast Action: Ask system services if there is any reason to
2545 * restart the given package. The data contains the name of the
2546 * package.
2547 * <ul>
2548 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2549 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2550 * </ul>
2551 *
2552 * <p class="note">This is a protected intent that can only be sent
2553 * by the system.
2554 */
2555 @SystemApi
2556 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2557 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2558 /**
2559 * Broadcast Action: The user has restarted a package, and all of its
2560 * processes have been killed. All runtime state
2561 * associated with it (processes, alarms, notifications, etc) should
2562 * be removed. Note that the restarted package does <em>not</em>
2563 * receive this broadcast.
2564 * The data contains the name of the package.
2565 * <ul>
2566 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2567 * </ul>
2568 *
2569 * <p class="note">This is a protected intent that can only be sent
2570 * by the system.
2571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2573 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2574 /**
2575 * Broadcast Action: The user has cleared the data of a package. This should
2576 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
2577 * its persistent data is erased and this broadcast sent.
2578 * Note that the cleared package does <em>not</em>
2579 * receive this broadcast. The data contains the name of the package.
2580 * <ul>
2581 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2582 * package whose data was cleared is an uninstalled instant app, then the UID
2583 * will be -1. The platform keeps some meta-data associated with instant apps
2584 * after they are uninstalled.
2585 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2586 * data was for an instant app.
2587 * </ul>
2588 *
2589 * <p class="note">This is a protected intent that can only be sent
2590 * by the system.
2591 */
2592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2593 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2594 /**
2595 * Broadcast Action: Packages have been suspended.
2596 * <p>Includes the following extras:
2597 * <ul>
2598 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2599 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
2600 * </ul>
2601 *
2602 * <p class="note">This is a protected intent that can only be sent
2603 * by the system. It is only sent to registered receivers.
2604 */
2605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2606 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2607 /**
2608 * Broadcast Action: Packages have been unsuspended.
2609 * <p>Includes the following extras:
2610 * <ul>
2611 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2612 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
2613 * </ul>
2614 *
2615 * <p class="note">This is a protected intent that can only be sent
2616 * by the system. It is only sent to registered receivers.
2617 */
2618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2619 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2620
2621 /**
2622 * Broadcast Action: Distracting packages have been changed.
2623 * <p>Includes the following extras:
2624 * <ul>
2625 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2626 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2627 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2628 * </ul>
2629 *
2630 * <p class="note">This is a protected intent that can only be sent
2631 * by the system. It is only sent to registered receivers.
2632 *
2633 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2634 * @hide
2635 */
2636 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2637 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2638 "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2639
2640 /**
2641 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
2642 * whenever a package is put into a suspended state or any of its app extras change while in the
2643 * suspended state.
2644 * <p> Optionally includes the following extras:
2645 * <ul>
2646 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2647 * useful information for the app being suspended.
2648 * </ul>
2649 * <p class="note">This is a protected intent that can only be sent
2650 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2651 * the manifest.</em>
2652 *
2653 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2654 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2655 * @see PackageManager#isPackageSuspended()
2656 * @see PackageManager#getSuspendedPackageAppExtras()
2657 */
2658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2659 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2660
2661 /**
2662 * Activity Action: Started to show more details about why an application was suspended.
2663 *
2664 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2665 * be used to show more details about the reason for suspension.
2666 *
2667 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2668 * handling this intent and protect it with
2669 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2670 *
2671 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2672 *
2673 * <p class="note">This is a protected intent that can only be sent
2674 * by the system.
2675 *
2676 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2677 * PersistableBundle, String)
2678 * @see PackageManager#isPackageSuspended()
2679 * @see #ACTION_PACKAGES_SUSPENDED
2680 *
2681 * @hide
2682 */
2683 @SystemApi
2684 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2685 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2686 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2687
2688 /**
2689 * Broadcast Action: Sent to indicate that the user unsuspended a package.
2690 *
2691 * <p>This can happen when the user taps on the neutral button of the
2692 * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using
2693 * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the
2694 * suspending app that originally specified this dialog while calling
2695 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2696 * PersistableBundle, SuspendDialogInfo)}.
2697 *
2698 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just
2699 * got unsuspended.
2700 *
2701 * <p class="note">This is a protected intent that can only be sent
2702 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2703 * the manifest.</em>
2704 *
2705 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2706 * PersistableBundle, SuspendDialogInfo)
2707 * @see PackageManager#isPackageSuspended()
2708 * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS
2709 * @hide
2710 */
2711 @SystemApi
2712 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2713 public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY =
2714 "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY";
2715
2716 /**
2717 * Broadcast Action: Sent to a package that has been unsuspended.
2718 *
2719 * <p class="note">This is a protected intent that can only be sent
2720 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2721 * the manifest.</em>
2722 *
2723 * @see #ACTION_MY_PACKAGE_SUSPENDED
2724 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2725 * @see PackageManager#isPackageSuspended()
2726 * @see PackageManager#getSuspendedPackageAppExtras()
2727 */
2728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2729 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2730
2731 /**
2732 * Broadcast Action: A user ID has been removed from the system. The user
2733 * ID number is stored in the extra data under {@link #EXTRA_UID}.
2734 *
2735 * <p class="note">This is a protected intent that can only be sent
2736 * by the system.
2737 */
2738 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2739 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
2740
2741 /**
2742 * Broadcast Action: Sent to the installer package of an application when
2743 * that application is first launched (that is the first time it is moved
2744 * out of the stopped state). The data contains the name of the package.
2745 *
2746 * <p>When the application is first launched, the application itself doesn't receive this
2747 * broadcast.</p>
2748 *
2749 * <p class="note">This is a protected intent that can only be sent
2750 * by the system.
2751 */
2752 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2753 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2754
2755 /**
2756 * Broadcast Action: Sent to the system package verifier when a package
2757 * needs to be verified. The data contains the package URI.
2758 * <p class="note">
2759 * This is a protected intent that can only be sent by the system.
2760 * </p>
2761 */
2762 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2763 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2764
2765 /**
2766 * Broadcast Action: Sent to the system package verifier when a package is
2767 * verified. The data contains the package URI.
2768 * <p class="note">
2769 * This is a protected intent that can only be sent by the system.
2770 */
2771 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2772 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2773
2774 /**
2775 * Broadcast Action: Sent to the system intent filter verifier when an
2776 * intent filter needs to be verified. The data contains the filter data
2777 * hosts to be verified against.
2778 * <p class="note">
2779 * This is a protected intent that can only be sent by the system.
2780 * </p>
2781 *
2782 * @hide
2783 */
2784 @SystemApi
2785 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2786 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2787
2788 /**
2789 * Broadcast Action: Resources for a set of packages (which were
2790 * previously unavailable) are currently
2791 * available since the media on which they exist is available.
2792 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2793 * list of packages whose availability changed.
2794 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2795 * list of uids of packages whose availability changed.
2796 * Note that the
2797 * packages in this list do <em>not</em> receive this broadcast.
2798 * The specified set of packages are now available on the system.
2799 * <p>Includes the following extras:
2800 * <ul>
2801 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2802 * whose resources(were previously unavailable) are currently available.
2803 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2804 * packages whose resources(were previously unavailable)
2805 * are currently available.
2806 * </ul>
2807 *
2808 * <p class="note">This is a protected intent that can only be sent
2809 * by the system.
2810 */
2811 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2812 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2813 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
2814
2815 /**
2816 * Broadcast Action: Resources for a set of packages are currently
2817 * unavailable since the media on which they exist is unavailable.
2818 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2819 * list of packages whose availability changed.
2820 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2821 * list of uids of packages whose availability changed.
2822 * The specified set of packages can no longer be
2823 * launched and are practically unavailable on the system.
2824 * <p>Inclues the following extras:
2825 * <ul>
2826 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2827 * whose resources are no longer available.
2828 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2829 * whose resources are no longer available.
2830 * </ul>
2831 *
2832 * <p class="note">This is a protected intent that can only be sent
2833 * by the system.
2834 */
2835 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2836 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
2837 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
2838
2839 /**
2840 * Broadcast Action: preferred activities have changed *explicitly*.
2841 *
2842 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2843 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2844 * be sent.
2845 *
2846 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2847 *
2848 * @hide
2849 */
2850 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2851 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2852 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2853
2854
2855 /**
2856 * Broadcast Action: The current system wallpaper has changed. See
2857 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
2858 * This should <em>only</em> be used to determine when the wallpaper
2859 * has changed to show the new wallpaper to the user. You should certainly
2860 * never, in response to this, change the wallpaper or other attributes of
2861 * it such as the suggested size. That would be crazy, right? You'd cause
2862 * all kinds of loops, especially if other apps are doing similar things,
2863 * right? Of course. So please don't do this.
2864 *
2865 * @deprecated Modern applications should use
2866 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2867 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2868 * shown behind their UI, rather than watching for this broadcast and
2869 * rendering the wallpaper on their own.
2870 */
2871 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2872 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2873 /**
2874 * Broadcast Action: The current device {@link android.content.res.Configuration}
2875 * (orientation, locale, etc) has changed. When such a change happens, the
2876 * UIs (view hierarchy) will need to be rebuilt based on this new
2877 * information; for the most part, applications don't need to worry about
2878 * this, because the system will take care of stopping and restarting the
2879 * application to make sure it sees the new changes. Some system code that
2880 * can not be restarted will need to watch for this action and handle it
2881 * appropriately.
2882 *
2883 * <p class="note">
2884 * You <em>cannot</em> receive this through components declared
2885 * in manifests, only by explicitly registering for it with
2886 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2887 * Context.registerReceiver()}.
2888 *
2889 * <p class="note">This is a protected intent that can only be sent
2890 * by the system.
2891 *
2892 * @see android.content.res.Configuration
2893 */
2894 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2895 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2896
2897 /**
2898 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2899 * such that the device may be eligible for the installation of additional configuration splits.
2900 * Configuration properties that can trigger this broadcast include locale and display density.
2901 *
2902 * <p class="note">
2903 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2904 * components declared in manifests. However, the receiver <em>must</em> hold the
2905 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2906 *
2907 * <p class="note">
2908 * This is a protected intent that can only be sent by the system.
2909 *
2910 * @hide
2911 */
2912 @SystemApi
2913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2914 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2915 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
2916 /**
2917 * Broadcast Action: The current device's locale has changed.
2918 *
2919 * <p class="note">This is a protected intent that can only be sent
2920 * by the system.
2921 */
2922 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2923 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2924 /**
2925 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2926 * charging state, level, and other information about the battery.
2927 * See {@link android.os.BatteryManager} for documentation on the
2928 * contents of the Intent.
2929 *
2930 * <p class="note">
2931 * You <em>cannot</em> receive this through components declared
2932 * in manifests, only by explicitly registering for it with
2933 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2934 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2935 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2936 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2937 * broadcasts that are sent and can be received through manifest
2938 * receivers.
2939 *
2940 * <p class="note">This is a protected intent that can only be sent
2941 * by the system.
2942 */
2943 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2944 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2945
2946
2947 /**
2948 * Broadcast Action: Sent when the current battery level changes.
2949 *
2950 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2951 * instances representing individual battery level changes with associated
2952 * extras from {@link #ACTION_BATTERY_CHANGED}.
2953 *
2954 * <p class="note">
2955 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2956 *
2957 * @hide
2958 */
2959 @SystemApi
2960 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2961 "android.intent.action.BATTERY_LEVEL_CHANGED";
2962 /**
2963 * Broadcast Action: Indicates low battery condition on the device.
2964 * This broadcast corresponds to the "Low battery warning" system dialog.
2965 *
2966 * <p class="note">This is a protected intent that can only be sent
2967 * by the system.
2968 */
2969 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2970 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2971 /**
2972 * Broadcast Action: Indicates the battery is now okay after being low.
2973 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2974 * gone back up to an okay state.
2975 *
2976 * <p class="note">This is a protected intent that can only be sent
2977 * by the system.
2978 */
2979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2980 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2981 /**
2982 * Broadcast Action: External power has been connected to the device.
2983 * This is intended for applications that wish to register specifically to this notification.
2984 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2985 * stay active to receive this notification. This action can be used to implement actions
2986 * that wait until power is available to trigger.
2987 *
2988 * <p class="note">This is a protected intent that can only be sent
2989 * by the system.
2990 */
2991 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2992 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
2993 /**
2994 * Broadcast Action: External power has been removed from the device.
2995 * This is intended for applications that wish to register specifically to this notification.
2996 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2997 * stay active to receive this notification. This action can be used to implement actions
2998 * that wait until power is available to trigger.
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_POWER_DISCONNECTED =
3005 "android.intent.action.ACTION_POWER_DISCONNECTED";
3006 /**
3007 * Broadcast Action: Device is shutting down.
3008 * This is broadcast when the device is being shut down (completely turned
3009 * off, not sleeping). Once the broadcast is complete, the final shutdown
3010 * will proceed and all unsaved data lost. Apps will not normally need
3011 * to handle this, since the foreground activity will be paused as well.
3012 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
3013 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3014 * Context.registerReceiver}.
3015 *
3016 * <p class="note">This is a protected intent that can only be sent
3017 * by the system.
3018 * <p>May include the following extras:
3019 * <ul>
3020 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
3021 * shutdown is only for userspace processes. If not set, assumed to be false.
3022 * </ul>
3023 */
3024 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3025 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
3026 /**
3027 * Activity Action: Start this activity to request system shutdown.
3028 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
3029 * to request confirmation from the user before shutting down. The optional boolean
3030 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
3031 * indicate that the shutdown is requested by the user.
3032 *
3033 * <p class="note">This is a protected intent that can only be sent
3034 * by the system.
3035 *
3036 * {@hide}
3037 */
3038 public static final String ACTION_REQUEST_SHUTDOWN
3039 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
3040 /**
3041 * Broadcast Action: A sticky broadcast that indicates low storage space
3042 * condition on the device
3043 * <p class="note">
3044 * This is a protected intent that can only be sent by the system.
3045 *
3046 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3047 * or above, this broadcast will no longer be delivered to any
3048 * {@link BroadcastReceiver} defined in your manifest. Instead,
3049 * apps are strongly encouraged to use the improved
3050 * {@link Context#getCacheDir()} behavior so the system can
3051 * automatically free up storage when needed.
3052 */
3053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3054 @Deprecated
3055 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
3056 /**
3057 * Broadcast Action: Indicates low storage space condition on the device no
3058 * longer exists
3059 * <p class="note">
3060 * This is a protected intent that can only be sent by the system.
3061 *
3062 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3063 * or above, this broadcast will no longer be delivered to any
3064 * {@link BroadcastReceiver} defined in your manifest. Instead,
3065 * apps are strongly encouraged to use the improved
3066 * {@link Context#getCacheDir()} behavior so the system can
3067 * automatically free up storage when needed.
3068 */
3069 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3070 @Deprecated
3071 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
3072 /**
3073 * Broadcast Action: A sticky broadcast that indicates a storage space full
3074 * condition on the device. This is intended for activities that want to be
3075 * able to fill the data partition completely, leaving only enough free
3076 * space to prevent system-wide SQLite failures.
3077 * <p class="note">
3078 * This is a protected intent that can only be sent by the system.
3079 *
3080 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3081 * or above, this broadcast will no longer be delivered to any
3082 * {@link BroadcastReceiver} defined in your manifest. Instead,
3083 * apps are strongly encouraged to use the improved
3084 * {@link Context#getCacheDir()} behavior so the system can
3085 * automatically free up storage when needed.
3086 * @hide
3087 */
3088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3089 @Deprecated
3090 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
3091 /**
3092 * Broadcast Action: Indicates storage space full condition on the device no
3093 * longer exists.
3094 * <p class="note">
3095 * This is a protected intent that can only be sent by the system.
3096 *
3097 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3098 * or above, this broadcast will no longer be delivered to any
3099 * {@link BroadcastReceiver} defined in your manifest. Instead,
3100 * apps are strongly encouraged to use the improved
3101 * {@link Context#getCacheDir()} behavior so the system can
3102 * automatically free up storage when needed.
3103 * @hide
3104 */
3105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3106 @Deprecated
3107 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
3108 /**
3109 * Broadcast Action: Indicates low memory condition notification acknowledged by user
3110 * and package management should be started.
3111 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
3112 * notification.
3113 */
3114 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3115 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
3116 /**
3117 * Broadcast Action: The device has entered USB Mass Storage mode.
3118 * This is used mainly for the USB Settings panel.
3119 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3120 * when the SD card file system is mounted or unmounted
3121 * @deprecated replaced by android.os.storage.StorageEventListener
3122 */
3123 @Deprecated
3124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3125 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
3126
3127 /**
3128 * Broadcast Action: The device has exited USB Mass Storage mode.
3129 * This is used mainly for the USB Settings panel.
3130 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3131 * when the SD card file system is mounted or unmounted
3132 * @deprecated replaced by android.os.storage.StorageEventListener
3133 */
3134 @Deprecated
3135 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3136 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3137
3138 /**
3139 * Broadcast Action: External media has been removed.
3140 * The path to the mount point for the removed media is contained in the Intent.mData field.
3141 */
3142 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3143 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3144
3145 /**
3146 * Broadcast Action: External media is present, but not mounted at its mount point.
3147 * The path to the mount point for the unmounted media is contained in the Intent.mData field.
3148 */
3149 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3150 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3151
3152 /**
3153 * Broadcast Action: External media is present, and being disk-checked
3154 * The path to the mount point for the checking media is contained in the Intent.mData field.
3155 */
3156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3157 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3158
3159 /**
3160 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
3161 * The path to the mount point for the checking media is contained in the Intent.mData field.
3162 */
3163 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3164 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3165
3166 /**
3167 * Broadcast Action: External media is present and mounted at its mount point.
3168 * The path to the mount point for the mounted media is contained in the Intent.mData field.
3169 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3170 * media was mounted read only.
3171 */
3172 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3173 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3174
3175 /**
3176 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
3177 * The path to the mount point for the shared media is contained in the Intent.mData field.
3178 */
3179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3180 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3181
3182 /**
3183 * Broadcast Action: External media is no longer being shared via USB mass storage.
3184 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3185 *
3186 * @hide
3187 */
3188 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3189
3190 /**
3191 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
3192 * The path to the mount point for the removed media is contained in the Intent.mData field.
3193 */
3194 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3195 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3196
3197 /**
3198 * Broadcast Action: External media is present but cannot be mounted.
3199 * The path to the mount point for the unmountable media is contained in the Intent.mData field.
3200 */
3201 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3202 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3203
3204 /**
3205 * Broadcast Action: User has expressed the desire to remove the external storage media.
3206 * Applications should close all files they have open within the mount point when they receive this intent.
3207 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3208 */
3209 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3210 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3211
3212 /**
3213 * Broadcast Action: The media scanner has started scanning a directory.
3214 * The path to the directory being scanned is contained in the Intent.mData field.
3215 */
3216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3217 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3218
3219 /**
3220 * Broadcast Action: The media scanner has finished scanning a directory.
3221 * The path to the scanned directory is contained in the Intent.mData field.
3222 */
3223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3224 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3225
3226 /**
3227 * Broadcast Action: Request the media scanner to scan a file and add it to
3228 * the media database.
3229 * <p>
3230 * The path to the file is contained in {@link Intent#getData()}.
3231 *
3232 * @deprecated Callers should migrate to inserting items directly into
3233 * {@link MediaStore}, where they will be automatically scanned
3234 * after each mutation.
3235 */
3236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3237 @Deprecated
3238 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3239
3240 /**
3241 * Broadcast Action: The "Media Button" was pressed. Includes a single
3242 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3243 * caused the broadcast.
3244 */
3245 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3246 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3247
3248 /**
3249 * Broadcast Action: The "Camera Button" was pressed. Includes a single
3250 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3251 * caused the broadcast.
3252 */
3253 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3254 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3255
3256 // *** NOTE: @todo(*) The following really should go into a more domain-specific
3257 // location; they are not general-purpose actions.
3258
3259 /**
3260 * Broadcast Action: A GTalk connection has been established.
3261 */
3262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3263 public static final String ACTION_GTALK_SERVICE_CONNECTED =
3264 "android.intent.action.GTALK_CONNECTED";
3265
3266 /**
3267 * Broadcast Action: A GTalk connection has been disconnected.
3268 */
3269 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3270 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3271 "android.intent.action.GTALK_DISCONNECTED";
3272
3273 /**
3274 * Broadcast Action: An input method has been changed.
3275 */
3276 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3277 public static final String ACTION_INPUT_METHOD_CHANGED =
3278 "android.intent.action.INPUT_METHOD_CHANGED";
3279
3280 /**
3281 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3282 * more radios have been turned off or on. The intent will have the following extra value:</p>
3283 * <ul>
3284 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3285 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3286 * turned off</li>
3287 * </ul>
3288 *
3289 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3290 */
3291 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3292 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3293
3294 /**
3295 * Broadcast Action: Some content providers have parts of their namespace
3296 * where they publish new events or items that the user may be especially
3297 * interested in. For these things, they may broadcast this action when the
3298 * set of interesting items change.
3299 *
3300 * For example, GmailProvider sends this notification when the set of unread
3301 * mail in the inbox changes.
3302 *
3303 * <p>The data of the intent identifies which part of which provider
3304 * changed. When queried through the content resolver, the data URI will
3305 * return the data set in question.
3306 *
3307 * <p>The intent will have the following extra values:
3308 * <ul>
3309 * <li><em>count</em> - The number of items in the data set. This is the
3310 * same as the number of items in the cursor returned by querying the
3311 * data URI. </li>
3312 * </ul>
3313 *
3314 * This intent will be sent at boot (if the count is non-zero) and when the
3315 * data set changes. It is possible for the data set to change without the
3316 * count changing (for example, if a new unread message arrives in the same
3317 * sync operation in which a message is archived). The phone should still
3318 * ring/vibrate/etc as normal in this case.
3319 */
3320 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3321 public static final String ACTION_PROVIDER_CHANGED =
3322 "android.intent.action.PROVIDER_CHANGED";
3323
3324 /**
3325 * Broadcast Action: Wired Headset plugged in or unplugged.
3326 *
3327 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3328 * and documentation.
3329 * <p>If the minimum SDK version of your application is
3330 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
3331 * to the <code>AudioManager</code> constant in your receiver registration code instead.
3332 */
3333 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3334 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
3335
3336 /**
3337 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3338 * <ul>
3339 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3340 * </ul>
3341 *
3342 * <p class="note">This is a protected intent that can only be sent
3343 * by the system.
3344 *
3345 * @hide
3346 */
3347 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3348 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3349 = "android.intent.action.ADVANCED_SETTINGS";
3350
3351 /**
3352 * Broadcast Action: Sent after application restrictions are changed.
3353 *
3354 * <p class="note">This is a protected intent that can only be sent
3355 * by the system.</p>
3356 */
3357 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3358 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3359 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3360
3361 /**
3362 * Broadcast Action: An outgoing call is about to be placed.
3363 *
3364 * <p>The Intent will have the following extra value:</p>
3365 * <ul>
3366 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
3367 * the phone number originally intended to be dialed.</li>
3368 * </ul>
3369 * <p>Once the broadcast is finished, the resultData is used as the actual
3370 * number to call. If <code>null</code>, no call will be placed.</p>
3371 * <p>It is perfectly acceptable for multiple receivers to process the
3372 * outgoing call in turn: for example, a parental control application
3373 * might verify that the user is authorized to place the call at that
3374 * time, then a number-rewriting application might add an area code if
3375 * one was not specified.</p>
3376 * <p>For consistency, any receiver whose purpose is to prohibit phone
3377 * calls should have a priority of 0, to ensure it will see the final
3378 * phone number to be dialed.
3379 * Any receiver whose purpose is to rewrite phone numbers to be called
3380 * should have a positive priority.
3381 * Negative priorities are reserved for the system for this broadcast;
3382 * using them may cause problems.</p>
3383 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3384 * abort the broadcast.</p>
3385 * <p>Emergency calls cannot be intercepted using this mechanism, and
3386 * other calls cannot be modified to call emergency numbers using this
3387 * mechanism.
3388 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3389 * call to use their own service instead. Those apps should first prevent
3390 * the call from being placed by setting resultData to <code>null</code>
3391 * and then start their own app to make the call.
3392 * <p>You must hold the
3393 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3394 * permission to receive this Intent.</p>
3395 *
3396 * <p class="note">This is a protected intent that can only be sent
3397 * by the system.
3398 *
3399 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3400 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3401 * This means that attempts to re-write the outgoing call by other apps using this intent will
3402 * be ignored.
3403 * </p>
3404 *
3405 * @deprecated Apps that redirect outgoing calls should use the
3406 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening
3407 * should use the {@link android.telecom.CallScreeningService} API. Apps which need to be
3408 * notified of basic call state should use
3409 * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine
3410 * when a new outgoing call is placed.
3411 */
3412 @Deprecated
3413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3414 public static final String ACTION_NEW_OUTGOING_CALL =
3415 "android.intent.action.NEW_OUTGOING_CALL";
3416
3417 /**
3418 * Broadcast Action: Have the device reboot. This is only for use by
3419 * system code.
3420 *
3421 * <p class="note">This is a protected intent that can only be sent
3422 * by the system.
3423 */
3424 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3425 public static final String ACTION_REBOOT =
3426 "android.intent.action.REBOOT";
3427
3428 /**
3429 * Broadcast Action: A sticky broadcast for changes in the physical
3430 * docking state of the device.
3431 *
3432 * <p>The intent will have the following extra values:
3433 * <ul>
3434 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
3435 * state, indicating which dock the device is physically in.</li>
3436 * </ul>
3437 * <p>This is intended for monitoring the current physical dock state.
3438 * See {@link android.app.UiModeManager} for the normal API dealing with
3439 * dock mode changes.
3440 */
3441 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3442 public static final String ACTION_DOCK_EVENT =
3443 "android.intent.action.DOCK_EVENT";
3444
3445 /**
3446 * Broadcast Action: A broadcast when idle maintenance can be started.
3447 * This means that the user is not interacting with the device and is
3448 * not expected to do so soon. Typical use of the idle maintenance is
3449 * to perform somehow expensive tasks that can be postponed at a moment
3450 * when they will not degrade user experience.
3451 * <p>
3452 * <p class="note">In order to keep the device responsive in case of an
3453 * unexpected user interaction, implementations of a maintenance task
3454 * should be interruptible. In such a scenario a broadcast with action
3455 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3456 * should not do the maintenance work in
3457 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3458 * maintenance service by {@link Context#startService(Intent)}. Also
3459 * you should hold a wake lock while your maintenance service is running
3460 * to prevent the device going to sleep.
3461 * </p>
3462 * <p>
3463 * <p class="note">This is a protected intent that can only be sent by
3464 * the system.
3465 * </p>
3466 *
3467 * @see #ACTION_IDLE_MAINTENANCE_END
3468 *
3469 * @hide
3470 */
3471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3472 public static final String ACTION_IDLE_MAINTENANCE_START =
3473 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3474
3475 /**
3476 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3477 * This means that the user was not interacting with the device as a result
3478 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3479 * was sent and now the user started interacting with the device. Typical
3480 * use of the idle maintenance is to perform somehow expensive tasks that
3481 * can be postponed at a moment when they will not degrade user experience.
3482 * <p>
3483 * <p class="note">In order to keep the device responsive in case of an
3484 * unexpected user interaction, implementations of a maintenance task
3485 * should be interruptible. Hence, on receiving a broadcast with this
3486 * action, the maintenance task should be interrupted as soon as possible.
3487 * In other words, you should not do the maintenance work in
3488 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3489 * maintenance service that was started on receiving of
3490 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3491 * lock you acquired when your maintenance service started.
3492 * </p>
3493 * <p class="note">This is a protected intent that can only be sent
3494 * by the system.
3495 *
3496 * @see #ACTION_IDLE_MAINTENANCE_START
3497 *
3498 * @hide
3499 */
3500 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3501 public static final String ACTION_IDLE_MAINTENANCE_END =
3502 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3503
3504 /**
3505 * Broadcast Action: a remote intent is to be broadcasted.
3506 *
3507 * A remote intent is used for remote RPC between devices. The remote intent
3508 * is serialized and sent from one device to another device. The receiving
3509 * device parses the remote intent and broadcasts it. Note that anyone can
3510 * broadcast a remote intent. However, if the intent receiver of the remote intent
3511 * does not trust intent broadcasts from arbitrary intent senders, it should require
3512 * the sender to hold certain permissions so only trusted sender's broadcast will be
3513 * let through.
3514 * @hide
3515 */
3516 public static final String ACTION_REMOTE_INTENT =
3517 "com.google.android.c2dm.intent.RECEIVE";
3518
3519 /**
3520 * Broadcast Action: This is broadcast once when the user is booting after a
3521 * system update. It can be used to perform cleanup or upgrades after a
3522 * system update.
3523 * <p>
3524 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3525 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3526 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3527 * sent to receivers in the system image.
3528 *
3529 * @hide
3530 */
3531 @SystemApi
3532 public static final String ACTION_PRE_BOOT_COMPLETED =
3533 "android.intent.action.PRE_BOOT_COMPLETED";
3534
3535 /**
3536 * Broadcast to a specific application to query any supported restrictions to impose
3537 * on restricted users. The broadcast intent contains an extra
3538 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3539 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3540 * String[] depending on the restriction type.<p/>
3541 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
3542 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3543 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3544 * The activity specified by that intent will be launched for a result which must contain
3545 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3546 * The keys and values of the returned restrictions will be persisted.
3547 * @see RestrictionEntry
3548 */
3549 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3550 "android.intent.action.GET_RESTRICTION_ENTRIES";
3551
3552 /**
3553 * Sent the first time a user is starting, to allow system apps to
3554 * perform one time initialization. (This will not be seen by third
3555 * party applications because a newly initialized user does not have any
3556 * third party applications installed for it.) This is sent early in
3557 * starting the user, around the time the home app is started, before
3558 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3559 * broadcast, since it is part of a visible user interaction; be as quick
3560 * as possible when handling it.
3561 */
3562 public static final String ACTION_USER_INITIALIZE =
3563 "android.intent.action.USER_INITIALIZE";
3564
3565 /**
3566 * Sent when a user switch is happening, causing the process's user to be
3567 * brought to the foreground. This is only sent to receivers registered
3568 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3569 * Context.registerReceiver}. It is sent to the user that is going to the
3570 * foreground. This is sent as a foreground
3571 * broadcast, since it is part of a visible user interaction; be as quick
3572 * as possible when handling it.
3573 */
3574 public static final String ACTION_USER_FOREGROUND =
3575 "android.intent.action.USER_FOREGROUND";
3576
3577 /**
3578 * Sent when a user switch is happening, causing the process's user to be
3579 * sent to the background. This is only sent to receivers registered
3580 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3581 * Context.registerReceiver}. It is sent to the user that is going to the
3582 * background. This is sent as a foreground
3583 * broadcast, since it is part of a visible user interaction; be as quick
3584 * as possible when handling it.
3585 */
3586 public static final String ACTION_USER_BACKGROUND =
3587 "android.intent.action.USER_BACKGROUND";
3588
3589 /**
3590 * Broadcast sent to the system when a user is added. Carries an extra
3591 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3592 * all running users. You must hold
3593 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3594 * @hide
3595 */
3596 @SystemApi
3597 public static final String ACTION_USER_ADDED =
3598 "android.intent.action.USER_ADDED";
3599
3600 /**
3601 * Broadcast sent by the system when a user is started. Carries an extra
3602 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
3603 * registered receivers, not manifest receivers. It is sent to the user
3604 * that has been started. This is sent as a foreground
3605 * broadcast, since it is part of a visible user interaction; be as quick
3606 * as possible when handling it.
3607 * @hide
3608 */
3609 public static final String ACTION_USER_STARTED =
3610 "android.intent.action.USER_STARTED";
3611
3612 /**
3613 * Broadcast sent when a user is in the process of starting. Carries an extra
3614 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3615 * sent to registered receivers, not manifest receivers. It is sent to all
3616 * users (including the one that is being started). You must hold
3617 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3618 * this broadcast. This is sent as a background broadcast, since
3619 * its result is not part of the primary UX flow; to safely keep track of
3620 * started/stopped state of a user you can use this in conjunction with
3621 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3622 * other user state broadcasts since those are foreground broadcasts so can
3623 * execute in a different order.
3624 * @hide
3625 */
3626 public static final String ACTION_USER_STARTING =
3627 "android.intent.action.USER_STARTING";
3628
3629 /**
3630 * Broadcast sent when a user is going to be stopped. Carries an extra
3631 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3632 * sent to registered receivers, not manifest receivers. It is sent to all
3633 * users (including the one that is being stopped). You must hold
3634 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3635 * this broadcast. The user will not stop until all receivers have
3636 * handled the broadcast. This is sent as a background broadcast, since
3637 * its result is not part of the primary UX flow; to safely keep track of
3638 * started/stopped state of a user you can use this in conjunction with
3639 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3640 * other user state broadcasts since those are foreground broadcasts so can
3641 * execute in a different order.
3642 * @hide
3643 */
3644 public static final String ACTION_USER_STOPPING =
3645 "android.intent.action.USER_STOPPING";
3646
3647 /**
3648 * Broadcast sent to the system when a user is stopped. Carries an extra
3649 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3650 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3651 * specific package. This is only sent to registered receivers, not manifest
3652 * receivers. It is sent to all running users <em>except</em> the one that
3653 * has just been stopped (which is no longer running).
3654 * @hide
3655 */
3656 public static final String ACTION_USER_STOPPED =
3657 "android.intent.action.USER_STOPPED";
3658
3659 /**
3660 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
3661 * the userHandle of the user. It is sent to all running users except the
3662 * one that has been removed. The user will not be completely removed until all receivers have
3663 * handled the broadcast. You must hold
3664 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3665 * @hide
3666 */
3667 @SystemApi
3668 public static final String ACTION_USER_REMOVED =
3669 "android.intent.action.USER_REMOVED";
3670
3671 /**
3672 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
3673 * the userHandle of the user to become the current one. This is only sent to
3674 * registered receivers, not manifest receivers. It is sent to all running users.
3675 * You must hold
3676 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3677 * @hide
3678 */
3679 @UnsupportedAppUsage
3680 public static final String ACTION_USER_SWITCHED =
3681 "android.intent.action.USER_SWITCHED";
3682
3683 /**
3684 * Broadcast Action: Sent when the credential-encrypted private storage has
3685 * become unlocked for the target user. This is only sent to registered
3686 * receivers, not manifest receivers.
3687 */
3688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3689 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3690
3691 /**
3692 * Broadcast sent to the system when a user's information changes. Carries an extra
3693 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
3694 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
3695 * @hide
3696 */
3697 public static final String ACTION_USER_INFO_CHANGED =
3698 "android.intent.action.USER_INFO_CHANGED";
3699
3700 /**
3701 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3702 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
3703 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3704 * that need to display merged content across both primary and managed profiles need to
3705 * worry about this broadcast. This is only sent to registered receivers,
3706 * not manifest receivers.
3707 */
3708 public static final String ACTION_MANAGED_PROFILE_ADDED =
3709 "android.intent.action.MANAGED_PROFILE_ADDED";
3710
3711 /**
3712 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
3713 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3714 * Only applications (for example Launchers) that need to display merged content across both
3715 * primary and managed profiles need to worry about this broadcast. This is only sent to
3716 * registered receivers, not manifest receivers.
3717 */
3718 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3719 "android.intent.action.MANAGED_PROFILE_REMOVED";
3720
3721 /**
3722 * Broadcast sent to the primary user when the credential-encrypted private storage for
3723 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3724 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3725 * Launchers) that need to display merged content across both primary and managed profiles
3726 * need to worry about this broadcast. This is only sent to registered receivers,
3727 * not manifest receivers.
3728 */
3729 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3730 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3731
3732 /**
3733 * Broadcast sent to the primary user when an associated managed profile has become available.
3734 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
3735 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3736 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3737 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3738 */
3739 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3740 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3741
3742 /**
3743 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3744 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3745 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3746 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3747 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3748 */
3749 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3750 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
3751
3752 /**
3753 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3754 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3755 * the device was locked or unlocked.
3756 *
3757 * This is only sent to registered receivers.
3758 *
3759 * @hide
3760 */
3761 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3762 "android.intent.action.DEVICE_LOCKED_CHANGED";
3763
3764 /**
3765 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3766 */
3767 public static final String ACTION_QUICK_CLOCK =
3768 "android.intent.action.QUICK_CLOCK";
3769
3770 /**
3771 * Activity Action: Shows the brightness setting dialog.
3772 * @hide
3773 */
3774 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3775 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3776
3777 /**
3778 * Broadcast Action: A global button was pressed. Includes a single
3779 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3780 * caused the broadcast.
3781 * @hide
3782 */
3783 @SystemApi
3784 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3785
3786 /**
3787 * Broadcast Action: Sent when media resource is granted.
3788 * <p>
3789 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3790 * granted.
3791 * </p>
3792 * <p class="note">
3793 * This is a protected intent that can only be sent by the system.
3794 * </p>
3795 * <p class="note">
3796 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
3797 * </p>
3798 *
3799 * @hide
3800 */
3801 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3802 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3803
3804 /**
3805 * Broadcast Action: An overlay package has changed. The data contains the
3806 * name of the overlay package which has changed. This is broadcast on all
3807 * changes to the OverlayInfo returned by {@link
3808 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3809 * most common change is a state change that will change whether the
3810 * overlay is enabled or not.
3811 * @hide
3812 */
3813 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3814
3815 /**
3816 * Activity Action: Allow the user to select and return one or more existing
3817 * documents. When invoked, the system will display the various
3818 * {@link DocumentsProvider} instances installed on the device, letting the
3819 * user interactively navigate through them. These documents include local
3820 * media, such as photos and video, and documents provided by installed
3821 * cloud storage providers.
3822 * <p>
3823 * Each document is represented as a {@code content://} URI backed by a
3824 * {@link DocumentsProvider}, which can be opened as a stream with
3825 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3826 * {@link android.provider.DocumentsContract.Document} metadata.
3827 * <p>
3828 * All selected documents are returned to the calling application with
3829 * persistable read and write permission grants. If you want to maintain
3830 * access to the documents across device reboots, you need to explicitly
3831 * take the persistable permissions using
3832 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3833 * <p>
3834 * Callers must indicate the acceptable document MIME types through
3835 * {@link #setType(String)}. For example, to select photos, use
3836 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3837 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3838 * {@literal *}/*.
3839 * <p>
3840 * If the caller can handle multiple returned items (the user performing
3841 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3842 * to indicate this.
3843 * <p>
3844 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3845 * URIs that can be opened with
3846 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3847 * <p>
3848 * Callers can set a document URI through
3849 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3850 * location of documents navigator. System will do its best to launch the
3851 * navigator in the specified document if it's a folder, or the folder that
3852 * contains the specified document if not.
3853 * <p>
3854 * Output: The URI of the item that was picked, returned in
3855 * {@link #getData()}. This must be a {@code content://} URI so that any
3856 * receiver can access it. If multiple documents were selected, they are
3857 * returned in {@link #getClipData()}.
3858 *
3859 * @see DocumentsContract
3860 * @see #ACTION_OPEN_DOCUMENT_TREE
3861 * @see #ACTION_CREATE_DOCUMENT
3862 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3863 */
3864 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3865 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3866
3867 /**
3868 * Activity Action: Allow the user to create a new document. When invoked,
3869 * the system will display the various {@link DocumentsProvider} instances
3870 * installed on the device, letting the user navigate through them. The
3871 * returned document may be a newly created document with no content, or it
3872 * may be an existing document with the requested MIME type.
3873 * <p>
3874 * Each document is represented as a {@code content://} URI backed by a
3875 * {@link DocumentsProvider}, which can be opened as a stream with
3876 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3877 * {@link android.provider.DocumentsContract.Document} metadata.
3878 * <p>
3879 * Callers must indicate the concrete MIME type of the document being
3880 * created by setting {@link #setType(String)}. This MIME type cannot be
3881 * changed after the document is created.
3882 * <p>
3883 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3884 * but the user may change this value before creating the file.
3885 * <p>
3886 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3887 * URIs that can be opened with
3888 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3889 * <p>
3890 * Callers can set a document URI through
3891 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3892 * location of documents navigator. System will do its best to launch the
3893 * navigator in the specified document if it's a folder, or the folder that
3894 * contains the specified document if not.
3895 * <p>
3896 * Output: The URI of the item that was created. This must be a
3897 * {@code content://} URI so that any receiver can access it.
3898 *
3899 * @see DocumentsContract
3900 * @see #ACTION_OPEN_DOCUMENT
3901 * @see #ACTION_OPEN_DOCUMENT_TREE
3902 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3903 */
3904 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3905 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3906
3907 /**
3908 * Activity Action: Allow the user to pick a directory subtree. When
3909 * invoked, the system will display the various {@link DocumentsProvider}
3910 * instances installed on the device, letting the user navigate through
3911 * them. Apps can fully manage documents within the returned directory.
3912 * <p>
3913 * To gain access to descendant (child, grandchild, etc) documents, use
3914 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3915 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3916 * with the returned URI.
3917 * <p>
3918 * Callers can set a document URI through
3919 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3920 * location of documents navigator. System will do its best to launch the
3921 * navigator in the specified document if it's a folder, or the folder that
3922 * contains the specified document if not.
3923 * <p>
3924 * Output: The URI representing the selected directory tree.
3925 *
3926 * @see DocumentsContract
3927 */
3928 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3929 public static final String
3930 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
3931
3932
3933 /**
3934 * Activity Action: Perform text translation.
3935 * <p>
3936 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
3937 * <p>
3938 * Output: nothing.
3939 */
3940 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3941 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
3942
3943 /**
3944 * Activity Action: Define the meaning of the selected word(s).
3945 * <p>
3946 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
3947 * <p>
3948 * Output: nothing.
3949 */
3950 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3951 public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
3952
3953 /**
3954 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3955 * exisiting sensor being disconnected.
3956 *
3957 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3958 *
3959 * {@hide}
3960 */
3961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3962 public static final String
3963 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3964
3965 /**
3966 * Deprecated - use ACTION_FACTORY_RESET instead.
3967 * @hide
3968 * @removed
3969 */
3970 @Deprecated
3971 @SystemApi
3972 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3973
3974 /**
3975 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3976 * is about to be performed.
3977 * @hide
3978 */
3979 @SystemApi
3980 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3981 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3982 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3983
3984 /**
3985 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3986 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3987 *
3988 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3989 *
3990 * @hide
3991 */
3992 @Deprecated
3993 public static final String EXTRA_FORCE_MASTER_CLEAR =
3994 "android.intent.extra.FORCE_MASTER_CLEAR";
3995
3996 /**
3997 * A broadcast action to trigger a factory reset.
3998 *
3999 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
4000 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
4001 *
4002 * <p>Not for use by third-party applications.
4003 *
4004 * @see #EXTRA_FORCE_FACTORY_RESET
4005 *
4006 * {@hide}
4007 */
4008 @SystemApi
4009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4010 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
4011
4012 /**
4013 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4014 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4015 *
4016 * <p>Not for use by third-party applications.
4017 *
4018 * @hide
4019 */
4020 @SystemApi
4021 public static final String EXTRA_FORCE_FACTORY_RESET =
4022 "android.intent.extra.FORCE_FACTORY_RESET";
4023
4024 /**
4025 * Broadcast action: report that a settings element is being restored from backup. The intent
4026 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
4027 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
4028 * is the value of that settings entry prior to the restore operation, and
4029 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
4030 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
4031 * values are represented as strings, the fourth one as int.
4032 *
4033 * <p>This broadcast is sent only for settings provider entries known to require special handling
4034 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
4035 * the provider's backup agent implementation.
4036 *
4037 * @see #EXTRA_SETTING_NAME
4038 * @see #EXTRA_SETTING_PREVIOUS_VALUE
4039 * @see #EXTRA_SETTING_NEW_VALUE
4040 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
4041 * {@hide}
4042 */
4043 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
4044
4045 /** {@hide} */
4046 public static final String EXTRA_SETTING_NAME = "setting_name";
4047 /** {@hide} */
4048 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
4049 /** {@hide} */
4050 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
4051 /** {@hide} */
4052 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
4053
4054 /**
4055 * Activity Action: Process a piece of text.
4056 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
4057 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
4058 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
4059 */
4060 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4061 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
4062
4063 /**
4064 * Broadcast Action: The sim card state has changed.
4065 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
4066 * because TelephonyIntents is an internal class.
4067 * The intent will have following extras.</p>
4068 * <p>
4069 * @see #EXTRA_SIM_STATE
4070 * @see #EXTRA_SIM_LOCKED_REASON
4071 * @see #EXTRA_REBROADCAST_ON_UNLOCK
4072 *
4073 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4074 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4075 *
4076 * @hide
4077 */
4078 @Deprecated
4079 @SystemApi
4080 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4081 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
4082
4083 /**
4084 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4085 * This will have one of the following intent values.
4086 * @see #SIM_STATE_UNKNOWN
4087 * @see #SIM_STATE_NOT_READY
4088 * @see #SIM_STATE_ABSENT
4089 * @see #SIM_STATE_PRESENT
4090 * @see #SIM_STATE_CARD_IO_ERROR
4091 * @see #SIM_STATE_CARD_RESTRICTED
4092 * @see #SIM_STATE_LOCKED
4093 * @see #SIM_STATE_READY
4094 * @see #SIM_STATE_IMSI
4095 * @see #SIM_STATE_LOADED
4096 * @hide
4097 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4098 */
4099 public static final String EXTRA_SIM_STATE = "ss";
4100
4101 /**
4102 * The intent value UNKNOWN represents the SIM state unknown
4103 * @hide
4104 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4105 */
4106 public static final String SIM_STATE_UNKNOWN = "UNKNOWN";
4107
4108 /**
4109 * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on
4110 * @hide
4111 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4112 */
4113 public static final String SIM_STATE_NOT_READY = "NOT_READY";
4114
4115 /**
4116 * The intent value ABSENT means the SIM card is missing
4117 * @hide
4118 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4119 */
4120 public static final String SIM_STATE_ABSENT = "ABSENT";
4121
4122 /**
4123 * The intent value PRESENT means the device has a SIM card inserted
4124 * @hide
4125 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4126 */
4127 public static final String SIM_STATE_PRESENT = "PRESENT";
4128
4129 /**
4130 * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error
4131 * @hide
4132 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4133 */
4134 static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR";
4135
4136 /**
4137 * The intent value CARD_RESTRICTED means card is present but not usable due to carrier
4138 * restrictions
4139 * @hide
4140 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4141 */
4142 static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED";
4143
4144 /**
4145 * The intent value LOCKED means the SIM is locked by PIN or by network
4146 * @hide
4147 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4148 */
4149 public static final String SIM_STATE_LOCKED = "LOCKED";
4150
4151 /**
4152 * The intent value READY means the SIM is ready to be accessed
4153 * @hide
4154 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4155 */
4156 public static final String SIM_STATE_READY = "READY";
4157
4158 /**
4159 * The intent value IMSI means the SIM IMSI is ready in property
4160 * @hide
4161 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4162 */
4163 public static final String SIM_STATE_IMSI = "IMSI";
4164
4165 /**
4166 * The intent value LOADED means all SIM records, including IMSI, are loaded
4167 * @hide
4168 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4169 */
4170 public static final String SIM_STATE_LOADED = "LOADED";
4171
4172 /**
4173 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4174 * This extra will have one of the following intent values.
4175 * <p>
4176 * @see #SIM_LOCKED_ON_PIN
4177 * @see #SIM_LOCKED_ON_PUK
4178 * @see #SIM_LOCKED_NETWORK
4179 * @see #SIM_ABSENT_ON_PERM_DISABLED
4180 *
4181 * @hide
4182 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4183 */
4184 public static final String EXTRA_SIM_LOCKED_REASON = "reason";
4185
4186 /**
4187 * The intent value PIN means the SIM is locked on PIN1
4188 * @hide
4189 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4190 */
4191 public static final String SIM_LOCKED_ON_PIN = "PIN";
4192
4193 /**
4194 * The intent value PUK means the SIM is locked on PUK1
4195 * @hide
4196 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4197 */
4198 /* PUK means ICC is locked on PUK1 */
4199 public static final String SIM_LOCKED_ON_PUK = "PUK";
4200
4201 /**
4202 * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION
4203 * @hide
4204 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4205 */
4206 public static final String SIM_LOCKED_NETWORK = "NETWORK";
4207
4208 /**
4209 * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails
4210 * @hide
4211 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4212 */
4213 public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED";
4214
4215 /**
4216 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast
4217 * is a rebroadcast on unlock. Defaults to {@code false} if not specified.
4218 *
4219 * @hide
4220 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4221 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4222 */
4223 public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock";
4224
4225 /**
4226 * Broadcast Action: indicate that the phone service state has changed.
4227 * The intent will have the following extra values:</p>
4228 * <p>
4229 * @see #EXTRA_VOICE_REG_STATE
4230 * @see #EXTRA_DATA_REG_STATE
4231 * @see #EXTRA_VOICE_ROAMING_TYPE
4232 * @see #EXTRA_DATA_ROAMING_TYPE
4233 * @see #EXTRA_OPERATOR_ALPHA_LONG
4234 * @see #EXTRA_OPERATOR_ALPHA_SHORT
4235 * @see #EXTRA_OPERATOR_NUMERIC
4236 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
4237 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
4238 * @see #EXTRA_DATA_OPERATOR_NUMERIC
4239 * @see #EXTRA_MANUAL
4240 * @see #EXTRA_VOICE_RADIO_TECH
4241 * @see #EXTRA_DATA_RADIO_TECH
4242 * @see #EXTRA_CSS_INDICATOR
4243 * @see #EXTRA_NETWORK_ID
4244 * @see #EXTRA_SYSTEM_ID
4245 * @see #EXTRA_CDMA_ROAMING_INDICATOR
4246 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
4247 * @see #EXTRA_EMERGENCY_ONLY
4248 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
4249 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
4250 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
4251 *
4252 * <p class="note">
4253 * Requires the READ_PHONE_STATE permission.
4254 *
4255 * <p class="note">This is a protected intent that can only be sent by the system.
4256 * @hide
4257 * @removed
4258 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
4259 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
4260 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
4261 * for a given subscription id and field with a ContentObserver or using JobScheduler.
4262 */
4263 @Deprecated
4264 @SystemApi
4265 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
4266 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
4267
4268 /**
4269 * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService}
4270 * for querying Data Loader Service providers. Data loader service providers register this
4271 * intent filter in their manifests, so that they can be looked up and bound to by
4272 * {@code DataLoaderManagerService}.
4273 *
4274 * <p class="note">This is a protected intent that can only be sent by the system.
4275 *
4276 * Data loader service providers must be privileged apps.
4277 * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such
4278 * data loader service provider.
4279 *
4280 * @hide
4281 */
4282 @SystemApi
4283 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
4284 public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA";
4285
4286 /**
4287 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
4288 * state.
4289 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4290 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4291 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4292 * @see android.telephony.ServiceState#STATE_POWER_OFF
4293 * @hide
4294 * @removed
4295 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
4296 */
4297 @Deprecated
4298 @SystemApi
4299 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4300
4301 /**
4302 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4303 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4304 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4305 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4306 * @see android.telephony.ServiceState#STATE_POWER_OFF
4307 * @hide
4308 * @removed
4309 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
4310 */
4311 @Deprecated
4312 @SystemApi
4313 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4314
4315 /**
4316 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4317 * type.
4318 * @hide
4319 * @removed
4320 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
4321 */
4322 @Deprecated
4323 @SystemApi
4324 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4325
4326 /**
4327 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4328 * type.
4329 * @hide
4330 * @removed
4331 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
4332 */
4333 @Deprecated
4334 @SystemApi
4335 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4336
4337 /**
4338 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4339 * registered voice operator name in long alphanumeric format.
4340 * {@code null} if the operator name is not known or unregistered.
4341 * @hide
4342 * @removed
4343 * @deprecated Use
4344 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
4345 */
4346 @Deprecated
4347 @SystemApi
4348 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4349
4350 /**
4351 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4352 * registered voice operator name in short alphanumeric format.
4353 * {@code null} if the operator name is not known or unregistered.
4354 * @hide
4355 * @removed
4356 * @deprecated Use
4357 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
4358 */
4359 @Deprecated
4360 @SystemApi
4361 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4362
4363 /**
4364 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4365 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4366 * network.
4367 * @hide
4368 * @removed
4369 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
4370 */
4371 @Deprecated
4372 @SystemApi
4373 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4374
4375 /**
4376 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4377 * registered data operator name in long alphanumeric format.
4378 * {@code null} if the operator name is not known or unregistered.
4379 * @hide
4380 * @removed
4381 * @deprecated Use
4382 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
4383 */
4384 @Deprecated
4385 @SystemApi
4386 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4387
4388 /**
4389 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4390 * registered data operator name in short alphanumeric format.
4391 * {@code null} if the operator name is not known or unregistered.
4392 * @hide
4393 * @removed
4394 * @deprecated Use
4395 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
4396 */
4397 @Deprecated
4398 @SystemApi
4399 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4400
4401 /**
4402 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4403 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4404 * data operator.
4405 * @hide
4406 * @removed
4407 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
4408 */
4409 @Deprecated
4410 @SystemApi
4411 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4412
4413 /**
4414 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4415 * network selection mode is manual.
4416 * Will be {@code true} if manual mode, {@code false} if automatic mode.
4417 * @hide
4418 * @removed
4419 * @deprecated Use
4420 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
4421 */
4422 @Deprecated
4423 @SystemApi
4424 public static final String EXTRA_MANUAL = "manual";
4425
4426 /**
4427 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4428 * radio technology.
4429 * @hide
4430 * @removed
4431 * @deprecated Use
4432 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
4433 */
4434 @Deprecated
4435 @SystemApi
4436 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4437
4438 /**
4439 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4440 * radio technology.
4441 * @hide
4442 * @removed
4443 * @deprecated Use
4444 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
4445 */
4446 @Deprecated
4447 @SystemApi
4448 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4449
4450 /**
4451 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4452 * support on CDMA network.
4453 * Will be {@code true} if support, {@code false} otherwise.
4454 * @hide
4455 * @removed
4456 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
4457 */
4458 @Deprecated
4459 @SystemApi
4460 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4461
4462 /**
4463 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4464 * id. {@code Integer.MAX_VALUE} if unknown.
4465 * @hide
4466 * @removed
4467 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
4468 */
4469 @Deprecated
4470 @SystemApi
4471 public static final String EXTRA_NETWORK_ID = "networkId";
4472
4473 /**
4474 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4475 * {@code Integer.MAX_VALUE} if unknown.
4476 * @hide
4477 * @removed
4478 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
4479 */
4480 @Deprecated
4481 @SystemApi
4482 public static final String EXTRA_SYSTEM_ID = "systemId";
4483
4484 /**
4485 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4486 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4487 * @hide
4488 * @removed
4489 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
4490 */
4491 @Deprecated
4492 @SystemApi
4493 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4494
4495 /**
4496 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4497 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4498 * @hide
4499 * @removed
4500 * @deprecated Use
4501 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
4502 */
4503 @Deprecated
4504 @SystemApi
4505 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4506
4507 /**
4508 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4509 * only mode.
4510 * {@code true} if in emergency only mode, {@code false} otherwise.
4511 * @hide
4512 * @removed
4513 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
4514 */
4515 @Deprecated
4516 @SystemApi
4517 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4518
4519 /**
4520 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4521 * registration state is roaming.
4522 * {@code true} if registration indicates roaming, {@code false} otherwise
4523 * @hide
4524 * @removed
4525 * @deprecated Use
4526 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
4527 */
4528 @Deprecated
4529 @SystemApi
4530 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4531 "isDataRoamingFromRegistration";
4532
4533 /**
4534 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4535 * aggregation is in use.
4536 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4537 * @hide
4538 * @removed
4539 * @deprecated Use
4540 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
4541 */
4542 @Deprecated
4543 @SystemApi
4544 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4545
4546 /**
4547 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4548 * is reduced from the rsrp threshold while calculating signal strength level.
4549 * @hide
4550 * @removed
4551 */
4552 @Deprecated
4553 @SystemApi
4554 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4555
4556 /**
4557 * The name of the extra used to define the text to be processed, as a
4558 * CharSequence. Note that this may be a styled CharSequence, so you must use
4559 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
4560 */
4561 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4562 /**
4563 * The name of the boolean extra used to define if the processed text will be used as read-only.
4564 */
4565 public static final String EXTRA_PROCESS_TEXT_READONLY =
4566 "android.intent.extra.PROCESS_TEXT_READONLY";
4567
4568 /**
4569 * Broadcast action: reports when a new thermal event has been reached. When the device
4570 * is reaching its maximum temperatue, the thermal level reported
4571 * {@hide}
4572 */
4573 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4574 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4575
4576 /** {@hide} */
4577 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4578
4579 /**
4580 * Thermal state when the device is normal. This state is sent in the
4581 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4582 * {@hide}
4583 */
4584 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4585
4586 /**
4587 * Thermal state where the device is approaching its maximum threshold. This state is sent in
4588 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4589 * {@hide}
4590 */
4591 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4592
4593 /**
4594 * Thermal state where the device has reached its maximum threshold. This state is sent in the
4595 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4596 * {@hide}
4597 */
4598 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4599
4600 /**
4601 * Broadcast Action: Indicates the dock in idle state while device is docked.
4602 *
4603 * <p class="note">This is a protected intent that can only be sent
4604 * by the system.
4605 *
4606 * @hide
4607 */
4608 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4609
4610 /**
4611 * Broadcast Action: Indicates the dock in active state while device is docked.
4612 *
4613 * <p class="note">This is a protected intent that can only be sent
4614 * by the system.
4615 *
4616 * @hide
4617 */
4618 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4619
4620 /**
4621 * Broadcast Action: Indicates that a new device customization has been
4622 * downloaded and applied (packages installed, runtime resource overlays
4623 * enabled, xml files copied, ...), and that it is time for components that
4624 * need to for example clear their caches to do so now.
4625 *
4626 * @hide
4627 */
4628 @SystemApi
4629 public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
4630 "android.intent.action.DEVICE_CUSTOMIZATION_READY";
4631
4632
4633 /**
4634 * Activity Action: Display an activity state associated with an unique {@link LocusId}.
4635 *
4636 * <p>For example, a chat app could use the context to resume a conversation between 2 users.
4637 *
4638 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
4639 * app domain. Should be stable across reboots and backup / restore.
4640 * <p>Output: nothing.
4641 */
4642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4643 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
4644
4645 /**
4646 * Broadcast Action: Sent to the integrity component when a package
4647 * needs to be verified. The data contains the package URI along with other relevant
4648 * information.
4649 *
4650 * <p class="note">
4651 * This is a protected intent that can only be sent by the system.
4652 * </p>
4653 *
4654 * @hide
4655 */
4656 @SystemApi
4657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4658 public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION =
4659 "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION";
4660
4661 // ---------------------------------------------------------------------
4662 // ---------------------------------------------------------------------
4663 // Standard intent categories (see addCategory()).
4664
4665 /**
4666 * Set if the activity should be an option for the default action
4667 * (center press) to perform on a piece of data. Setting this will
4668 * hide from the user any activities without it set when performing an
4669 * action on some data. Note that this is normally -not- set in the
4670 * Intent when initiating an action -- it is for use in intent filters
4671 * specified in packages.
4672 */
4673 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4674 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4675 /**
4676 * Activities that can be safely invoked from a browser must support this
4677 * category. For example, if the user is viewing a web page or an e-mail
4678 * and clicks on a link in the text, the Intent generated execute that
4679 * link will require the BROWSABLE category, so that only activities
4680 * supporting this category will be considered as possible actions. By
4681 * supporting this category, you are promising that there is nothing
4682 * damaging (without user intervention) that can happen by invoking any
4683 * matching Intent.
4684 */
4685 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4686 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4687 /**
4688 * Categories for activities that can participate in voice interaction.
4689 * An activity that supports this category must be prepared to run with
4690 * no UI shown at all (though in some case it may have a UI shown), and
4691 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4692 */
4693 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4694 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4695 /**
4696 * Set if the activity should be considered as an alternative action to
4697 * the data the user is currently viewing. See also
4698 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4699 * applies to the selection in a list of items.
4700 *
4701 * <p>Supporting this category means that you would like your activity to be
4702 * displayed in the set of alternative things the user can do, usually as
4703 * part of the current activity's options menu. You will usually want to
4704 * include a specific label in the &lt;intent-filter&gt; of this action
4705 * describing to the user what it does.
4706 *
4707 * <p>The action of IntentFilter with this category is important in that it
4708 * describes the specific action the target will perform. This generally
4709 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4710 * a specific name such as "com.android.camera.action.CROP. Only one
4711 * alternative of any particular action will be shown to the user, so using
4712 * a specific action like this makes sure that your alternative will be
4713 * displayed while also allowing other applications to provide their own
4714 * overrides of that particular action.
4715 */
4716 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4717 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4718 /**
4719 * Set if the activity should be considered as an alternative selection
4720 * action to the data the user has currently selected. This is like
4721 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4722 * of items from which the user can select, giving them alternatives to the
4723 * default action that will be performed on it.
4724 */
4725 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4726 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4727 /**
4728 * Intended to be used as a tab inside of a containing TabActivity.
4729 */
4730 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4731 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4732 /**
4733 * Should be displayed in the top-level launcher.
4734 */
4735 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4736 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4737 /**
4738 * Indicates an activity optimized for Leanback mode, and that should
4739 * be displayed in the Leanback launcher.
4740 */
4741 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4742 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4743 /**
4744 * Indicates the preferred entry-point activity when an application is launched from a Car
4745 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4746 * fallback, or exclude the application entirely.
4747 * @hide
4748 */
4749 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4750 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4751 /**
4752 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4753 * @hide
4754 */
4755 @SystemApi
4756 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4757 /**
4758 * Provides information about the package it is in; typically used if
4759 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4760 * a front-door to the user without having to be shown in the all apps list.
4761 */
4762 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4763 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4764 /**
4765 * This is the home activity, that is the first activity that is displayed
4766 * when the device boots.
4767 */
4768 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4769 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4770 /**
4771 * This is the home activity that is displayed when the device is finished setting up and ready
4772 * for use.
4773 * @hide
4774 */
4775 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4776 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4777 /**
4778 * The home activity shown on secondary displays that support showing home activities.
4779 */
4780 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4781 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
4782 /**
4783 * This is the setup wizard activity, that is the first activity that is displayed
4784 * when the user sets up the device for the first time.
4785 * @hide
4786 */
4787 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4788 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4789 /**
4790 * This is the home activity, that is the activity that serves as the launcher app
4791 * from there the user can start other apps. Often components with lower/higher
4792 * priority intent filters handle the home intent, for example SetupWizard, to
4793 * setup the device and we need to be able to distinguish the home app from these
4794 * setup helpers.
4795 * @hide
4796 */
4797 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4798 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4799 /**
4800 * This activity is a preference panel.
4801 */
4802 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4803 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4804 /**
4805 * This activity is a development preference panel.
4806 */
4807 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4808 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4809 /**
4810 * Capable of running inside a parent activity container.
4811 */
4812 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4813 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4814 /**
4815 * This activity allows the user to browse and download new applications.
4816 */
4817 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4818 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4819 /**
4820 * This activity may be exercised by the monkey or other automated test tools.
4821 */
4822 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4823 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4824 /**
4825 * To be used as a test (not part of the normal user experience).
4826 */
4827 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4828 /**
4829 * To be used as a unit test (run through the Test Harness).
4830 */
4831 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4832 /**
4833 * To be used as a sample code example (not part of the normal user
4834 * experience).
4835 */
4836 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
4837
4838 /**
4839 * Used to indicate that an intent only wants URIs that can be opened with
4840 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4841 * must support at least the columns defined in {@link OpenableColumns} when
4842 * queried.
4843 *
4844 * @see #ACTION_GET_CONTENT
4845 * @see #ACTION_OPEN_DOCUMENT
4846 * @see #ACTION_CREATE_DOCUMENT
4847 */
4848 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4849 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4850
4851 /**
4852 * Used to indicate that an intent filter can accept files which are not necessarily
4853 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4854 * at least streamable via
4855 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4856 * using one of the stream types exposed via
4857 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4858 *
4859 * @see #ACTION_SEND
4860 * @see #ACTION_SEND_MULTIPLE
4861 */
4862 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4863 public static final String CATEGORY_TYPED_OPENABLE =
4864 "android.intent.category.TYPED_OPENABLE";
4865
4866 /**
4867 * To be used as code under test for framework instrumentation tests.
4868 */
4869 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4870 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
4871 /**
4872 * An activity to run when device is inserted into a car dock.
4873 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4874 * information, see {@link android.app.UiModeManager}.
4875 */
4876 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4877 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4878 /**
4879 * An activity to run when device is inserted into a car dock.
4880 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4881 * information, see {@link android.app.UiModeManager}.
4882 */
4883 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4884 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
4885 /**
4886 * An activity to run when device is inserted into a analog (low end) dock.
4887 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4888 * information, see {@link android.app.UiModeManager}.
4889 */
4890 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4891 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4892
4893 /**
4894 * An activity to run when device is inserted into a digital (high end) dock.
4895 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4896 * information, see {@link android.app.UiModeManager}.
4897 */
4898 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4899 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
4900
4901 /**
4902 * Used to indicate that the activity can be used in a car environment.
4903 */
4904 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4905 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4906
4907 /**
4908 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4909 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4910 * information, see {@link android.app.UiModeManager}.
4911 */
4912 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4913 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
4914
4915 /**
4916 * The accessibility shortcut is a global gesture for users with disabilities to trigger an
4917 * important for them accessibility feature to help developers determine whether they want to
4918 * make their activity a shortcut target.
4919 * <p>
4920 * An activity of interest to users with accessibility needs may request to be the target of
4921 * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category,
4922 * which will be dispatched by the system when the user activates the shortcut when it is
4923 * configured to point at this target.
4924 * </p>
4925 * <p>
4926 * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must
4927 * also do two things:
4928 * <ul>
4929 * <ol>
4930 * Specify that it handles the <code>android.intent.action.MAIN</code>
4931 * {@link android.content.Intent}
4932 * with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>.
4933 * </ol>
4934 * <ol>
4935 * Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the
4936 * manifest when declaring the activity.
4937 * </ol>
4938 * </ul>
4939 * If either of these items is missing, the system will ignore the accessibility shortcut
4940 * target. Following is an example declaration:
4941 * </p>
4942 * <pre>
4943 * &lt;activity android:name=".MainActivity"
4944 * . . .
4945 * &lt;intent-filter&gt;
4946 * &lt;action android:name="android.intent.action.MAIN" /&gt;
4947 * &lt;category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /&gt;
4948 * &lt;/intent-filter&gt;
4949 * &lt;meta-data android:name="android.accessibilityshortcut.target"
4950 * android:resource="@xml/accessibilityshortcut" /&gt;
4951 * &lt;/activity&gt;
4952 * </pre>
4953 * <p> This is a sample XML file configuring a accessibility shortcut target: </p>
4954 * <pre>
4955 * &lt;accessibility-shortcut-target
4956 * android:description="@string/shortcut_target_description"
4957 * android:summary="@string/shortcut_target_summary"
4958 * android:animatedImageDrawable="@drawable/shortcut_target_animated_image"
4959 * android:htmlDescription="@string/shortcut_target_html_description"
4960 * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /&gt;
4961 * </pre>
4962 * <p>
4963 * Both description and summary are necessary. The system will ignore the accessibility
4964 * shortcut target if they are missing. The animated image and html description are supported
4965 * to help users understand how to use the shortcut target. The settings activity is a
4966 * component name that allows the user to modify the settings for this accessibility shortcut
4967 * target.
4968 * </p>
4969 */
4970 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4971 public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET =
4972 "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET";
4973 // ---------------------------------------------------------------------
4974 // ---------------------------------------------------------------------
4975 // Application launch intent categories (see addCategory()).
4976
4977 /**
4978 * Used with {@link #ACTION_MAIN} to launch the browser application.
4979 * The activity should be able to browse the Internet.
4980 * <p>NOTE: This should not be used as the primary key of an Intent,
4981 * since it will not result in the app launching with the correct
4982 * action and category. Instead, use this with
4983 * {@link #makeMainSelectorActivity(String, String)} to generate a main
4984 * Intent with this category in the selector.</p>
4985 */
4986 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4987 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4988
4989 /**
4990 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4991 * The activity should be able to perform standard arithmetic operations.
4992 * <p>NOTE: This should not be used as the primary key of an Intent,
4993 * since it will not result in the app launching with the correct
4994 * action and category. Instead, use this with
4995 * {@link #makeMainSelectorActivity(String, String)} to generate a main
4996 * Intent with this category in the selector.</p>
4997 */
4998 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4999 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
5000
5001 /**
5002 * Used with {@link #ACTION_MAIN} to launch the calendar application.
5003 * The activity should be able to view and manipulate calendar entries.
5004 * <p>NOTE: This should not be used as the primary key of an Intent,
5005 * since it will not result in the app launching with the correct
5006 * action and category. Instead, use this with
5007 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5008 * Intent with this category in the selector.</p>
5009 */
5010 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5011 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
5012
5013 /**
5014 * Used with {@link #ACTION_MAIN} to launch the contacts application.
5015 * The activity should be able to view and manipulate address book entries.
5016 * <p>NOTE: This should not be used as the primary key of an Intent,
5017 * since it will not result in the app launching with the correct
5018 * action and category. Instead, use this with
5019 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5020 * Intent with this category in the selector.</p>
5021 */
5022 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5023 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
5024
5025 /**
5026 * Used with {@link #ACTION_MAIN} to launch the email application.
5027 * The activity should be able to send and receive email.
5028 * <p>NOTE: This should not be used as the primary key of an Intent,
5029 * since it will not result in the app launching with the correct
5030 * action and category. Instead, use this with
5031 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5032 * Intent with this category in the selector.</p>
5033 */
5034 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5035 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
5036
5037 /**
5038 * Used with {@link #ACTION_MAIN} to launch the gallery application.
5039 * The activity should be able to view and manipulate image and video files
5040 * stored on the device.
5041 * <p>NOTE: This should not be used as the primary key of an Intent,
5042 * since it will not result in the app launching with the correct
5043 * action and category. Instead, use this with
5044 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5045 * Intent with this category in the selector.</p>
5046 */
5047 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5048 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
5049
5050 /**
5051 * Used with {@link #ACTION_MAIN} to launch the maps application.
5052 * The activity should be able to show the user's current location and surroundings.
5053 * <p>NOTE: This should not be used as the primary key of an Intent,
5054 * since it will not result in the app launching with the correct
5055 * action and category. Instead, use this with
5056 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5057 * Intent with this category in the selector.</p>
5058 */
5059 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5060 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
5061
5062 /**
5063 * Used with {@link #ACTION_MAIN} to launch the messaging application.
5064 * The activity should be able to send and receive text messages.
5065 * <p>NOTE: This should not be used as the primary key of an Intent,
5066 * since it will not result in the app launching with the correct
5067 * action and category. Instead, use this with
5068 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5069 * Intent with this category in the selector.</p>
5070 */
5071 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5072 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
5073
5074 /**
5075 * Used with {@link #ACTION_MAIN} to launch the music application.
5076 * The activity should be able to play, browse, or manipulate music files
5077 * stored on the device.
5078 * <p>NOTE: This should not be used as the primary key of an Intent,
5079 * since it will not result in the app launching with the correct
5080 * action and category. Instead, use this with
5081 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5082 * Intent with this category in the selector.</p>
5083 */
5084 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5085 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
5086
5087 /**
5088 * Used with {@link #ACTION_MAIN} to launch the files application.
5089 * The activity should be able to browse and manage files stored on the device.
5090 * <p>NOTE: This should not be used as the primary key of an Intent,
5091 * since it will not result in the app launching with the correct
5092 * action and category. Instead, use this with
5093 * {@link #makeMainSelectorActivity(String, String)} to generate a main
5094 * Intent with this category in the selector.</p>
5095 */
5096 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5097 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES";
5098
5099 // ---------------------------------------------------------------------
5100 // ---------------------------------------------------------------------
5101 // Standard extra data keys.
5102
5103 /**
5104 * The initial data to place in a newly created record. Use with
5105 * {@link #ACTION_INSERT}. The data here is a Map containing the same
5106 * fields as would be given to the underlying ContentProvider.insert()
5107 * call.
5108 */
5109 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
5110
5111 /**
5112 * A constant CharSequence that is associated with the Intent, used with
5113 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
5114 * this may be a styled CharSequence, so you must use
5115 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
5116 * retrieve it.
5117 */
5118 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
5119
5120 /**
5121 * A constant String that is associated with the Intent, used with
5122 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
5123 * as HTML formatted text. Note that you <em>must</em> also supply
5124 * {@link #EXTRA_TEXT}.
5125 */
5126 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
5127
5128 /**
5129 * A content: URI holding a stream of data associated with the Intent,
5130 * used with {@link #ACTION_SEND} to supply the data being sent.
5131 */
5132 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
5133
5134 /**
5135 * A String[] holding e-mail addresses that should be delivered to.
5136 */
5137 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
5138
5139 /**
5140 * A String[] holding e-mail addresses that should be carbon copied.
5141 */
5142 public static final String EXTRA_CC = "android.intent.extra.CC";
5143
5144 /**
5145 * A String[] holding e-mail addresses that should be blind carbon copied.
5146 */
5147 public static final String EXTRA_BCC = "android.intent.extra.BCC";
5148
5149 /**
5150 * A constant string holding the desired subject line of a message.
5151 */
5152 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
5153
5154 /**
5155 * An Intent describing the choices you would like shown with
5156 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
5157 */
5158 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
5159
5160 /**
5161 * An int representing the user id to be used.
5162 *
5163 * @hide
5164 */
5165 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
5166
5167 /**
5168 * An int representing the task id to be retrieved. This is used when a launch from recents is
5169 * intercepted by another action such as credentials confirmation to remember which task should
5170 * be resumed when complete.
5171 *
5172 * @hide
5173 */
5174 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
5175
5176 /**
5177 * An Intent[] describing additional, alternate choices you would like shown with
5178 * {@link #ACTION_CHOOSER}.
5179 *
5180 * <p>An app may be capable of providing several different payload types to complete a
5181 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
5182 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
5183 * several different supported sending mechanisms for sharing, such as the actual "image/*"
5184 * photo data or a hosted link where the photos can be viewed.</p>
5185 *
5186 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
5187 * first/primary/preferred intent in the set. Additional intents specified in
5188 * this extra are ordered; by default intents that appear earlier in the array will be
5189 * preferred over intents that appear later in the array as matches for the same
5190 * target component. To alter this preference, a calling app may also supply
5191 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
5192 */
5193 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
5194
5195 /**
5196 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
5197 * and omitted from a list of components presented to the user.
5198 *
5199 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
5200 * in this array if it otherwise would have shown them. Useful for omitting specific targets
5201 * from your own package or other apps from your organization if the idea of sending to those
5202 * targets would be redundant with other app functionality. Filtered components will not
5203 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
5204 */
5205 public static final String EXTRA_EXCLUDE_COMPONENTS
5206 = "android.intent.extra.EXCLUDE_COMPONENTS";
5207
5208 /**
5209 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
5210 * describing additional high-priority deep-link targets for the chooser to present to the user.
5211 *
5212 * <p>Targets provided in this way will be presented inline with all other targets provided
5213 * by services from other apps. They will be prioritized before other service targets, but
5214 * after those targets provided by sources that the user has manually pinned to the front.</p>
5215 *
5216 * @see #ACTION_CHOOSER
5217 */
5218 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
5219
5220 /**
5221 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
5222 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
5223 *
5224 * <p>An app preparing an action for another app to complete may wish to allow the user to
5225 * disambiguate between several options for completing the action based on the chosen target
5226 * or otherwise refine the action before it is invoked.
5227 * </p>
5228 *
5229 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
5230 * <ul>
5231 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
5232 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
5233 * chosen target beyond the first</li>
5234 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
5235 * should fill in and send once the disambiguation is complete</li>
5236 * </ul>
5237 */
5238 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
5239 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
5240
5241 /**
5242 * An {@code ArrayList} of {@code String} annotations describing content for
5243 * {@link #ACTION_CHOOSER}.
5244 *
5245 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
5246 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
5247 *
5248 * <p>Annotations should describe the major components or topics of the content. It is up to
5249 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
5250 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
5251 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
5252 * character. Performance on customized annotations can suffer, if they are rarely used for
5253 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
5254 * following annotations when applicable.</p>
5255 * <ul>
5256 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
5257 * health & beauty, and office supplies.</li>
5258 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
5259 * happy, and sad.</li>
5260 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
5261 * face, finger, standing, and walking.</li>
5262 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
5263 * child, and baby.</li>
5264 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
5265 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
5266 * <li>"party" represents that the topic of the content is mainly about parties.</li>
5267 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
5268 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
5269 * flowers.</li>
5270 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
5271 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
5272 * sunglasses, jewelry, handbags and clothing.</li>
5273 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
5274 * paper, and silk.</li>
5275 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
5276 * cars, and boats.</li>
5277 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
5278 * posters.</li>
5279 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
5280 * and designs of houses.</li>
5281 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
5282 * Christmas and Thanksgiving.</li>
5283 * </ul>
5284 */
5285 public static final String EXTRA_CONTENT_ANNOTATIONS
5286 = "android.intent.extra.CONTENT_ANNOTATIONS";
5287
5288 /**
5289 * A {@link ResultReceiver} used to return data back to the sender.
5290 *
5291 * <p>Used to complete an app-specific
5292 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
5293 *
5294 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
5295 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
5296 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
5297 * when the user selects a target component from the chooser. It is up to the recipient
5298 * to send a result to this ResultReceiver to signal that disambiguation is complete
5299 * and that the chooser should invoke the user's choice.</p>
5300 *
5301 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
5302 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
5303 * to match and fill in the final Intent or ChooserTarget before starting it.
5304 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
5305 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
5306 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
5307 *
5308 * <p>The result code passed to the ResultReceiver should be
5309 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
5310 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
5311 * the chooser should finish without starting a target.</p>
5312 */
5313 public static final String EXTRA_RESULT_RECEIVER
5314 = "android.intent.extra.RESULT_RECEIVER";
5315
5316 /**
5317 * A CharSequence dialog title to provide to the user when used with a
5318 * {@link #ACTION_CHOOSER}.
5319 */
5320 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
5321
5322 /**
5323 * A Parcelable[] of {@link Intent} or
5324 * {@link android.content.pm.LabeledIntent} objects as set with
5325 * {@link #putExtra(String, Parcelable[])} of additional activities to place
5326 * a the front of the list of choices, when shown to the user with a
5327 * {@link #ACTION_CHOOSER}.
5328 */
5329 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
5330
5331 /**
5332 * A {@link IntentSender} to start after instant app installation success.
5333 * @hide
5334 */
5335 @SystemApi
5336 public static final String EXTRA_INSTANT_APP_SUCCESS =
5337 "android.intent.extra.INSTANT_APP_SUCCESS";
5338
5339 /**
5340 * A {@link IntentSender} to start after instant app installation failure.
5341 * @hide
5342 */
5343 @SystemApi
5344 public static final String EXTRA_INSTANT_APP_FAILURE =
5345 "android.intent.extra.INSTANT_APP_FAILURE";
5346
5347 /**
5348 * The host name that triggered an instant app resolution.
5349 * @hide
5350 */
5351 @SystemApi
5352 public static final String EXTRA_INSTANT_APP_HOSTNAME =
5353 "android.intent.extra.INSTANT_APP_HOSTNAME";
5354
5355 /**
5356 * An opaque token to track instant app resolution.
5357 * @hide
5358 */
5359 @SystemApi
5360 public static final String EXTRA_INSTANT_APP_TOKEN =
5361 "android.intent.extra.INSTANT_APP_TOKEN";
5362
5363 /**
5364 * The action that triggered an instant application resolution.
5365 * @hide
5366 */
5367 @SystemApi
5368 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
5369
5370 /**
5371 * An array of {@link Bundle}s containing details about resolved instant apps..
5372 * @hide
5373 */
5374 @SystemApi
5375 public static final String EXTRA_INSTANT_APP_BUNDLES =
5376 "android.intent.extra.INSTANT_APP_BUNDLES";
5377
5378 /**
5379 * A {@link Bundle} of metadata that describes the instant application that needs to be
5380 * installed. This data is populated from the response to
5381 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
5382 * instant application resolver.
5383 * @hide
5384 */
5385 @SystemApi
5386 public static final String EXTRA_INSTANT_APP_EXTRAS =
5387 "android.intent.extra.INSTANT_APP_EXTRAS";
5388
5389 /**
5390 * A boolean value indicating that the instant app resolver was unable to state with certainty
5391 * that it did or did not have an app for the sanitized {@link Intent} defined at
5392 * {@link #EXTRA_INTENT}.
5393 * @hide
5394 */
5395 @SystemApi
5396 public static final String EXTRA_UNKNOWN_INSTANT_APP =
5397 "android.intent.extra.UNKNOWN_INSTANT_APP";
5398
5399 /**
5400 * The version code of the app to install components from.
5401 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
5402 * @hide
5403 */
5404 @Deprecated
5405 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5406
5407 /**
5408 * The version code of the app to install components from.
5409 * @hide
5410 */
5411 @SystemApi
5412 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5413
5414 /**
5415 * The app that triggered the instant app installation.
5416 * @hide
5417 */
5418 @SystemApi
5419 public static final String EXTRA_CALLING_PACKAGE
5420 = "android.intent.extra.CALLING_PACKAGE";
5421
5422 /**
5423 * Optional calling app provided bundle containing additional launch information the
5424 * installer may use.
5425 * @hide
5426 */
5427 @SystemApi
5428 public static final String EXTRA_VERIFICATION_BUNDLE
5429 = "android.intent.extra.VERIFICATION_BUNDLE";
5430
5431 /**
5432 * A Bundle forming a mapping of potential target package names to different extras Bundles
5433 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5434 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5435 * be currently installed on the device.
5436 *
5437 * <p>An application may choose to provide alternate extras for the case where a user
5438 * selects an activity from a predetermined set of target packages. If the activity
5439 * the user selects from the chooser belongs to a package with its package name as
5440 * a key in this bundle, the corresponding extras for that package will be merged with
5441 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5442 * extra has the same key as an extra already present in the intent it will overwrite
5443 * the extra from the intent.</p>
5444 *
5445 * <p><em>Examples:</em>
5446 * <ul>
5447 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
5448 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5449 * parameters for that target.</li>
5450 * <li>An application may offer additional metadata for known targets of a given intent
5451 * to pass along information only relevant to that target such as account or content
5452 * identifiers already known to that application.</li>
5453 * </ul></p>
5454 */
5455 public static final String EXTRA_REPLACEMENT_EXTRAS =
5456 "android.intent.extra.REPLACEMENT_EXTRAS";
5457
5458 /**
5459 * An {@link IntentSender} that will be notified if a user successfully chooses a target
5460 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5461 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5462 * {@link ComponentName} of the chosen component.
5463 *
5464 * <p>In some situations this callback may never come, for example if the user abandons
5465 * the chooser, switches to another task or any number of other reasons. Apps should not
5466 * be written assuming that this callback will always occur.</p>
5467 */
5468 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5469 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5470
5471 /**
5472 * The {@link ComponentName} chosen by the user to complete an action.
5473 *
5474 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5475 */
5476 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5477
5478 /**
5479 * A {@link android.view.KeyEvent} object containing the event that
5480 * triggered the creation of the Intent it is in.
5481 */
5482 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5483
5484 /**
5485 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
5486 * before shutting down.
5487 *
5488 * {@hide}
5489 */
5490 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
5491
5492 /**
5493 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
5494 * requested by the user.
5495 *
5496 * {@hide}
5497 */
5498 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
5499 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
5500
5501 /**
5502 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5503 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
5504 * of restarting the application.
5505 */
5506 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
5507
5508 /**
5509 * A String holding the phone number originally entered in
5510 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
5511 * number to call in a {@link android.content.Intent#ACTION_CALL}.
5512 */
5513 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
5514
5515 /**
5516 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
5517 * intents to supply the uid the package had been assigned. Also an optional
5518 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5519 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
5520 * purpose.
5521 */
5522 public static final String EXTRA_UID = "android.intent.extra.UID";
5523
5524 /**
5525 * @hide String array of package names.
5526 */
5527 @SystemApi
5528 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
5529
5530 /**
5531 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5532 * intents to indicate whether this represents a full uninstall (removing
5533 * both the code and its data) or a partial uninstall (leaving its data,
5534 * implying that this is an update).
5535 */
5536 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
5537
5538 /**
5539 * @hide
5540 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5541 * intents to indicate that at this point the package has been removed for
5542 * all users on the device.
5543 */
5544 public static final String EXTRA_REMOVED_FOR_ALL_USERS
5545 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
5546
5547 /**
5548 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5549 * intents to indicate that this is a replacement of the package, so this
5550 * broadcast will immediately be followed by an add broadcast for a
5551 * different version of the same package.
5552 */
5553 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
5554
5555 /**
5556 * Used as an int extra field in {@link android.app.AlarmManager} intents
5557 * to tell the application being invoked how many pending alarms are being
5558 * delievered with the intent. For one-shot alarms this will always be 1.
5559 * For recurring alarms, this might be greater than 1 if the device was
5560 * asleep or powered off at the time an earlier alarm would have been
5561 * delivered.
5562 */
5563 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
5564
5565 /**
5566 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
5567 * intents to request the dock state. Possible values are
5568 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
5569 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
5570 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
5571 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
5572 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
5573 */
5574 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
5575
5576 /**
5577 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5578 * to represent that the phone is not in any dock.
5579 */
5580 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
5581
5582 /**
5583 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5584 * to represent that the phone is in a desk dock.
5585 */
5586 public static final int EXTRA_DOCK_STATE_DESK = 1;
5587
5588 /**
5589 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5590 * to represent that the phone is in a car dock.
5591 */
5592 public static final int EXTRA_DOCK_STATE_CAR = 2;
5593
5594 /**
5595 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5596 * to represent that the phone is in a analog (low end) dock.
5597 */
5598 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
5599
5600 /**
5601 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5602 * to represent that the phone is in a digital (high end) dock.
5603 */
5604 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
5605
5606 /**
5607 * Boolean that can be supplied as meta-data with a dock activity, to
5608 * indicate that the dock should take over the home key when it is active.
5609 */
5610 public static final String METADATA_DOCK_HOME = "android.dock_home";
5611
5612 /**
5613 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
5614 * the bug report.
5615 */
5616 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
5617
5618 /**
5619 * Used in the extra field in the remote intent. It's astring token passed with the
5620 * remote intent.
5621 */
5622 public static final String EXTRA_REMOTE_INTENT_TOKEN =
5623 "android.intent.extra.remote_intent_token";
5624
5625 /**
5626 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
5627 * will contain only the first name in the list.
5628 */
5629 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
5630 "android.intent.extra.changed_component_name";
5631
5632 /**
5633 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
5634 * and contains a string array of all of the components that have changed. If
5635 * the state of the overall package has changed, then it will contain an entry
5636 * with the package name itself.
5637 */
5638 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5639 "android.intent.extra.changed_component_name_list";
5640
5641 /**
5642 * This field is part of
5643 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5644 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5645 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5646 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
5647 * and contains a string array of all of the components that have changed.
5648 */
5649 public static final String EXTRA_CHANGED_PACKAGE_LIST =
5650 "android.intent.extra.changed_package_list";
5651
5652 /**
5653 * This field is part of
5654 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5655 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
5656 * and contains an integer array of uids of all of the components
5657 * that have changed.
5658 */
5659 public static final String EXTRA_CHANGED_UID_LIST =
5660 "android.intent.extra.changed_uid_list";
5661
5662 /**
5663 * An integer denoting a bitwise combination of restrictions set on distracting packages via
5664 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
5665 *
5666 * @hide
5667 * @see PackageManager.DistractionRestriction
5668 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
5669 */
5670 public static final String EXTRA_DISTRACTION_RESTRICTIONS =
5671 "android.intent.extra.distraction_restrictions";
5672
5673 /**
5674 * @hide
5675 * Magic extra system code can use when binding, to give a label for
5676 * who it is that has bound to a service. This is an integer giving
5677 * a framework string resource that can be displayed to the user.
5678 */
5679 public static final String EXTRA_CLIENT_LABEL =
5680 "android.intent.extra.client_label";
5681
5682 /**
5683 * @hide
5684 * Magic extra system code can use when binding, to give a PendingIntent object
5685 * that can be launched for the user to disable the system's use of this
5686 * service.
5687 */
5688 public static final String EXTRA_CLIENT_INTENT =
5689 "android.intent.extra.client_intent";
5690
5691 /**
5692 * Extra used to indicate that an intent should only return data that is on
5693 * the local device. This is a boolean extra; the default is false. If true,
5694 * an implementation should only allow the user to select data that is
5695 * already on the device, not requiring it be downloaded from a remote
5696 * service when opened.
5697 *
5698 * @see #ACTION_GET_CONTENT
5699 * @see #ACTION_OPEN_DOCUMENT
5700 * @see #ACTION_OPEN_DOCUMENT_TREE
5701 * @see #ACTION_CREATE_DOCUMENT
5702 */
5703 public static final String EXTRA_LOCAL_ONLY =
5704 "android.intent.extra.LOCAL_ONLY";
5705
5706 /**
5707 * Extra used to indicate that an intent can allow the user to select and
5708 * return multiple items. This is a boolean extra; the default is false. If
5709 * true, an implementation is allowed to present the user with a UI where
5710 * they can pick multiple items that are all returned to the caller. When
5711 * this happens, they should be returned as the {@link #getClipData()} part
5712 * of the result Intent.
5713 *
5714 * @see #ACTION_GET_CONTENT
5715 * @see #ACTION_OPEN_DOCUMENT
5716 */
5717 public static final String EXTRA_ALLOW_MULTIPLE =
5718 "android.intent.extra.ALLOW_MULTIPLE";
5719
5720 /**
5721 * The integer userHandle (i.e. userId) carried with broadcast intents related to addition,
5722 * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5723 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5724 *
5725 * @hide
5726 */
5727 public static final String EXTRA_USER_HANDLE =
5728 "android.intent.extra.user_handle";
5729
5730 /**
5731 * The UserHandle carried with intents.
5732 */
5733 public static final String EXTRA_USER =
5734 "android.intent.extra.USER";
5735
5736 /**
5737 * Extra used in the response from a BroadcastReceiver that handles
5738 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5739 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
5740 */
5741 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5742
5743 /**
5744 * Extra sent in the intent to the BroadcastReceiver that handles
5745 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5746 * the restrictions as key/value pairs.
5747 */
5748 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5749 "android.intent.extra.restrictions_bundle";
5750
5751 /**
5752 * Extra used in the response from a BroadcastReceiver that handles
5753 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5754 */
5755 public static final String EXTRA_RESTRICTIONS_INTENT =
5756 "android.intent.extra.restrictions_intent";
5757
5758 /**
5759 * Extra used to communicate a set of acceptable MIME types. The type of the
5760 * extra is {@code String[]}. Values may be a combination of concrete MIME
5761 * types (such as "image/png") and/or partial MIME types (such as
5762 * "audio/*").
5763 *
5764 * @see #ACTION_GET_CONTENT
5765 * @see #ACTION_OPEN_DOCUMENT
5766 */
5767 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5768
5769 /**
5770 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5771 * this shutdown is only for the user space of the system, not a complete shutdown.
5772 * When this is true, hardware devices can use this information to determine that
5773 * they shouldn't do a complete shutdown of their device since this is not a
5774 * complete shutdown down to the kernel, but only user space restarting.
5775 * The default if not supplied is false.
5776 */
5777 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5778 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5779
5780 /**
5781 * Optional extra specifying a time in milliseconds since the Epoch. The value must be
5782 * non-negative.
5783 * <p>
5784 * Type: long
5785 * </p>
5786 */
5787 public static final String EXTRA_TIME = "android.intent.extra.TIME";
5788
5789 /**
5790 * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device.
5791 *
5792 * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones.
5793 */
5794 @SuppressLint("ActionValue")
5795 public static final String EXTRA_TIMEZONE = "time-zone";
5796
5797 /**
5798 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5799 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5800 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5801 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
5802 *
5803 * @hide for internal use only.
5804 */
5805 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5806 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
5807 /** @hide */
5808 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5809 /** @hide */
5810 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5811 /** @hide */
5812 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
5813
5814 /**
5815 * Intent extra: the reason that the operation associated with this intent is being performed.
5816 *
5817 * <p>Type: String
5818 * @hide
5819 */
5820 @SystemApi
5821 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5822
5823 /**
5824 * {@hide}
5825 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5826 */
5827 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5828
5829 /**
5830 * {@hide}
5831 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5832 * reset for the device with eSIM. This extra will be sent together with
5833 * {@link #ACTION_FACTORY_RESET}
5834 */
5835 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5836
5837 /**
5838 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5839 * activation request.
5840 * TODO: Add information about the structure and response data used with the pending intent.
5841 * @hide
5842 */
5843 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5844 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5845
5846 /**
5847 * Optional index with semantics depending on the intent action.
5848 *
5849 * <p>The value must be an integer greater or equal to 0.
5850 * @see #ACTION_QUICK_VIEW
5851 */
5852 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5853
5854 /**
5855 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5856 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5857 * casting, etc.
5858 *
5859 * <p>The value is boolean. By default false.
5860 * @see #ACTION_QUICK_VIEW
5861 * @removed
5862 */
5863 @Deprecated
5864 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5865 "android.intent.extra.QUICK_VIEW_ADVANCED";
5866
5867 /**
5868 * An optional extra of {@code String[]} indicating which quick view features should be made
5869 * available to the user in the quick view UI while handing a
5870 * {@link Intent#ACTION_QUICK_VIEW} intent.
5871 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5872 * Quick viewer can implement features not listed below.
5873 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
5874 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5875 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5876 * {@link QuickViewConstants#FEATURE_PRINT}.
5877 * <p>
5878 * Requirements:
5879 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5880 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5881 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5882 * internal policies.
5883 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5884 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5885 * disable or hide features.
5886 *
5887 * @see #ACTION_QUICK_VIEW
5888 */
5889 public static final String EXTRA_QUICK_VIEW_FEATURES =
5890 "android.intent.extra.QUICK_VIEW_FEATURES";
5891
5892 /**
5893 * Optional boolean extra indicating whether quiet mode has been switched on or off.
5894 * When a profile goes into quiet mode, all apps in the profile are killed and the
5895 * profile user is stopped. Widgets originating from the profile are masked, and app
5896 * launcher icons are grayed out.
5897 */
5898 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
5899
5900 /**
5901 * Optional CharSequence extra to provide a search query.
5902 * The format of this query is dependent on the receiving application.
5903 *
5904 * <p>Applicable to {@link Intent} with actions:
5905 * <ul>
5906 * <li>{@link Intent#ACTION_GET_CONTENT}</li>
5907 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
5908 * </ul>
5909 */
5910 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
5911
5912 /**
5913 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
5914 * intents to specify the resource type granted. Possible values are
5915 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5916 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
5917 *
5918 * @hide
5919 */
5920 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5921 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5922
5923 /**
5924 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5925 * whether to show the chooser or not when there is only one application available
5926 * to choose from.
5927 */
5928 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5929 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5930
5931 /**
5932 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
5933 * to represent that a video codec is allowed to use.
5934 *
5935 * @hide
5936 */
5937 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5938
5939 /**
5940 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
5941 * to represent that a audio codec is allowed to use.
5942 *
5943 * @hide
5944 */
5945 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5946
5947 /**
5948 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
5949 *
5950 * <p>
5951 * Type: {@link LocusId}
5952 * </p>
5953 */
5954 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
5955
5956 // ---------------------------------------------------------------------
5957 // ---------------------------------------------------------------------
5958 // Intent flags (see mFlags variable).
5959
5960 /** @hide */
5961 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
5962 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5963 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
5964 @Retention(RetentionPolicy.SOURCE)
5965 public @interface GrantUriMode {}
5966
5967 /** @hide */
5968 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
5969 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5970 @Retention(RetentionPolicy.SOURCE)
5971 public @interface AccessUriMode {}
5972
5973 /**
5974 * Test if given mode flags specify an access mode, which must be at least
5975 * read and/or write.
5976 *
5977 * @hide
5978 */
5979 public static boolean isAccessUriMode(int modeFlags) {
5980 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5981 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5982 }
5983
5984 /** @hide */
5985 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5986 FLAG_GRANT_READ_URI_PERMISSION,
5987 FLAG_GRANT_WRITE_URI_PERMISSION,
5988 FLAG_FROM_BACKGROUND,
5989 FLAG_DEBUG_LOG_RESOLUTION,
5990 FLAG_EXCLUDE_STOPPED_PACKAGES,
5991 FLAG_INCLUDE_STOPPED_PACKAGES,
5992 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5993 FLAG_GRANT_PREFIX_URI_PERMISSION,
5994 FLAG_DEBUG_TRIAGED_MISSING,
5995 FLAG_IGNORE_EPHEMERAL,
5996 FLAG_ACTIVITY_MATCH_EXTERNAL,
5997 FLAG_ACTIVITY_NO_HISTORY,
5998 FLAG_ACTIVITY_SINGLE_TOP,
5999 FLAG_ACTIVITY_NEW_TASK,
6000 FLAG_ACTIVITY_MULTIPLE_TASK,
6001 FLAG_ACTIVITY_CLEAR_TOP,
6002 FLAG_ACTIVITY_FORWARD_RESULT,
6003 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6004 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6005 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6006 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6007 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6008 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6009 FLAG_ACTIVITY_NEW_DOCUMENT,
6010 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6011 FLAG_ACTIVITY_NO_USER_ACTION,
6012 FLAG_ACTIVITY_REORDER_TO_FRONT,
6013 FLAG_ACTIVITY_NO_ANIMATION,
6014 FLAG_ACTIVITY_CLEAR_TASK,
6015 FLAG_ACTIVITY_TASK_ON_HOME,
6016 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6017 FLAG_ACTIVITY_LAUNCH_ADJACENT,
6018 FLAG_ACTIVITY_REQUIRE_NON_BROWSER,
6019 FLAG_ACTIVITY_REQUIRE_DEFAULT,
6020 FLAG_RECEIVER_REGISTERED_ONLY,
6021 FLAG_RECEIVER_REPLACE_PENDING,
6022 FLAG_RECEIVER_FOREGROUND,
6023 FLAG_RECEIVER_NO_ABORT,
6024 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6025 FLAG_RECEIVER_BOOT_UPGRADE,
6026 FLAG_RECEIVER_INCLUDE_BACKGROUND,
6027 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6028 FLAG_RECEIVER_FROM_SHELL,
6029 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6030 FLAG_RECEIVER_OFFLOAD,
6031 })
6032 @Retention(RetentionPolicy.SOURCE)
6033 public @interface Flags {}
6034
6035 /** @hide */
6036 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
6037 FLAG_FROM_BACKGROUND,
6038 FLAG_DEBUG_LOG_RESOLUTION,
6039 FLAG_EXCLUDE_STOPPED_PACKAGES,
6040 FLAG_INCLUDE_STOPPED_PACKAGES,
6041 FLAG_DEBUG_TRIAGED_MISSING,
6042 FLAG_IGNORE_EPHEMERAL,
6043 FLAG_ACTIVITY_MATCH_EXTERNAL,
6044 FLAG_ACTIVITY_NO_HISTORY,
6045 FLAG_ACTIVITY_SINGLE_TOP,
6046 FLAG_ACTIVITY_NEW_TASK,
6047 FLAG_ACTIVITY_MULTIPLE_TASK,
6048 FLAG_ACTIVITY_CLEAR_TOP,
6049 FLAG_ACTIVITY_FORWARD_RESULT,
6050 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6051 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6052 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6053 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6054 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6055 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6056 FLAG_ACTIVITY_NEW_DOCUMENT,
6057 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6058 FLAG_ACTIVITY_NO_USER_ACTION,
6059 FLAG_ACTIVITY_REORDER_TO_FRONT,
6060 FLAG_ACTIVITY_NO_ANIMATION,
6061 FLAG_ACTIVITY_CLEAR_TASK,
6062 FLAG_ACTIVITY_TASK_ON_HOME,
6063 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6064 FLAG_ACTIVITY_LAUNCH_ADJACENT,
6065 FLAG_RECEIVER_REGISTERED_ONLY,
6066 FLAG_RECEIVER_REPLACE_PENDING,
6067 FLAG_RECEIVER_FOREGROUND,
6068 FLAG_RECEIVER_NO_ABORT,
6069 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6070 FLAG_RECEIVER_BOOT_UPGRADE,
6071 FLAG_RECEIVER_INCLUDE_BACKGROUND,
6072 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6073 FLAG_RECEIVER_FROM_SHELL,
6074 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6075 FLAG_RECEIVER_OFFLOAD,
6076 })
6077 @Retention(RetentionPolicy.SOURCE)
6078 public @interface MutableFlags {}
6079
6080 /**
6081 * If set, the recipient of this Intent will be granted permission to
6082 * perform read operations on the URI in the Intent's data and any URIs
6083 * specified in its ClipData. When applying to an Intent's ClipData,
6084 * all URIs as well as recursive traversals through data or other ClipData
6085 * in Intent items will be granted; only the grant flags of the top-level
6086 * Intent are used.
6087 */
6088 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
6089 /**
6090 * If set, the recipient of this Intent will be granted permission to
6091 * perform write operations on the URI in the Intent's data and any URIs
6092 * specified in its ClipData. When applying to an Intent's ClipData,
6093 * all URIs as well as recursive traversals through data or other ClipData
6094 * in Intent items will be granted; only the grant flags of the top-level
6095 * Intent are used.
6096 */
6097 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
6098 /**
6099 * Can be set by the caller to indicate that this Intent is coming from
6100 * a background operation, not from direct user interaction.
6101 */
6102 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
6103 /**
6104 * A flag you can enable for debugging: when set, log messages will be
6105 * printed during the resolution of this intent to show you what has
6106 * been found to create the final resolved list.
6107 */
6108 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
6109 /**
6110 * If set, this intent will not match any components in packages that
6111 * are currently stopped. If this is not set, then the default behavior
6112 * is to include such applications in the result.
6113 */
6114 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
6115 /**
6116 * If set, this intent will always match any components in packages that
6117 * are currently stopped. This is the default behavior when
6118 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
6119 * flags are set, this one wins (it allows overriding of exclude for
6120 * places where the framework may automatically set the exclude flag).
6121 */
6122 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
6123
6124 /**
6125 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6126 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
6127 * persisted across device reboots until explicitly revoked with
6128 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
6129 * grant for possible persisting; the receiving application must call
6130 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
6131 * actually persist.
6132 *
6133 * @see ContentResolver#takePersistableUriPermission(Uri, int)
6134 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
6135 * @see ContentResolver#getPersistedUriPermissions()
6136 * @see ContentResolver#getOutgoingPersistedUriPermissions()
6137 */
6138 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
6139
6140 /**
6141 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6142 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
6143 * applies to any URI that is a prefix match against the original granted
6144 * URI. (Without this flag, the URI must match exactly for access to be
6145 * granted.) Another URI is considered a prefix match only when scheme,
6146 * authority, and all path segments defined by the prefix are an exact
6147 * match.
6148 */
6149 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
6150
6151 /**
6152 * Flag used to automatically match intents based on their Direct Boot
6153 * awareness and the current user state.
6154 * <p>
6155 * Since the default behavior is to automatically apply the current user
6156 * state, this is effectively a sentinel value that doesn't change the
6157 * output of any queries based on its presence or absence.
6158 * <p>
6159 * Instead, this value can be useful in conjunction with
6160 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
6161 * to detect when a caller is relying on implicit automatic matching,
6162 * instead of confirming the explicit behavior they want.
6163 */
6164 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
6165
6166 /** {@hide} */
6167 @Deprecated
6168 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
6169
6170 /**
6171 * Internal flag used to indicate ephemeral applications should not be
6172 * considered when resolving the intent.
6173 *
6174 * @hide
6175 */
6176 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
6177
6178 /**
6179 * If set, the new activity is not kept in the history stack. As soon as
6180 * the user navigates away from it, the activity is finished. This may also
6181 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
6182 * noHistory} attribute.
6183 *
6184 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
6185 * is never invoked when the current activity starts a new activity which
6186 * sets a result and finishes.
6187 */
6188 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
6189 /**
6190 * If set, the activity will not be launched if it is already running
6191 * at the top of the history stack.
6192 */
6193 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
6194 /**
6195 * If set, this activity will become the start of a new task on this
6196 * history stack. A task (from the activity that started it to the
6197 * next task activity) defines an atomic group of activities that the
6198 * user can move to. Tasks can be moved to the foreground and background;
6199 * all of the activities inside of a particular task always remain in
6200 * the same order. See
6201 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6202 * Stack</a> for more information about tasks.
6203 *
6204 * <p>This flag is generally used by activities that want
6205 * to present a "launcher" style behavior: they give the user a list of
6206 * separate things that can be done, which otherwise run completely
6207 * independently of the activity launching them.
6208 *
6209 * <p>When using this flag, if a task is already running for the activity
6210 * you are now starting, then a new activity will not be started; instead,
6211 * the current task will simply be brought to the front of the screen with
6212 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
6213 * to disable this behavior.
6214 *
6215 * <p>This flag can not be used when the caller is requesting a result from
6216 * the activity being launched.
6217 */
6218 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
6219 /**
6220 * This flag is used to create a new task and launch an activity into it.
6221 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
6222 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
6223 * search through existing tasks for ones matching this Intent. Only if no such
6224 * task is found would a new task be created. When paired with
6225 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
6226 * the search for a matching task and unconditionally start a new task.
6227 *
6228 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
6229 * flag unless you are implementing your own
6230 * top-level application launcher.</strong> Used in conjunction with
6231 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
6232 * behavior of bringing an existing task to the foreground. When set,
6233 * a new task is <em>always</em> started to host the Activity for the
6234 * Intent, regardless of whether there is already an existing task running
6235 * the same thing.
6236 *
6237 * <p><strong>Because the default system does not include graphical task management,
6238 * you should not use this flag unless you provide some way for a user to
6239 * return back to the tasks you have launched.</strong>
6240 *
6241 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
6242 * creating new document tasks.
6243 *
6244 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
6245 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
6246 *
6247 * <p>See
6248 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6249 * Stack</a> for more information about tasks.
6250 *
6251 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
6252 * @see #FLAG_ACTIVITY_NEW_TASK
6253 */
6254 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
6255 /**
6256 * If set, and the activity being launched is already running in the
6257 * current task, then instead of launching a new instance of that activity,
6258 * all of the other activities on top of it will be closed and this Intent
6259 * will be delivered to the (now on top) old activity as a new Intent.
6260 *
6261 * <p>For example, consider a task consisting of the activities: A, B, C, D.
6262 * If D calls startActivity() with an Intent that resolves to the component
6263 * of activity B, then C and D will be finished and B receive the given
6264 * Intent, resulting in the stack now being: A, B.
6265 *
6266 * <p>The currently running instance of activity B in the above example will
6267 * either receive the new intent you are starting here in its
6268 * onNewIntent() method, or be itself finished and restarted with the
6269 * new intent. If it has declared its launch mode to be "multiple" (the
6270 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
6271 * the same intent, then it will be finished and re-created; for all other
6272 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
6273 * Intent will be delivered to the current instance's onNewIntent().
6274 *
6275 * <p>This launch mode can also be used to good effect in conjunction with
6276 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
6277 * of a task, it will bring any currently running instance of that task
6278 * to the foreground, and then clear it to its root state. This is
6279 * especially useful, for example, when launching an activity from the
6280 * notification manager.
6281 *
6282 * <p>See
6283 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6284 * Stack</a> for more information about tasks.
6285 */
6286 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
6287 /**
6288 * If set and this intent is being used to launch a new activity from an
6289 * existing one, then the reply target of the existing activity will be
6290 * transferred to the new activity. This way, the new activity can call
6291 * {@link android.app.Activity#setResult} and have that result sent back to
6292 * the reply target of the original activity.
6293 */
6294 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
6295 /**
6296 * If set and this intent is being used to launch a new activity from an
6297 * existing one, the current activity will not be counted as the top
6298 * activity for deciding whether the new intent should be delivered to
6299 * the top instead of starting a new one. The previous activity will
6300 * be used as the top, with the assumption being that the current activity
6301 * will finish itself immediately.
6302 */
6303 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
6304 /**
6305 * If set, the new activity is not kept in the list of recently launched
6306 * activities.
6307 */
6308 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
6309 /**
6310 * This flag is not normally set by application code, but set for you by
6311 * the system as described in the
6312 * {@link android.R.styleable#AndroidManifestActivity_launchMode
6313 * launchMode} documentation for the singleTask mode.
6314 */
6315 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
6316 /**
6317 * If set, and this activity is either being started in a new task or
6318 * bringing to the top an existing task, then it will be launched as
6319 * the front door of the task. This will result in the application of
6320 * any affinities needed to have that task in the proper state (either
6321 * moving activities to or from it), or simply resetting that task to
6322 * its initial state if needed.
6323 */
6324 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
6325 /**
6326 * This flag is not normally set by application code, but set for you by
6327 * the system if this activity is being launched from history
6328 * (longpress home key).
6329 */
6330 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
6331 /**
6332 * @deprecated As of API 21 this performs identically to
6333 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
6334 */
6335 @Deprecated
6336 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
6337 /**
6338 * This flag is used to open a document into a new task rooted at the activity launched
6339 * by this Intent. Through the use of this flag, or its equivalent attribute,
6340 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
6341 * containing different documents will appear in the recent tasks list.
6342 *
6343 * <p>The use of the activity attribute form of this,
6344 * {@link android.R.attr#documentLaunchMode}, is
6345 * preferred over the Intent flag described here. The attribute form allows the
6346 * Activity to specify multiple document behavior for all launchers of the Activity
6347 * whereas using this flag requires each Intent that launches the Activity to specify it.
6348 *
6349 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
6350 * it is kept after the activity is finished is different than the use of
6351 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
6352 * this flag is being used to create a new recents entry, then by default that entry
6353 * will be removed once the activity is finished. You can modify this behavior with
6354 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
6355 *
6356 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
6357 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
6358 * equivalent of the Activity manifest specifying {@link
6359 * android.R.attr#documentLaunchMode}="intoExisting". When used with
6360 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
6361 * {@link android.R.attr#documentLaunchMode}="always".
6362 *
6363 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
6364 *
6365 * @see android.R.attr#documentLaunchMode
6366 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
6367 */
6368 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
6369 /**
6370 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
6371 * callback from occurring on the current frontmost activity before it is
6372 * paused as the newly-started activity is brought to the front.
6373 *
6374 * <p>Typically, an activity can rely on that callback to indicate that an
6375 * explicit user action has caused their activity to be moved out of the
6376 * foreground. The callback marks an appropriate point in the activity's
6377 * lifecycle for it to dismiss any notifications that it intends to display
6378 * "until the user has seen them," such as a blinking LED.
6379 *
6380 * <p>If an activity is ever started via any non-user-driven events such as
6381 * phone-call receipt or an alarm handler, this flag should be passed to {@link
6382 * Context#startActivity Context.startActivity}, ensuring that the pausing
6383 * activity does not think the user has acknowledged its notification.
6384 */
6385 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
6386 /**
6387 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6388 * this flag will cause the launched activity to be brought to the front of its
6389 * task's history stack if it is already running.
6390 *
6391 * <p>For example, consider a task consisting of four activities: A, B, C, D.
6392 * If D calls startActivity() with an Intent that resolves to the component
6393 * of activity B, then B will be brought to the front of the history stack,
6394 * with this resulting order: A, C, D, B.
6395 *
6396 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
6397 * specified.
6398 */
6399 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
6400 /**
6401 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6402 * this flag will prevent the system from applying an activity transition
6403 * animation to go to the next activity state. This doesn't mean an
6404 * animation will never run -- if another activity change happens that doesn't
6405 * specify this flag before the activity started here is displayed, then
6406 * that transition will be used. This flag can be put to good use
6407 * when you are going to do a series of activity operations but the
6408 * animation seen by the user shouldn't be driven by the first activity
6409 * change but rather a later one.
6410 */
6411 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
6412 /**
6413 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6414 * this flag will cause any existing task that would be associated with the
6415 * activity to be cleared before the activity is started. That is, the activity
6416 * becomes the new root of an otherwise empty task, and any old activities
6417 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6418 */
6419 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
6420 /**
6421 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6422 * this flag will cause a newly launching task to be placed on top of the current
6423 * home activity task (if there is one). That is, pressing back from the task
6424 * will always return the user to home even if that was not the last activity they
6425 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6426 */
6427 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6428 /**
6429 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6430 * have its entry in recent tasks removed when the user closes it (with back
6431 * or however else it may finish()). If you would like to instead allow the
6432 * document to be kept in recents so that it can be re-launched, you can use
6433 * this flag. When set and the task's activity is finished, the recents
6434 * entry will remain in the interface for the user to re-launch it, like a
6435 * recents entry for a top-level application.
6436 * <p>
6437 * The receiving activity can override this request with
6438 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6439 * {@link android.app.Activity#finishAndRemoveTask()
6440 * Activity.finishAndRemoveTask()}.
6441 */
6442 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
6443
6444 /**
6445 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
6446 * adjacent to the one launching it. This can only be used in conjunction with
6447 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6448 * required if you want a new instance of an existing activity to be created.
6449 */
6450 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
6451
6452
6453 /**
6454 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6455 * this flag will attempt to launch an instant app if no full app on the device can already
6456 * handle the intent.
6457 * <p>
6458 * When attempting to resolve instant apps externally, the following {@link Intent} properties
6459 * are supported:
6460 * <ul>
6461 * <li>{@link Intent#setAction(String)}</li>
6462 * <li>{@link Intent#addCategory(String)}</li>
6463 * <li>{@link Intent#setData(Uri)}</li>
6464 * <li>{@link Intent#setType(String)}</li>
6465 * <li>{@link Intent#setPackage(String)}</li>
6466 * <li>{@link Intent#addFlags(int)}</li>
6467 * </ul>
6468 * <p>
6469 * In the case that no instant app can be found, the installer will be launched to notify the
6470 * user that the intent could not be resolved. On devices that do not support instant apps,
6471 * the flag will be ignored.
6472 */
6473 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
6474
6475 /**
6476 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
6477 * flag will only launch the intent if it resolves to a result that is not a browser. If no such
6478 * result exists, an {@link ActivityNotFoundException} will be thrown.
6479 */
6480 public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400;
6481
6482 /**
6483 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
6484 * flag will only launch the intent if it resolves to a single result. If no such result exists
6485 * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException}
6486 * will be thrown.
6487 */
6488 public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200;
6489
6490 /**
6491 * If set, when sending a broadcast only registered receivers will be
6492 * called -- no BroadcastReceiver components will be launched.
6493 */
6494 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
6495 /**
6496 * If set, when sending a broadcast the new broadcast will replace
6497 * any existing pending broadcast that matches it. Matching is defined
6498 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
6499 * true for the intents of the two broadcasts. When a match is found,
6500 * the new broadcast (and receivers associated with it) will replace the
6501 * existing one in the pending broadcast list, remaining at the same
6502 * position in the list.
6503 *
6504 * <p>This flag is most typically used with sticky broadcasts, which
6505 * only care about delivering the most recent values of the broadcast
6506 * to their receivers.
6507 */
6508 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
6509 /**
6510 * If set, when sending a broadcast the recipient is allowed to run at
6511 * foreground priority, with a shorter timeout interval. During normal
6512 * broadcasts the receivers are not automatically hoisted out of the
6513 * background priority class.
6514 */
6515 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
6516 /**
6517 * If set, when sending a broadcast the recipient will be run on the offload queue.
6518 *
6519 * @hide
6520 */
6521 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
6522 /**
6523 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
6524 * They can still propagate results through to later receivers, but they can not prevent
6525 * later receivers from seeing the broadcast.
6526 */
6527 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
6528 /**
6529 * If set, when sending a broadcast <i>before the system has fully booted up
6530 * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only
6531 * registered receivers will be called -- no BroadcastReceiver components
6532 * will be launched. Sticky intent state will be recorded properly even
6533 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
6534 * is specified in the broadcast intent, this flag is unnecessary.
6535 *
6536 * <p>This flag is only for use by system services (even services from mainline modules) as a
6537 * convenience to avoid having to implement a more complex mechanism around detection
6538 * of boot completion.
6539 *
6540 * <p>This is useful to system server mainline modules
6541 *
6542 * @hide
6543 */
6544 @SystemApi
6545 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
6546 /**
6547 * Set when this broadcast is for a boot upgrade, a special mode that
6548 * allows the broadcast to be sent before the system is ready and launches
6549 * the app process with no providers running in it.
6550 * @hide
6551 */
6552 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
6553 /**
6554 * If set, the broadcast will always go to manifest receivers in background (cached
6555 * or not running) apps, regardless of whether that would be done by default. By
6556 * default they will only receive broadcasts if the broadcast has specified an
6557 * explicit component or package name.
6558 *
6559 * NOTE: dumpstate uses this flag numerically, so when its value is changed
6560 * the broadcast code there must also be changed to match.
6561 *
6562 * @hide
6563 */
6564 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
6565 /**
6566 * If set, the broadcast will never go to manifest receivers in background (cached
6567 * or not running) apps, regardless of whether that would be done by default. By
6568 * default they will receive broadcasts if the broadcast has specified an
6569 * explicit component or package name.
6570 * @hide
6571 */
6572 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
6573 /**
6574 * If set, this broadcast is being sent from the shell.
6575 * @hide
6576 */
6577 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
6578
6579 /**
6580 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
6581 * will not receive broadcasts.
6582 *
6583 * <em>This flag has no effect when used by an Instant App.</em>
6584 */
6585 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
6586
6587 /**
6588 * @hide Flags that can't be changed with PendingIntent.
6589 */
6590 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
6591 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6592 | FLAG_GRANT_PREFIX_URI_PERMISSION;
6593
6594 // ---------------------------------------------------------------------
6595 // ---------------------------------------------------------------------
6596 // toUri() and parseUri() options.
6597
6598 /** @hide */
6599 @IntDef(flag = true, prefix = { "URI_" }, value = {
6600 URI_ALLOW_UNSAFE,
6601 URI_ANDROID_APP_SCHEME,
6602 URI_INTENT_SCHEME,
6603 })
6604 @Retention(RetentionPolicy.SOURCE)
6605 public @interface UriFlags {}
6606
6607 /**
6608 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6609 * always has the "intent:" scheme. This syntax can be used when you want
6610 * to later disambiguate between URIs that are intended to describe an
6611 * Intent vs. all others that should be treated as raw URIs. When used
6612 * with {@link #parseUri}, any other scheme will result in a generic
6613 * VIEW action for that raw URI.
6614 */
6615 public static final int URI_INTENT_SCHEME = 1<<0;
6616
6617 /**
6618 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6619 * always has the "android-app:" scheme. This is a variation of
6620 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
6621 * http/https URI being delivered to a specific package name. The format
6622 * is:
6623 *
6624 * <pre class="prettyprint">
6625 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
6626 *
6627 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
6628 * you must also include a scheme; including a path also requires both a host and a scheme.
6629 * The final #Intent; fragment can be used without a scheme, host, or path.
6630 * Note that this can not be
6631 * used with intents that have a {@link #setSelector}, since the base intent
6632 * will always have an explicit package name.</p>
6633 *
6634 * <p>Some examples of how this scheme maps to Intent objects:</p>
6635 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
6636 * <colgroup align="left" />
6637 * <colgroup align="left" />
6638 * <thead>
6639 * <tr><th>URI</th> <th>Intent</th></tr>
6640 * </thead>
6641 *
6642 * <tbody>
6643 * <tr><td><code>android-app://com.example.app</code></td>
6644 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6645 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
6646 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6647 * </table></td>
6648 * </tr>
6649 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
6650 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6651 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6652 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
6653 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6654 * </table></td>
6655 * </tr>
6656 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
6657 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6658 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6659 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6660 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6661 * </table></td>
6662 * </tr>
6663 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6664 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6665 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6666 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6667 * </table></td>
6668 * </tr>
6669 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6670 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6671 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6672 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6673 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6674 * </table></td>
6675 * </tr>
6676 * <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>
6677 * <td><table border="" style="margin:0" >
6678 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6679 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6680 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
6681 * </table></td>
6682 * </tr>
6683 * </tbody>
6684 * </table>
6685 */
6686 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6687
6688 /**
6689 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6690 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6691 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6692 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6693 * generated Intent can not cause unexpected data access to happen.
6694 *
6695 * <p>If you do not trust the source of the URI being parsed, you should still do further
6696 * processing to protect yourself from it. In particular, when using it to start an
6697 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6698 * that can handle it.</p>
6699 */
6700 public static final int URI_ALLOW_UNSAFE = 1<<2;
6701
6702 // ---------------------------------------------------------------------
6703
6704 private String mAction;
6705 private Uri mData;
6706 private String mType;
6707 private String mIdentifier;
6708 private String mPackage;
6709 private ComponentName mComponent;
6710 private int mFlags;
6711 private ArraySet<String> mCategories;
6712 @UnsupportedAppUsage
6713 private Bundle mExtras;
6714 private Rect mSourceBounds;
6715 private Intent mSelector;
6716 private ClipData mClipData;
6717 private int mContentUserHint = UserHandle.USER_CURRENT;
6718 /** Token to track instant app launches. Local only; do not copy cross-process. */
6719 private String mLaunchToken;
6720
6721 // ---------------------------------------------------------------------
6722
6723 private static final int COPY_MODE_ALL = 0;
6724 private static final int COPY_MODE_FILTER = 1;
6725 private static final int COPY_MODE_HISTORY = 2;
6726
6727 /** @hide */
6728 @IntDef(prefix = { "COPY_MODE_" }, value = {
6729 COPY_MODE_ALL,
6730 COPY_MODE_FILTER,
6731 COPY_MODE_HISTORY
6732 })
6733 @Retention(RetentionPolicy.SOURCE)
6734 public @interface CopyMode {}
6735
6736 /**
6737 * Create an empty intent.
6738 */
6739 public Intent() {
6740 }
6741
6742 /**
6743 * Copy constructor.
6744 */
6745 public Intent(Intent o) {
6746 this(o, COPY_MODE_ALL);
6747 }
6748
6749 private Intent(Intent o, @CopyMode int copyMode) {
6750 this.mAction = o.mAction;
6751 this.mData = o.mData;
6752 this.mType = o.mType;
6753 this.mIdentifier = o.mIdentifier;
6754 this.mPackage = o.mPackage;
6755 this.mComponent = o.mComponent;
6756
6757 if (o.mCategories != null) {
6758 this.mCategories = new ArraySet<>(o.mCategories);
6759 }
6760
6761 if (copyMode != COPY_MODE_FILTER) {
6762 this.mFlags = o.mFlags;
6763 this.mContentUserHint = o.mContentUserHint;
6764 this.mLaunchToken = o.mLaunchToken;
6765 if (o.mSourceBounds != null) {
6766 this.mSourceBounds = new Rect(o.mSourceBounds);
6767 }
6768 if (o.mSelector != null) {
6769 this.mSelector = new Intent(o.mSelector);
6770 }
6771
6772 if (copyMode != COPY_MODE_HISTORY) {
6773 if (o.mExtras != null) {
6774 this.mExtras = new Bundle(o.mExtras);
6775 }
6776 if (o.mClipData != null) {
6777 this.mClipData = new ClipData(o.mClipData);
6778 }
6779 } else {
6780 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) {
6781 this.mExtras = Bundle.STRIPPED;
6782 }
6783
6784 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6785 // history.
6786 }
6787 }
6788 }
6789
6790 @Override
6791 public Object clone() {
6792 return new Intent(this);
6793 }
6794
6795 /**
6796 * Make a clone of only the parts of the Intent that are relevant for
6797 * filter matching: the action, data, type, component, and categories.
6798 */
6799 public @NonNull Intent cloneFilter() {
6800 return new Intent(this, COPY_MODE_FILTER);
6801 }
6802
6803 /**
6804 * Create an intent with a given action. All other fields (data, type,
6805 * class) are null. Note that the action <em>must</em> be in a
6806 * namespace because Intents are used globally in the system -- for
6807 * example the system VIEW action is android.intent.action.VIEW; an
6808 * application's custom action would be something like
6809 * com.google.app.myapp.CUSTOM_ACTION.
6810 *
6811 * @param action The Intent action, such as ACTION_VIEW.
6812 */
6813 public Intent(String action) {
6814 setAction(action);
6815 }
6816
6817 /**
6818 * Create an intent with a given action and for a given data url. Note
6819 * that the action <em>must</em> be in a namespace because Intents are
6820 * used globally in the system -- for example the system VIEW action is
6821 * android.intent.action.VIEW; an application's custom action would be
6822 * something like com.google.app.myapp.CUSTOM_ACTION.
6823 *
6824 * <p><em>Note: scheme and host name matching in the Android framework is
6825 * case-sensitive, unlike the formal RFC. As a result,
6826 * you should always ensure that you write your Uri with these elements
6827 * using lower case letters, and normalize any Uris you receive from
6828 * outside of Android to ensure the scheme and host is lower case.</em></p>
6829 *
6830 * @param action The Intent action, such as ACTION_VIEW.
6831 * @param uri The Intent data URI.
6832 */
6833 public Intent(String action, Uri uri) {
6834 setAction(action);
6835 mData = uri;
6836 }
6837
6838 /**
6839 * Create an intent for a specific component. All other fields (action, data,
6840 * type, class) are null, though they can be modified later with explicit
6841 * calls. This provides a convenient way to create an intent that is
6842 * intended to execute a hard-coded class name, rather than relying on the
6843 * system to find an appropriate class for you; see {@link #setComponent}
6844 * for more information on the repercussions of this.
6845 *
6846 * @param packageContext A Context of the application package implementing
6847 * this class.
6848 * @param cls The component class that is to be used for the intent.
6849 *
6850 * @see #setClass
6851 * @see #setComponent
6852 * @see #Intent(String, android.net.Uri , Context, Class)
6853 */
6854 public Intent(Context packageContext, Class<?> cls) {
6855 mComponent = new ComponentName(packageContext, cls);
6856 }
6857
6858 /**
6859 * Create an intent for a specific component with a specified action and data.
6860 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
6861 * construct the Intent and then calling {@link #setClass} to set its
6862 * class.
6863 *
6864 * <p><em>Note: scheme and host name matching in the Android framework is
6865 * case-sensitive, unlike the formal RFC. As a result,
6866 * you should always ensure that you write your Uri with these elements
6867 * using lower case letters, and normalize any Uris you receive from
6868 * outside of Android to ensure the scheme and host is lower case.</em></p>
6869 *
6870 * @param action The Intent action, such as ACTION_VIEW.
6871 * @param uri The Intent data URI.
6872 * @param packageContext A Context of the application package implementing
6873 * this class.
6874 * @param cls The component class that is to be used for the intent.
6875 *
6876 * @see #Intent(String, android.net.Uri)
6877 * @see #Intent(Context, Class)
6878 * @see #setClass
6879 * @see #setComponent
6880 */
6881 public Intent(String action, Uri uri,
6882 Context packageContext, Class<?> cls) {
6883 setAction(action);
6884 mData = uri;
6885 mComponent = new ComponentName(packageContext, cls);
6886 }
6887
6888 /**
6889 * Create an intent to launch the main (root) activity of a task. This
6890 * is the Intent that is started when the application's is launched from
6891 * Home. For anything else that wants to launch an application in the
6892 * same way, it is important that they use an Intent structured the same
6893 * way, and can use this function to ensure this is the case.
6894 *
6895 * <p>The returned Intent has the given Activity component as its explicit
6896 * component, {@link #ACTION_MAIN} as its action, and includes the
6897 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6898 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6899 * to do that through {@link #addFlags(int)} on the returned Intent.
6900 *
6901 * @param mainActivity The main activity component that this Intent will
6902 * launch.
6903 * @return Returns a newly created Intent that can be used to launch the
6904 * activity as a main application entry.
6905 *
6906 * @see #setClass
6907 * @see #setComponent
6908 */
6909 public static Intent makeMainActivity(ComponentName mainActivity) {
6910 Intent intent = new Intent(ACTION_MAIN);
6911 intent.setComponent(mainActivity);
6912 intent.addCategory(CATEGORY_LAUNCHER);
6913 return intent;
6914 }
6915
6916 /**
6917 * Make an Intent for the main activity of an application, without
6918 * specifying a specific activity to run but giving a selector to find
6919 * the activity. This results in a final Intent that is structured
6920 * the same as when the application is launched from
6921 * Home. For anything else that wants to launch an application in the
6922 * same way, it is important that they use an Intent structured the same
6923 * way, and can use this function to ensure this is the case.
6924 *
6925 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6926 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6927 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6928 * to do that through {@link #addFlags(int)} on the returned Intent.
6929 *
6930 * @param selectorAction The action name of the Intent's selector.
6931 * @param selectorCategory The name of a category to add to the Intent's
6932 * selector.
6933 * @return Returns a newly created Intent that can be used to launch the
6934 * activity as a main application entry.
6935 *
6936 * @see #setSelector(Intent)
6937 */
6938 public static Intent makeMainSelectorActivity(String selectorAction,
6939 String selectorCategory) {
6940 Intent intent = new Intent(ACTION_MAIN);
6941 intent.addCategory(CATEGORY_LAUNCHER);
6942 Intent selector = new Intent();
6943 selector.setAction(selectorAction);
6944 selector.addCategory(selectorCategory);
6945 intent.setSelector(selector);
6946 return intent;
6947 }
6948
6949 /**
6950 * Make an Intent that can be used to re-launch an application's task
6951 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6952 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6953 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6954 *
6955 * @param mainActivity The activity component that is the root of the
6956 * task; this is the activity that has been published in the application's
6957 * manifest as the main launcher icon.
6958 *
6959 * @return Returns a newly created Intent that can be used to relaunch the
6960 * activity's task in its root state.
6961 */
6962 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6963 Intent intent = makeMainActivity(mainActivity);
6964 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6965 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6966 return intent;
6967 }
6968
6969 /**
6970 * Call {@link #parseUri} with 0 flags.
6971 * @deprecated Use {@link #parseUri} instead.
6972 */
6973 @Deprecated
6974 public static Intent getIntent(String uri) throws URISyntaxException {
6975 return parseUri(uri, 0);
6976 }
6977
6978 /**
6979 * Create an intent from a URI. This URI may encode the action,
6980 * category, and other intent fields, if it was returned by
6981 * {@link #toUri}. If the Intent was not generate by toUri(), its data
6982 * will be the entire URI and its action will be ACTION_VIEW.
6983 *
6984 * <p>The URI given here must not be relative -- that is, it must include
6985 * the scheme and full path.
6986 *
6987 * @param uri The URI to turn into an Intent.
6988 * @param flags Additional processing flags.
6989 *
6990 * @return Intent The newly created Intent object.
6991 *
6992 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6993 * it bad (as parsed by the Uri class) or the Intent data within the
6994 * URI is invalid.
6995 *
6996 * @see #toUri
6997 */
6998 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
6999 int i = 0;
7000 try {
7001 final boolean androidApp = uri.startsWith("android-app:");
7002
7003 // Validate intent scheme if requested.
7004 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
7005 if (!uri.startsWith("intent:") && !androidApp) {
7006 Intent intent = new Intent(ACTION_VIEW);
7007 try {
7008 intent.setData(Uri.parse(uri));
7009 } catch (IllegalArgumentException e) {
7010 throw new URISyntaxException(uri, e.getMessage());
7011 }
7012 return intent;
7013 }
7014 }
7015
7016 i = uri.lastIndexOf("#");
7017 // simple case
7018 if (i == -1) {
7019 if (!androidApp) {
7020 return new Intent(ACTION_VIEW, Uri.parse(uri));
7021 }
7022
7023 // old format Intent URI
7024 } else if (!uri.startsWith("#Intent;", i)) {
7025 if (!androidApp) {
7026 return getIntentOld(uri, flags);
7027 } else {
7028 i = -1;
7029 }
7030 }
7031
7032 // new format
7033 Intent intent = new Intent(ACTION_VIEW);
7034 Intent baseIntent = intent;
7035 boolean explicitAction = false;
7036 boolean inSelector = false;
7037
7038 // fetch data part, if present
7039 String scheme = null;
7040 String data;
7041 if (i >= 0) {
7042 data = uri.substring(0, i);
7043 i += 8; // length of "#Intent;"
7044 } else {
7045 data = uri;
7046 }
7047
7048 // loop over contents of Intent, all name=value;
7049 while (i >= 0 && !uri.startsWith("end", i)) {
7050 int eq = uri.indexOf('=', i);
7051 if (eq < 0) eq = i-1;
7052 int semi = uri.indexOf(';', i);
7053 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
7054
7055 // action
7056 if (uri.startsWith("action=", i)) {
7057 intent.setAction(value);
7058 if (!inSelector) {
7059 explicitAction = true;
7060 }
7061 }
7062
7063 // categories
7064 else if (uri.startsWith("category=", i)) {
7065 intent.addCategory(value);
7066 }
7067
7068 // type
7069 else if (uri.startsWith("type=", i)) {
7070 intent.mType = value;
7071 }
7072
7073 // identifier
7074 else if (uri.startsWith("identifier=", i)) {
7075 intent.mIdentifier = value;
7076 }
7077
7078 // launch flags
7079 else if (uri.startsWith("launchFlags=", i)) {
7080 intent.mFlags = Integer.decode(value).intValue();
7081 if ((flags& URI_ALLOW_UNSAFE) == 0) {
7082 intent.mFlags &= ~IMMUTABLE_FLAGS;
7083 }
7084 }
7085
7086 // package
7087 else if (uri.startsWith("package=", i)) {
7088 intent.mPackage = value;
7089 }
7090
7091 // component
7092 else if (uri.startsWith("component=", i)) {
7093 intent.mComponent = ComponentName.unflattenFromString(value);
7094 }
7095
7096 // scheme
7097 else if (uri.startsWith("scheme=", i)) {
7098 if (inSelector) {
7099 intent.mData = Uri.parse(value + ":");
7100 } else {
7101 scheme = value;
7102 }
7103 }
7104
7105 // source bounds
7106 else if (uri.startsWith("sourceBounds=", i)) {
7107 intent.mSourceBounds = Rect.unflattenFromString(value);
7108 }
7109
7110 // selector
7111 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
7112 intent = new Intent();
7113 inSelector = true;
7114 }
7115
7116 // extra
7117 else {
7118 String key = Uri.decode(uri.substring(i + 2, eq));
7119 // create Bundle if it doesn't already exist
7120 if (intent.mExtras == null) intent.mExtras = new Bundle();
7121 Bundle b = intent.mExtras;
7122 // add EXTRA
7123 if (uri.startsWith("S.", i)) b.putString(key, value);
7124 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
7125 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
7126 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
7127 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
7128 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
7129 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
7130 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
7131 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
7132 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
7133 }
7134
7135 // move to the next item
7136 i = semi + 1;
7137 }
7138
7139 if (inSelector) {
7140 // The Intent had a selector; fix it up.
7141 if (baseIntent.mPackage == null) {
7142 baseIntent.setSelector(intent);
7143 }
7144 intent = baseIntent;
7145 }
7146
7147 if (data != null) {
7148 if (data.startsWith("intent:")) {
7149 data = data.substring(7);
7150 if (scheme != null) {
7151 data = scheme + ':' + data;
7152 }
7153 } else if (data.startsWith("android-app:")) {
7154 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
7155 // Correctly formed android-app, first part is package name.
7156 int end = data.indexOf('/', 14);
7157 if (end < 0) {
7158 // All we have is a package name.
7159 intent.mPackage = data.substring(14);
7160 if (!explicitAction) {
7161 intent.setAction(ACTION_MAIN);
7162 }
7163 data = "";
7164 } else {
7165 // Target the Intent at the given package name always.
7166 String authority = null;
7167 intent.mPackage = data.substring(14, end);
7168 int newEnd;
7169 if ((end+1) < data.length()) {
7170 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
7171 // Found a scheme, remember it.
7172 scheme = data.substring(end+1, newEnd);
7173 end = newEnd;
7174 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
7175 // Found a authority, remember it.
7176 authority = data.substring(end+1, newEnd);
7177 end = newEnd;
7178 }
7179 } else {
7180 // All we have is a scheme.
7181 scheme = data.substring(end+1);
7182 }
7183 }
7184 if (scheme == null) {
7185 // If there was no scheme, then this just targets the package.
7186 if (!explicitAction) {
7187 intent.setAction(ACTION_MAIN);
7188 }
7189 data = "";
7190 } else if (authority == null) {
7191 data = scheme + ":";
7192 } else {
7193 data = scheme + "://" + authority + data.substring(end);
7194 }
7195 }
7196 } else {
7197 data = "";
7198 }
7199 }
7200
7201 if (data.length() > 0) {
7202 try {
7203 intent.mData = Uri.parse(data);
7204 } catch (IllegalArgumentException e) {
7205 throw new URISyntaxException(uri, e.getMessage());
7206 }
7207 }
7208 }
7209
7210 return intent;
7211
7212 } catch (IndexOutOfBoundsException e) {
7213 throw new URISyntaxException(uri, "illegal Intent URI format", i);
7214 }
7215 }
7216
7217 public static Intent getIntentOld(String uri) throws URISyntaxException {
7218 return getIntentOld(uri, 0);
7219 }
7220
7221 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
7222 Intent intent;
7223
7224 int i = uri.lastIndexOf('#');
7225 if (i >= 0) {
7226 String action = null;
7227 final int intentFragmentStart = i;
7228 boolean isIntentFragment = false;
7229
7230 i++;
7231
7232 if (uri.regionMatches(i, "action(", 0, 7)) {
7233 isIntentFragment = true;
7234 i += 7;
7235 int j = uri.indexOf(')', i);
7236 action = uri.substring(i, j);
7237 i = j + 1;
7238 }
7239
7240 intent = new Intent(action);
7241
7242 if (uri.regionMatches(i, "categories(", 0, 11)) {
7243 isIntentFragment = true;
7244 i += 11;
7245 int j = uri.indexOf(')', i);
7246 while (i < j) {
7247 int sep = uri.indexOf('!', i);
7248 if (sep < 0 || sep > j) sep = j;
7249 if (i < sep) {
7250 intent.addCategory(uri.substring(i, sep));
7251 }
7252 i = sep + 1;
7253 }
7254 i = j + 1;
7255 }
7256
7257 if (uri.regionMatches(i, "type(", 0, 5)) {
7258 isIntentFragment = true;
7259 i += 5;
7260 int j = uri.indexOf(')', i);
7261 intent.mType = uri.substring(i, j);
7262 i = j + 1;
7263 }
7264
7265 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
7266 isIntentFragment = true;
7267 i += 12;
7268 int j = uri.indexOf(')', i);
7269 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
7270 if ((flags& URI_ALLOW_UNSAFE) == 0) {
7271 intent.mFlags &= ~IMMUTABLE_FLAGS;
7272 }
7273 i = j + 1;
7274 }
7275
7276 if (uri.regionMatches(i, "component(", 0, 10)) {
7277 isIntentFragment = true;
7278 i += 10;
7279 int j = uri.indexOf(')', i);
7280 int sep = uri.indexOf('!', i);
7281 if (sep >= 0 && sep < j) {
7282 String pkg = uri.substring(i, sep);
7283 String cls = uri.substring(sep + 1, j);
7284 intent.mComponent = new ComponentName(pkg, cls);
7285 }
7286 i = j + 1;
7287 }
7288
7289 if (uri.regionMatches(i, "extras(", 0, 7)) {
7290 isIntentFragment = true;
7291 i += 7;
7292
7293 final int closeParen = uri.indexOf(')', i);
7294 if (closeParen == -1) throw new URISyntaxException(uri,
7295 "EXTRA missing trailing ')'", i);
7296
7297 while (i < closeParen) {
7298 // fetch the key value
7299 int j = uri.indexOf('=', i);
7300 if (j <= i + 1 || i >= closeParen) {
7301 throw new URISyntaxException(uri, "EXTRA missing '='", i);
7302 }
7303 char type = uri.charAt(i);
7304 i++;
7305 String key = uri.substring(i, j);
7306 i = j + 1;
7307
7308 // get type-value
7309 j = uri.indexOf('!', i);
7310 if (j == -1 || j >= closeParen) j = closeParen;
7311 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7312 String value = uri.substring(i, j);
7313 i = j;
7314
7315 // create Bundle if it doesn't already exist
7316 if (intent.mExtras == null) intent.mExtras = new Bundle();
7317
7318 // add item to bundle
7319 try {
7320 switch (type) {
7321 case 'S':
7322 intent.mExtras.putString(key, Uri.decode(value));
7323 break;
7324 case 'B':
7325 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
7326 break;
7327 case 'b':
7328 intent.mExtras.putByte(key, Byte.parseByte(value));
7329 break;
7330 case 'c':
7331 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
7332 break;
7333 case 'd':
7334 intent.mExtras.putDouble(key, Double.parseDouble(value));
7335 break;
7336 case 'f':
7337 intent.mExtras.putFloat(key, Float.parseFloat(value));
7338 break;
7339 case 'i':
7340 intent.mExtras.putInt(key, Integer.parseInt(value));
7341 break;
7342 case 'l':
7343 intent.mExtras.putLong(key, Long.parseLong(value));
7344 break;
7345 case 's':
7346 intent.mExtras.putShort(key, Short.parseShort(value));
7347 break;
7348 default:
7349 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
7350 }
7351 } catch (NumberFormatException e) {
7352 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
7353 }
7354
7355 char ch = uri.charAt(i);
7356 if (ch == ')') break;
7357 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7358 i++;
7359 }
7360 }
7361
7362 if (isIntentFragment) {
7363 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
7364 } else {
7365 intent.mData = Uri.parse(uri);
7366 }
7367
7368 if (intent.mAction == null) {
7369 // By default, if no action is specified, then use VIEW.
7370 intent.mAction = ACTION_VIEW;
7371 }
7372
7373 } else {
7374 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
7375 }
7376
7377 return intent;
7378 }
7379
7380 /** @hide */
7381 public interface CommandOptionHandler {
7382 boolean handleOption(String opt, ShellCommand cmd);
7383 }
7384
7385 /** @hide */
7386 @UnsupportedAppUsage
7387 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
7388 throws URISyntaxException {
7389 Intent intent = new Intent();
7390 Intent baseIntent = intent;
7391 boolean hasIntentInfo = false;
7392
7393 Uri data = null;
7394 String type = null;
7395
7396 String opt;
7397 while ((opt=cmd.getNextOption()) != null) {
7398 switch (opt) {
7399 case "-a":
7400 intent.setAction(cmd.getNextArgRequired());
7401 if (intent == baseIntent) {
7402 hasIntentInfo = true;
7403 }
7404 break;
7405 case "-d":
7406 data = Uri.parse(cmd.getNextArgRequired());
7407 if (intent == baseIntent) {
7408 hasIntentInfo = true;
7409 }
7410 break;
7411 case "-t":
7412 type = cmd.getNextArgRequired();
7413 if (intent == baseIntent) {
7414 hasIntentInfo = true;
7415 }
7416 break;
7417 case "-i":
7418 intent.setIdentifier(cmd.getNextArgRequired());
7419 if (intent == baseIntent) {
7420 hasIntentInfo = true;
7421 }
7422 break;
7423 case "-c":
7424 intent.addCategory(cmd.getNextArgRequired());
7425 if (intent == baseIntent) {
7426 hasIntentInfo = true;
7427 }
7428 break;
7429 case "-e":
7430 case "--es": {
7431 String key = cmd.getNextArgRequired();
7432 String value = cmd.getNextArgRequired();
7433 intent.putExtra(key, value);
7434 }
7435 break;
7436 case "--esn": {
7437 String key = cmd.getNextArgRequired();
7438 intent.putExtra(key, (String) null);
7439 }
7440 break;
7441 case "--ei": {
7442 String key = cmd.getNextArgRequired();
7443 String value = cmd.getNextArgRequired();
7444 intent.putExtra(key, Integer.decode(value));
7445 }
7446 break;
7447 case "--eu": {
7448 String key = cmd.getNextArgRequired();
7449 String value = cmd.getNextArgRequired();
7450 intent.putExtra(key, Uri.parse(value));
7451 }
7452 break;
7453 case "--ecn": {
7454 String key = cmd.getNextArgRequired();
7455 String value = cmd.getNextArgRequired();
7456 ComponentName cn = ComponentName.unflattenFromString(value);
7457 if (cn == null)
7458 throw new IllegalArgumentException("Bad component name: " + value);
7459 intent.putExtra(key, cn);
7460 }
7461 break;
7462 case "--eia": {
7463 String key = cmd.getNextArgRequired();
7464 String value = cmd.getNextArgRequired();
7465 String[] strings = value.split(",");
7466 int[] list = new int[strings.length];
7467 for (int i = 0; i < strings.length; i++) {
7468 list[i] = Integer.decode(strings[i]);
7469 }
7470 intent.putExtra(key, list);
7471 }
7472 break;
7473 case "--eial": {
7474 String key = cmd.getNextArgRequired();
7475 String value = cmd.getNextArgRequired();
7476 String[] strings = value.split(",");
7477 ArrayList<Integer> list = new ArrayList<>(strings.length);
7478 for (int i = 0; i < strings.length; i++) {
7479 list.add(Integer.decode(strings[i]));
7480 }
7481 intent.putExtra(key, list);
7482 }
7483 break;
7484 case "--el": {
7485 String key = cmd.getNextArgRequired();
7486 String value = cmd.getNextArgRequired();
7487 intent.putExtra(key, Long.valueOf(value));
7488 }
7489 break;
7490 case "--ela": {
7491 String key = cmd.getNextArgRequired();
7492 String value = cmd.getNextArgRequired();
7493 String[] strings = value.split(",");
7494 long[] list = new long[strings.length];
7495 for (int i = 0; i < strings.length; i++) {
7496 list[i] = Long.valueOf(strings[i]);
7497 }
7498 intent.putExtra(key, list);
7499 hasIntentInfo = true;
7500 }
7501 break;
7502 case "--elal": {
7503 String key = cmd.getNextArgRequired();
7504 String value = cmd.getNextArgRequired();
7505 String[] strings = value.split(",");
7506 ArrayList<Long> list = new ArrayList<>(strings.length);
7507 for (int i = 0; i < strings.length; i++) {
7508 list.add(Long.valueOf(strings[i]));
7509 }
7510 intent.putExtra(key, list);
7511 hasIntentInfo = true;
7512 }
7513 break;
7514 case "--ef": {
7515 String key = cmd.getNextArgRequired();
7516 String value = cmd.getNextArgRequired();
7517 intent.putExtra(key, Float.valueOf(value));
7518 hasIntentInfo = true;
7519 }
7520 break;
7521 case "--efa": {
7522 String key = cmd.getNextArgRequired();
7523 String value = cmd.getNextArgRequired();
7524 String[] strings = value.split(",");
7525 float[] list = new float[strings.length];
7526 for (int i = 0; i < strings.length; i++) {
7527 list[i] = Float.valueOf(strings[i]);
7528 }
7529 intent.putExtra(key, list);
7530 hasIntentInfo = true;
7531 }
7532 break;
7533 case "--efal": {
7534 String key = cmd.getNextArgRequired();
7535 String value = cmd.getNextArgRequired();
7536 String[] strings = value.split(",");
7537 ArrayList<Float> list = new ArrayList<>(strings.length);
7538 for (int i = 0; i < strings.length; i++) {
7539 list.add(Float.valueOf(strings[i]));
7540 }
7541 intent.putExtra(key, list);
7542 hasIntentInfo = true;
7543 }
7544 break;
7545 case "--esa": {
7546 String key = cmd.getNextArgRequired();
7547 String value = cmd.getNextArgRequired();
7548 // Split on commas unless they are preceeded by an escape.
7549 // The escape character must be escaped for the string and
7550 // again for the regex, thus four escape characters become one.
7551 String[] strings = value.split("(?<!\\\\),");
7552 intent.putExtra(key, strings);
7553 hasIntentInfo = true;
7554 }
7555 break;
7556 case "--esal": {
7557 String key = cmd.getNextArgRequired();
7558 String value = cmd.getNextArgRequired();
7559 // Split on commas unless they are preceeded by an escape.
7560 // The escape character must be escaped for the string and
7561 // again for the regex, thus four escape characters become one.
7562 String[] strings = value.split("(?<!\\\\),");
7563 ArrayList<String> list = new ArrayList<>(strings.length);
7564 for (int i = 0; i < strings.length; i++) {
7565 list.add(strings[i]);
7566 }
7567 intent.putExtra(key, list);
7568 hasIntentInfo = true;
7569 }
7570 break;
7571 case "--ez": {
7572 String key = cmd.getNextArgRequired();
7573 String value = cmd.getNextArgRequired().toLowerCase();
7574 // Boolean.valueOf() results in false for anything that is not "true", which is
7575 // error-prone in shell commands
7576 boolean arg;
7577 if ("true".equals(value) || "t".equals(value)) {
7578 arg = true;
7579 } else if ("false".equals(value) || "f".equals(value)) {
7580 arg = false;
7581 } else {
7582 try {
7583 arg = Integer.decode(value) != 0;
7584 } catch (NumberFormatException ex) {
7585 throw new IllegalArgumentException("Invalid boolean value: " + value);
7586 }
7587 }
7588
7589 intent.putExtra(key, arg);
7590 }
7591 break;
7592 case "-n": {
7593 String str = cmd.getNextArgRequired();
7594 ComponentName cn = ComponentName.unflattenFromString(str);
7595 if (cn == null)
7596 throw new IllegalArgumentException("Bad component name: " + str);
7597 intent.setComponent(cn);
7598 if (intent == baseIntent) {
7599 hasIntentInfo = true;
7600 }
7601 }
7602 break;
7603 case "-p": {
7604 String str = cmd.getNextArgRequired();
7605 intent.setPackage(str);
7606 if (intent == baseIntent) {
7607 hasIntentInfo = true;
7608 }
7609 }
7610 break;
7611 case "-f":
7612 String str = cmd.getNextArgRequired();
7613 intent.setFlags(Integer.decode(str).intValue());
7614 break;
7615 case "--grant-read-uri-permission":
7616 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
7617 break;
7618 case "--grant-write-uri-permission":
7619 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
7620 break;
7621 case "--grant-persistable-uri-permission":
7622 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
7623 break;
7624 case "--grant-prefix-uri-permission":
7625 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
7626 break;
7627 case "--exclude-stopped-packages":
7628 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
7629 break;
7630 case "--include-stopped-packages":
7631 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
7632 break;
7633 case "--debug-log-resolution":
7634 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
7635 break;
7636 case "--activity-brought-to-front":
7637 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
7638 break;
7639 case "--activity-clear-top":
7640 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
7641 break;
7642 case "--activity-clear-when-task-reset":
7643 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
7644 break;
7645 case "--activity-exclude-from-recents":
7646 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
7647 break;
7648 case "--activity-launched-from-history":
7649 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
7650 break;
7651 case "--activity-multiple-task":
7652 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
7653 break;
7654 case "--activity-no-animation":
7655 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
7656 break;
7657 case "--activity-no-history":
7658 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
7659 break;
7660 case "--activity-no-user-action":
7661 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
7662 break;
7663 case "--activity-previous-is-top":
7664 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
7665 break;
7666 case "--activity-reorder-to-front":
7667 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
7668 break;
7669 case "--activity-reset-task-if-needed":
7670 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
7671 break;
7672 case "--activity-single-top":
7673 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
7674 break;
7675 case "--activity-clear-task":
7676 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
7677 break;
7678 case "--activity-task-on-home":
7679 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
7680 break;
7681 case "--activity-match-external":
7682 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
7683 break;
7684 case "--receiver-registered-only":
7685 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
7686 break;
7687 case "--receiver-replace-pending":
7688 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
7689 break;
7690 case "--receiver-foreground":
7691 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
7692 break;
7693 case "--receiver-no-abort":
7694 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
7695 break;
7696 case "--receiver-include-background":
7697 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7698 break;
7699 case "--selector":
7700 intent.setDataAndType(data, type);
7701 intent = new Intent();
7702 break;
7703 default:
7704 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7705 // Okay, caller handled this option.
7706 } else {
7707 throw new IllegalArgumentException("Unknown option: " + opt);
7708 }
7709 break;
7710 }
7711 }
7712 intent.setDataAndType(data, type);
7713
7714 final boolean hasSelector = intent != baseIntent;
7715 if (hasSelector) {
7716 // A selector was specified; fix up.
7717 baseIntent.setSelector(intent);
7718 intent = baseIntent;
7719 }
7720
7721 String arg = cmd.getNextArg();
7722 baseIntent = null;
7723 if (arg == null) {
7724 if (hasSelector) {
7725 // If a selector has been specified, and no arguments
7726 // have been supplied for the main Intent, then we can
7727 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7728 // need to have a component name specified yet, the
7729 // selector will take care of that.
7730 baseIntent = new Intent(Intent.ACTION_MAIN);
7731 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7732 }
7733 } else if (arg.indexOf(':') >= 0) {
7734 // The argument is a URI. Fully parse it, and use that result
7735 // to fill in any data not specified so far.
7736 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7737 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7738 } else if (arg.indexOf('/') >= 0) {
7739 // The argument is a component name. Build an Intent to launch
7740 // it.
7741 baseIntent = new Intent(Intent.ACTION_MAIN);
7742 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7743 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
7744 } else {
7745 // Assume the argument is a package name.
7746 baseIntent = new Intent(Intent.ACTION_MAIN);
7747 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7748 baseIntent.setPackage(arg);
7749 }
7750 if (baseIntent != null) {
7751 Bundle extras = intent.getExtras();
7752 intent.replaceExtras((Bundle)null);
7753 Bundle uriExtras = baseIntent.getExtras();
7754 baseIntent.replaceExtras((Bundle)null);
7755 if (intent.getAction() != null && baseIntent.getCategories() != null) {
7756 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7757 for (String c : cats) {
7758 baseIntent.removeCategory(c);
7759 }
7760 }
7761 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7762 if (extras == null) {
7763 extras = uriExtras;
7764 } else if (uriExtras != null) {
7765 uriExtras.putAll(extras);
7766 extras = uriExtras;
7767 }
7768 intent.replaceExtras(extras);
7769 hasIntentInfo = true;
7770 }
7771
7772 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7773 return intent;
7774 }
7775
7776 /** @hide */
7777 @UnsupportedAppUsage
7778 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7779 final String[] lines = new String[] {
7780 "<INTENT> specifications include these flags and arguments:",
7781 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]",
7782 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
7783 " [-n <COMPONENT_NAME>]",
7784 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7785 " [--esn <EXTRA_KEY> ...]",
7786 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7787 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7788 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7789 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7790 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7791 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7792 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7793 " (mutiple extras passed as Integer[])",
7794 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7795 " (mutiple extras passed as List<Integer>)",
7796 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7797 " (mutiple extras passed as Long[])",
7798 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7799 " (mutiple extras passed as List<Long>)",
7800 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7801 " (mutiple extras passed as Float[])",
7802 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7803 " (mutiple extras passed as List<Float>)",
7804 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7805 " (mutiple extras passed as String[]; to embed a comma into a string,",
7806 " escape it using \"\\,\")",
7807 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7808 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7809 " escape it using \"\\,\")",
7810 " [-f <FLAG>]",
7811 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7812 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7813 " [--debug-log-resolution] [--exclude-stopped-packages]",
7814 " [--include-stopped-packages]",
7815 " [--activity-brought-to-front] [--activity-clear-top]",
7816 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7817 " [--activity-launched-from-history] [--activity-multiple-task]",
7818 " [--activity-no-animation] [--activity-no-history]",
7819 " [--activity-no-user-action] [--activity-previous-is-top]",
7820 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7821 " [--activity-single-top] [--activity-clear-task]",
7822 " [--activity-task-on-home] [--activity-match-external]",
7823 " [--receiver-registered-only] [--receiver-replace-pending]",
7824 " [--receiver-foreground] [--receiver-no-abort]",
7825 " [--receiver-include-background]",
7826 " [--selector]",
7827 " [<URI> | <PACKAGE> | <COMPONENT>]"
7828 };
7829 for (String line : lines) {
7830 pw.print(prefix);
7831 pw.println(line);
7832 }
7833 }
7834
7835 /**
7836 * Retrieve the general action to be performed, such as
7837 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7838 * the information in the intent should be interpreted -- most importantly,
7839 * what to do with the data returned by {@link #getData}.
7840 *
7841 * @return The action of this intent or null if none is specified.
7842 *
7843 * @see #setAction
7844 */
7845 public @Nullable String getAction() {
7846 return mAction;
7847 }
7848
7849 /**
7850 * Retrieve data this intent is operating on. This URI specifies the name
7851 * of the data; often it uses the content: scheme, specifying data in a
7852 * content provider. Other schemes may be handled by specific activities,
7853 * such as http: by the web browser.
7854 *
7855 * @return The URI of the data this intent is targeting or null.
7856 *
7857 * @see #getScheme
7858 * @see #setData
7859 */
7860 public @Nullable Uri getData() {
7861 return mData;
7862 }
7863
7864 /**
7865 * The same as {@link #getData()}, but returns the URI as an encoded
7866 * String.
7867 */
7868 public @Nullable String getDataString() {
7869 return mData != null ? mData.toString() : null;
7870 }
7871
7872 /**
7873 * Return the scheme portion of the intent's data. If the data is null or
7874 * does not include a scheme, null is returned. Otherwise, the scheme
7875 * prefix without the final ':' is returned, i.e. "http".
7876 *
7877 * <p>This is the same as calling getData().getScheme() (and checking for
7878 * null data).
7879 *
7880 * @return The scheme of this intent.
7881 *
7882 * @see #getData
7883 */
7884 public @Nullable String getScheme() {
7885 return mData != null ? mData.getScheme() : null;
7886 }
7887
7888 /**
7889 * Retrieve any explicit MIME type included in the intent. This is usually
7890 * null, as the type is determined by the intent data.
7891 *
7892 * @return If a type was manually set, it is returned; else null is
7893 * returned.
7894 *
7895 * @see #resolveType(ContentResolver)
7896 * @see #setType
7897 */
7898 public @Nullable String getType() {
7899 return mType;
7900 }
7901
7902 /**
7903 * Return the MIME data type of this intent. If the type field is
7904 * explicitly set, that is simply returned. Otherwise, if the data is set,
7905 * the type of that data is returned. If neither fields are set, a null is
7906 * returned.
7907 *
7908 * @return The MIME type of this intent.
7909 *
7910 * @see #getType
7911 * @see #resolveType(ContentResolver)
7912 */
7913 public @Nullable String resolveType(@NonNull Context context) {
7914 return resolveType(context.getContentResolver());
7915 }
7916
7917 /**
7918 * Return the MIME data type of this intent. If the type field is
7919 * explicitly set, that is simply returned. Otherwise, if the data is set,
7920 * the type of that data is returned. If neither fields are set, a null is
7921 * returned.
7922 *
7923 * @param resolver A ContentResolver that can be used to determine the MIME
7924 * type of the intent's data.
7925 *
7926 * @return The MIME type of this intent.
7927 *
7928 * @see #getType
7929 * @see #resolveType(Context)
7930 */
7931 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
7932 if (mType != null) {
7933 return mType;
7934 }
7935 if (mData != null) {
7936 if ("content".equals(mData.getScheme())) {
7937 return resolver.getType(mData);
7938 }
7939 }
7940 return null;
7941 }
7942
7943 /**
7944 * Return the MIME data type of this intent, only if it will be needed for
7945 * intent resolution. This is not generally useful for application code;
7946 * it is used by the frameworks for communicating with back-end system
7947 * services.
7948 *
7949 * @param resolver A ContentResolver that can be used to determine the MIME
7950 * type of the intent's data.
7951 *
7952 * @return The MIME type of this intent, or null if it is unknown or not
7953 * needed.
7954 */
7955 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
7956 if (mComponent != null) {
7957 return mType;
7958 }
7959 return resolveType(resolver);
7960 }
7961
7962 /**
7963 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity
7964 * of the Intent to distinguish it from other Intents.
7965 *
7966 * @return The identifier of this intent or null if none is specified.
7967 *
7968 * @see #setIdentifier
7969 */
7970 public @Nullable String getIdentifier() {
7971 return mIdentifier;
7972 }
7973
7974 /**
7975 * Check if a category exists in the intent.
7976 *
7977 * @param category The category to check.
7978 *
7979 * @return boolean True if the intent contains the category, else false.
7980 *
7981 * @see #getCategories
7982 * @see #addCategory
7983 */
7984 public boolean hasCategory(String category) {
7985 return mCategories != null && mCategories.contains(category);
7986 }
7987
7988 /**
7989 * Return the set of all categories in the intent. If there are no categories,
7990 * returns NULL.
7991 *
7992 * @return The set of categories you can examine. Do not modify!
7993 *
7994 * @see #hasCategory
7995 * @see #addCategory
7996 */
7997 public Set<String> getCategories() {
7998 return mCategories;
7999 }
8000
8001 /**
8002 * Return the specific selector associated with this Intent. If there is
8003 * none, returns null. See {@link #setSelector} for more information.
8004 *
8005 * @see #setSelector
8006 */
8007 public @Nullable Intent getSelector() {
8008 return mSelector;
8009 }
8010
8011 /**
8012 * Return the {@link ClipData} associated with this Intent. If there is
8013 * none, returns null. See {@link #setClipData} for more information.
8014 *
8015 * @see #setClipData
8016 */
8017 public @Nullable ClipData getClipData() {
8018 return mClipData;
8019 }
8020
8021 /** @hide */
8022 public int getContentUserHint() {
8023 return mContentUserHint;
8024 }
8025
8026 /** @hide */
8027 public String getLaunchToken() {
8028 return mLaunchToken;
8029 }
8030
8031 /** @hide */
8032 public void setLaunchToken(String launchToken) {
8033 mLaunchToken = launchToken;
8034 }
8035
8036 /**
8037 * Sets the ClassLoader that will be used when unmarshalling
8038 * any Parcelable values from the extras of this Intent.
8039 *
8040 * @param loader a ClassLoader, or null to use the default loader
8041 * at the time of unmarshalling.
8042 */
8043 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
8044 if (mExtras != null) {
8045 mExtras.setClassLoader(loader);
8046 }
8047 }
8048
8049 /**
8050 * Returns true if an extra value is associated with the given name.
8051 * @param name the extra's name
8052 * @return true if the given extra is present.
8053 */
8054 public boolean hasExtra(String name) {
8055 return mExtras != null && mExtras.containsKey(name);
8056 }
8057
8058 /**
8059 * Returns true if the Intent's extras contain a parcelled file descriptor.
8060 * @return true if the Intent contains a parcelled file descriptor.
8061 */
8062 public boolean hasFileDescriptors() {
8063 return mExtras != null && mExtras.hasFileDescriptors();
8064 }
8065
8066 /** {@hide} */
8067 @UnsupportedAppUsage
8068 public void setAllowFds(boolean allowFds) {
8069 if (mExtras != null) {
8070 mExtras.setAllowFds(allowFds);
8071 }
8072 }
8073
8074 /** {@hide} */
8075 public void setDefusable(boolean defusable) {
8076 if (mExtras != null) {
8077 mExtras.setDefusable(defusable);
8078 }
8079 }
8080
8081 /**
8082 * Retrieve extended data from the intent.
8083 *
8084 * @param name The name of the desired item.
8085 *
8086 * @return the value of an item previously added with putExtra(),
8087 * or null if none was found.
8088 *
8089 * @deprecated
8090 * @hide
8091 */
8092 @Deprecated
8093 @UnsupportedAppUsage
8094 public Object getExtra(String name) {
8095 return getExtra(name, null);
8096 }
8097
8098 /**
8099 * Retrieve extended data from the intent.
8100 *
8101 * @param name The name of the desired item.
8102 * @param defaultValue the value to be returned if no value of the desired
8103 * type is stored with the given name.
8104 *
8105 * @return the value of an item previously added with putExtra(),
8106 * or the default value if none was found.
8107 *
8108 * @see #putExtra(String, boolean)
8109 */
8110 public boolean getBooleanExtra(String name, boolean defaultValue) {
8111 return mExtras == null ? defaultValue :
8112 mExtras.getBoolean(name, defaultValue);
8113 }
8114
8115 /**
8116 * Retrieve extended data from the intent.
8117 *
8118 * @param name The name of the desired item.
8119 * @param defaultValue the value to be returned if no value of the desired
8120 * type is stored with the given name.
8121 *
8122 * @return the value of an item previously added with putExtra(),
8123 * or the default value if none was found.
8124 *
8125 * @see #putExtra(String, byte)
8126 */
8127 public byte getByteExtra(String name, byte defaultValue) {
8128 return mExtras == null ? defaultValue :
8129 mExtras.getByte(name, defaultValue);
8130 }
8131
8132 /**
8133 * Retrieve extended data from the intent.
8134 *
8135 * @param name The name of the desired item.
8136 * @param defaultValue the value to be returned if no value of the desired
8137 * type is stored with the given name.
8138 *
8139 * @return the value of an item previously added with putExtra(),
8140 * or the default value if none was found.
8141 *
8142 * @see #putExtra(String, short)
8143 */
8144 public short getShortExtra(String name, short defaultValue) {
8145 return mExtras == null ? defaultValue :
8146 mExtras.getShort(name, defaultValue);
8147 }
8148
8149 /**
8150 * Retrieve extended data from the intent.
8151 *
8152 * @param name The name of the desired item.
8153 * @param defaultValue the value to be returned if no value of the desired
8154 * type is stored with the given name.
8155 *
8156 * @return the value of an item previously added with putExtra(),
8157 * or the default value if none was found.
8158 *
8159 * @see #putExtra(String, char)
8160 */
8161 public char getCharExtra(String name, char defaultValue) {
8162 return mExtras == null ? defaultValue :
8163 mExtras.getChar(name, defaultValue);
8164 }
8165
8166 /**
8167 * Retrieve extended data from the intent.
8168 *
8169 * @param name The name of the desired item.
8170 * @param defaultValue the value to be returned if no value of the desired
8171 * type is stored with the given name.
8172 *
8173 * @return the value of an item previously added with putExtra(),
8174 * or the default value if none was found.
8175 *
8176 * @see #putExtra(String, int)
8177 */
8178 public int getIntExtra(String name, int defaultValue) {
8179 return mExtras == null ? defaultValue :
8180 mExtras.getInt(name, defaultValue);
8181 }
8182
8183 /**
8184 * Retrieve extended data from the intent.
8185 *
8186 * @param name The name of the desired item.
8187 * @param defaultValue the value to be returned if no value of the desired
8188 * type is stored with the given name.
8189 *
8190 * @return the value of an item previously added with putExtra(),
8191 * or the default value if none was found.
8192 *
8193 * @see #putExtra(String, long)
8194 */
8195 public long getLongExtra(String name, long defaultValue) {
8196 return mExtras == null ? defaultValue :
8197 mExtras.getLong(name, defaultValue);
8198 }
8199
8200 /**
8201 * Retrieve extended data from the intent.
8202 *
8203 * @param name The name of the desired item.
8204 * @param defaultValue the value to be returned if no value of the desired
8205 * type is stored with the given name.
8206 *
8207 * @return the value of an item previously added with putExtra(),
8208 * or the default value if no such item is present
8209 *
8210 * @see #putExtra(String, float)
8211 */
8212 public float getFloatExtra(String name, float defaultValue) {
8213 return mExtras == null ? defaultValue :
8214 mExtras.getFloat(name, defaultValue);
8215 }
8216
8217 /**
8218 * Retrieve extended data from the intent.
8219 *
8220 * @param name The name of the desired item.
8221 * @param defaultValue the value to be returned if no value of the desired
8222 * type is stored with the given name.
8223 *
8224 * @return the value of an item previously added with putExtra(),
8225 * or the default value if none was found.
8226 *
8227 * @see #putExtra(String, double)
8228 */
8229 public double getDoubleExtra(String name, double defaultValue) {
8230 return mExtras == null ? defaultValue :
8231 mExtras.getDouble(name, defaultValue);
8232 }
8233
8234 /**
8235 * Retrieve extended data from the intent.
8236 *
8237 * @param name The name of the desired item.
8238 *
8239 * @return the value of an item previously added with putExtra(),
8240 * or null if no String value was found.
8241 *
8242 * @see #putExtra(String, String)
8243 */
8244 public @Nullable String getStringExtra(String name) {
8245 return mExtras == null ? null : mExtras.getString(name);
8246 }
8247
8248 /**
8249 * Retrieve extended data from the intent.
8250 *
8251 * @param name The name of the desired item.
8252 *
8253 * @return the value of an item previously added with putExtra(),
8254 * or null if no CharSequence value was found.
8255 *
8256 * @see #putExtra(String, CharSequence)
8257 */
8258 public @Nullable CharSequence getCharSequenceExtra(String name) {
8259 return mExtras == null ? null : mExtras.getCharSequence(name);
8260 }
8261
8262 /**
8263 * Retrieve extended data from the intent.
8264 *
8265 * @param name The name of the desired item.
8266 *
8267 * @return the value of an item previously added with putExtra(),
8268 * or null if no Parcelable value was found.
8269 *
8270 * @see #putExtra(String, Parcelable)
8271 */
8272 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
8273 return mExtras == null ? null : mExtras.<T>getParcelable(name);
8274 }
8275
8276 /**
8277 * Retrieve extended data from the intent.
8278 *
8279 * @param name The name of the desired item.
8280 *
8281 * @return the value of an item previously added with putExtra(),
8282 * or null if no Parcelable[] value was found.
8283 *
8284 * @see #putExtra(String, Parcelable[])
8285 */
8286 public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
8287 return mExtras == null ? null : mExtras.getParcelableArray(name);
8288 }
8289
8290 /**
8291 * Retrieve extended data from the intent.
8292 *
8293 * @param name The name of the desired item.
8294 *
8295 * @return the value of an item previously added with
8296 * putParcelableArrayListExtra(), or null if no
8297 * ArrayList<Parcelable> value was found.
8298 *
8299 * @see #putParcelableArrayListExtra(String, ArrayList)
8300 */
8301 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
8302 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
8303 }
8304
8305 /**
8306 * Retrieve extended data from the intent.
8307 *
8308 * @param name The name of the desired item.
8309 *
8310 * @return the value of an item previously added with putExtra(),
8311 * or null if no Serializable value was found.
8312 *
8313 * @see #putExtra(String, Serializable)
8314 */
8315 public @Nullable Serializable getSerializableExtra(String name) {
8316 return mExtras == null ? null : mExtras.getSerializable(name);
8317 }
8318
8319 /**
8320 * Retrieve extended data from the intent.
8321 *
8322 * @param name The name of the desired item.
8323 *
8324 * @return the value of an item previously added with
8325 * putIntegerArrayListExtra(), or null if no
8326 * ArrayList<Integer> value was found.
8327 *
8328 * @see #putIntegerArrayListExtra(String, ArrayList)
8329 */
8330 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
8331 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
8332 }
8333
8334 /**
8335 * Retrieve extended data from the intent.
8336 *
8337 * @param name The name of the desired item.
8338 *
8339 * @return the value of an item previously added with
8340 * putStringArrayListExtra(), or null if no
8341 * ArrayList<String> value was found.
8342 *
8343 * @see #putStringArrayListExtra(String, ArrayList)
8344 */
8345 public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
8346 return mExtras == null ? null : mExtras.getStringArrayList(name);
8347 }
8348
8349 /**
8350 * Retrieve extended data from the intent.
8351 *
8352 * @param name The name of the desired item.
8353 *
8354 * @return the value of an item previously added with
8355 * putCharSequenceArrayListExtra, or null if no
8356 * ArrayList<CharSequence> value was found.
8357 *
8358 * @see #putCharSequenceArrayListExtra(String, ArrayList)
8359 */
8360 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
8361 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
8362 }
8363
8364 /**
8365 * Retrieve extended data from the intent.
8366 *
8367 * @param name The name of the desired item.
8368 *
8369 * @return the value of an item previously added with putExtra(),
8370 * or null if no boolean array value was found.
8371 *
8372 * @see #putExtra(String, boolean[])
8373 */
8374 public @Nullable boolean[] getBooleanArrayExtra(String name) {
8375 return mExtras == null ? null : mExtras.getBooleanArray(name);
8376 }
8377
8378 /**
8379 * Retrieve extended data from the intent.
8380 *
8381 * @param name The name of the desired item.
8382 *
8383 * @return the value of an item previously added with putExtra(),
8384 * or null if no byte array value was found.
8385 *
8386 * @see #putExtra(String, byte[])
8387 */
8388 public @Nullable byte[] getByteArrayExtra(String name) {
8389 return mExtras == null ? null : mExtras.getByteArray(name);
8390 }
8391
8392 /**
8393 * Retrieve extended data from the intent.
8394 *
8395 * @param name The name of the desired item.
8396 *
8397 * @return the value of an item previously added with putExtra(),
8398 * or null if no short array value was found.
8399 *
8400 * @see #putExtra(String, short[])
8401 */
8402 public @Nullable short[] getShortArrayExtra(String name) {
8403 return mExtras == null ? null : mExtras.getShortArray(name);
8404 }
8405
8406 /**
8407 * Retrieve extended data from the intent.
8408 *
8409 * @param name The name of the desired item.
8410 *
8411 * @return the value of an item previously added with putExtra(),
8412 * or null if no char array value was found.
8413 *
8414 * @see #putExtra(String, char[])
8415 */
8416 public @Nullable char[] getCharArrayExtra(String name) {
8417 return mExtras == null ? null : mExtras.getCharArray(name);
8418 }
8419
8420 /**
8421 * Retrieve extended data from the intent.
8422 *
8423 * @param name The name of the desired item.
8424 *
8425 * @return the value of an item previously added with putExtra(),
8426 * or null if no int array value was found.
8427 *
8428 * @see #putExtra(String, int[])
8429 */
8430 public @Nullable int[] getIntArrayExtra(String name) {
8431 return mExtras == null ? null : mExtras.getIntArray(name);
8432 }
8433
8434 /**
8435 * Retrieve extended data from the intent.
8436 *
8437 * @param name The name of the desired item.
8438 *
8439 * @return the value of an item previously added with putExtra(),
8440 * or null if no long array value was found.
8441 *
8442 * @see #putExtra(String, long[])
8443 */
8444 public @Nullable long[] getLongArrayExtra(String name) {
8445 return mExtras == null ? null : mExtras.getLongArray(name);
8446 }
8447
8448 /**
8449 * Retrieve extended data from the intent.
8450 *
8451 * @param name The name of the desired item.
8452 *
8453 * @return the value of an item previously added with putExtra(),
8454 * or null if no float array value was found.
8455 *
8456 * @see #putExtra(String, float[])
8457 */
8458 public @Nullable float[] getFloatArrayExtra(String name) {
8459 return mExtras == null ? null : mExtras.getFloatArray(name);
8460 }
8461
8462 /**
8463 * Retrieve extended data from the intent.
8464 *
8465 * @param name The name of the desired item.
8466 *
8467 * @return the value of an item previously added with putExtra(),
8468 * or null if no double array value was found.
8469 *
8470 * @see #putExtra(String, double[])
8471 */
8472 public @Nullable double[] getDoubleArrayExtra(String name) {
8473 return mExtras == null ? null : mExtras.getDoubleArray(name);
8474 }
8475
8476 /**
8477 * Retrieve extended data from the intent.
8478 *
8479 * @param name The name of the desired item.
8480 *
8481 * @return the value of an item previously added with putExtra(),
8482 * or null if no String array value was found.
8483 *
8484 * @see #putExtra(String, String[])
8485 */
8486 public @Nullable String[] getStringArrayExtra(String name) {
8487 return mExtras == null ? null : mExtras.getStringArray(name);
8488 }
8489
8490 /**
8491 * Retrieve extended data from the intent.
8492 *
8493 * @param name The name of the desired item.
8494 *
8495 * @return the value of an item previously added with putExtra(),
8496 * or null if no CharSequence array value was found.
8497 *
8498 * @see #putExtra(String, CharSequence[])
8499 */
8500 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
8501 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
8502 }
8503
8504 /**
8505 * Retrieve extended data from the intent.
8506 *
8507 * @param name The name of the desired item.
8508 *
8509 * @return the value of an item previously added with putExtra(),
8510 * or null if no Bundle value was found.
8511 *
8512 * @see #putExtra(String, Bundle)
8513 */
8514 public @Nullable Bundle getBundleExtra(String name) {
8515 return mExtras == null ? null : mExtras.getBundle(name);
8516 }
8517
8518 /**
8519 * Retrieve extended data from the intent.
8520 *
8521 * @param name The name of the desired item.
8522 *
8523 * @return the value of an item previously added with putExtra(),
8524 * or null if no IBinder value was found.
8525 *
8526 * @see #putExtra(String, IBinder)
8527 *
8528 * @deprecated
8529 * @hide
8530 */
8531 @Deprecated
8532 @UnsupportedAppUsage
8533 public IBinder getIBinderExtra(String name) {
8534 return mExtras == null ? null : mExtras.getIBinder(name);
8535 }
8536
8537 /**
8538 * Retrieve extended data from the intent.
8539 *
8540 * @param name The name of the desired item.
8541 * @param defaultValue The default value to return in case no item is
8542 * associated with the key 'name'
8543 *
8544 * @return the value of an item previously added with putExtra(),
8545 * or defaultValue if none was found.
8546 *
8547 * @see #putExtra
8548 *
8549 * @deprecated
8550 * @hide
8551 */
8552 @Deprecated
8553 @UnsupportedAppUsage
8554 public Object getExtra(String name, Object defaultValue) {
8555 Object result = defaultValue;
8556 if (mExtras != null) {
8557 Object result2 = mExtras.get(name);
8558 if (result2 != null) {
8559 result = result2;
8560 }
8561 }
8562
8563 return result;
8564 }
8565
8566 /**
8567 * Retrieves a map of extended data from the intent.
8568 *
8569 * @return the map of all extras previously added with putExtra(),
8570 * or null if none have been added.
8571 */
8572 public @Nullable Bundle getExtras() {
8573 return (mExtras != null)
8574 ? new Bundle(mExtras)
8575 : null;
8576 }
8577
8578 /**
8579 * Filter extras to only basic types.
8580 * @hide
8581 */
8582 public void removeUnsafeExtras() {
8583 if (mExtras != null) {
8584 mExtras = mExtras.filterValues();
8585 }
8586 }
8587
8588 /**
8589 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
8590 * return itself as-is.
8591 * @hide
8592 */
8593 public boolean canStripForHistory() {
8594 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
8595 }
8596
8597 /**
8598 * Call it when the system needs to keep an intent for logging purposes to remove fields
8599 * that are not needed for logging.
8600 * @hide
8601 */
8602 public Intent maybeStripForHistory() {
8603 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
8604
8605 if (!canStripForHistory()) {
8606 return this;
8607 }
8608 return new Intent(this, COPY_MODE_HISTORY);
8609 }
8610
8611 /**
8612 * Retrieve any special flags associated with this intent. You will
8613 * normally just set them with {@link #setFlags} and let the system
8614 * take the appropriate action with them.
8615 *
8616 * @return The currently set flags.
8617 * @see #setFlags
8618 * @see #addFlags
8619 * @see #removeFlags
8620 */
8621 public @Flags int getFlags() {
8622 return mFlags;
8623 }
8624
8625 /** @hide */
8626 @UnsupportedAppUsage
8627 public boolean isExcludingStopped() {
8628 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
8629 == FLAG_EXCLUDE_STOPPED_PACKAGES;
8630 }
8631
8632 /**
8633 * Retrieve the application package name this Intent is limited to. When
8634 * resolving an Intent, if non-null this limits the resolution to only
8635 * components in the given application package.
8636 *
8637 * @return The name of the application package for the Intent.
8638 *
8639 * @see #resolveActivity
8640 * @see #setPackage
8641 */
8642 public @Nullable String getPackage() {
8643 return mPackage;
8644 }
8645
8646 /**
8647 * Retrieve the concrete component associated with the intent. When receiving
8648 * an intent, this is the component that was found to best handle it (that is,
8649 * yourself) and will always be non-null; in all other cases it will be
8650 * null unless explicitly set.
8651 *
8652 * @return The name of the application component to handle the intent.
8653 *
8654 * @see #resolveActivity
8655 * @see #setComponent
8656 */
8657 public @Nullable ComponentName getComponent() {
8658 return mComponent;
8659 }
8660
8661 /**
8662 * Get the bounds of the sender of this intent, in screen coordinates. This can be
8663 * used as a hint to the receiver for animations and the like. Null means that there
8664 * is no source bounds.
8665 */
8666 public @Nullable Rect getSourceBounds() {
8667 return mSourceBounds;
8668 }
8669
8670 /**
8671 * Return the Activity component that should be used to handle this intent.
8672 * The appropriate component is determined based on the information in the
8673 * intent, evaluated as follows:
8674 *
8675 * <p>If {@link #getComponent} returns an explicit class, that is returned
8676 * without any further consideration.
8677 *
8678 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
8679 * category to be considered.
8680 *
8681 * <p>If {@link #getAction} is non-NULL, the activity must handle this
8682 * action.
8683 *
8684 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
8685 * this type.
8686 *
8687 * <p>If {@link #addCategory} has added any categories, the activity must
8688 * handle ALL of the categories specified.
8689 *
8690 * <p>If {@link #getPackage} is non-NULL, only activity components in
8691 * that application package will be considered.
8692 *
8693 * <p>If there are no activities that satisfy all of these conditions, a
8694 * null string is returned.
8695 *
8696 * <p>If multiple activities are found to satisfy the intent, the one with
8697 * the highest priority will be used. If there are multiple activities
8698 * with the same priority, the system will either pick the best activity
8699 * based on user preference, or resolve to a system class that will allow
8700 * the user to pick an activity and forward from there.
8701 *
8702 * <p>This method is implemented simply by calling
8703 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
8704 * true.</p>
8705 * <p> This API is called for you as part of starting an activity from an
8706 * intent. You do not normally need to call it yourself.</p>
8707 *
8708 * @param pm The package manager with which to resolve the Intent.
8709 *
8710 * @return Name of the component implementing an activity that can
8711 * display the intent.
8712 *
8713 * @see #setComponent
8714 * @see #getComponent
8715 * @see #resolveActivityInfo
8716 */
8717 public ComponentName resolveActivity(@NonNull PackageManager pm) {
8718 if (mComponent != null) {
8719 return mComponent;
8720 }
8721
8722 ResolveInfo info = pm.resolveActivity(
8723 this, PackageManager.MATCH_DEFAULT_ONLY);
8724 if (info != null) {
8725 return new ComponentName(
8726 info.activityInfo.applicationInfo.packageName,
8727 info.activityInfo.name);
8728 }
8729
8730 return null;
8731 }
8732
8733 /**
8734 * Resolve the Intent into an {@link ActivityInfo}
8735 * describing the activity that should execute the intent. Resolution
8736 * follows the same rules as described for {@link #resolveActivity}, but
8737 * you get back the completely information about the resolved activity
8738 * instead of just its class name.
8739 *
8740 * @param pm The package manager with which to resolve the Intent.
8741 * @param flags Addition information to retrieve as per
8742 * {@link PackageManager#getActivityInfo(ComponentName, int)
8743 * PackageManager.getActivityInfo()}.
8744 *
8745 * @return PackageManager.ActivityInfo
8746 *
8747 * @see #resolveActivity
8748 */
8749 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
8750 @PackageManager.ComponentInfoFlags int flags) {
8751 ActivityInfo ai = null;
8752 if (mComponent != null) {
8753 try {
8754 ai = pm.getActivityInfo(mComponent, flags);
8755 } catch (PackageManager.NameNotFoundException e) {
8756 // ignore
8757 }
8758 } else {
8759 ResolveInfo info = pm.resolveActivity(
8760 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
8761 if (info != null) {
8762 ai = info.activityInfo;
8763 }
8764 }
8765
8766 return ai;
8767 }
8768
8769 /**
8770 * Special function for use by the system to resolve service
8771 * intents to system apps. Throws an exception if there are
8772 * multiple potential matches to the Intent. Returns null if
8773 * there are no matches.
8774 * @hide
8775 */
8776 @UnsupportedAppUsage
8777 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8778 @PackageManager.ComponentInfoFlags int flags) {
8779 if (mComponent != null) {
8780 return mComponent;
8781 }
8782
8783 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8784 if (results == null) {
8785 return null;
8786 }
8787 ComponentName comp = null;
8788 for (int i=0; i<results.size(); i++) {
8789 ResolveInfo ri = results.get(i);
8790 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8791 continue;
8792 }
8793 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8794 ri.serviceInfo.name);
8795 if (comp != null) {
8796 throw new IllegalStateException("Multiple system services handle " + this
8797 + ": " + comp + ", " + foundComp);
8798 }
8799 comp = foundComp;
8800 }
8801 return comp;
8802 }
8803
8804 /**
8805 * Set the general action to be performed.
8806 *
8807 * @param action An action name, such as ACTION_VIEW. Application-specific
8808 * actions should be prefixed with the vendor's package name.
8809 *
8810 * @return Returns the same Intent object, for chaining multiple calls
8811 * into a single statement.
8812 *
8813 * @see #getAction
8814 */
8815 public @NonNull Intent setAction(@Nullable String action) {
8816 mAction = action != null ? action.intern() : null;
8817 return this;
8818 }
8819
8820 /**
8821 * Set the data this intent is operating on. This method automatically
8822 * clears any type that was previously set by {@link #setType} or
8823 * {@link #setTypeAndNormalize}.
8824 *
8825 * <p><em>Note: scheme matching in the Android framework is
8826 * case-sensitive, unlike the formal RFC. As a result,
8827 * you should always write your Uri with a lower case scheme,
8828 * or use {@link Uri#normalizeScheme} or
8829 * {@link #setDataAndNormalize}
8830 * to ensure that the scheme is converted to lower case.</em>
8831 *
8832 * @param data The Uri of the data this intent is now targeting.
8833 *
8834 * @return Returns the same Intent object, for chaining multiple calls
8835 * into a single statement.
8836 *
8837 * @see #getData
8838 * @see #setDataAndNormalize
8839 * @see android.net.Uri#normalizeScheme()
8840 */
8841 public @NonNull Intent setData(@Nullable Uri data) {
8842 mData = data;
8843 mType = null;
8844 return this;
8845 }
8846
8847 /**
8848 * Normalize and set the data this intent is operating on.
8849 *
8850 * <p>This method automatically clears any type that was
8851 * previously set (for example, by {@link #setType}).
8852 *
8853 * <p>The data Uri is normalized using
8854 * {@link android.net.Uri#normalizeScheme} before it is set,
8855 * so really this is just a convenience method for
8856 * <pre>
8857 * setData(data.normalize())
8858 * </pre>
8859 *
8860 * @param data The Uri of the data this intent is now targeting.
8861 *
8862 * @return Returns the same Intent object, for chaining multiple calls
8863 * into a single statement.
8864 *
8865 * @see #getData
8866 * @see #setType
8867 * @see android.net.Uri#normalizeScheme
8868 */
8869 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
8870 return setData(data.normalizeScheme());
8871 }
8872
8873 /**
8874 * Set an explicit MIME data type.
8875 *
8876 * <p>This is used to create intents that only specify a type and not data,
8877 * for example to indicate the type of data to return.
8878 *
8879 * <p>This method automatically clears any data that was
8880 * previously set (for example by {@link #setData}).
8881 *
8882 * <p><em>Note: MIME type matching in the Android framework is
8883 * case-sensitive, unlike formal RFC MIME types. As a result,
8884 * you should always write your MIME types with lower case letters,
8885 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8886 * to ensure that it is converted to lower case.</em>
8887 *
8888 * @param type The MIME type of the data being handled by this intent.
8889 *
8890 * @return Returns the same Intent object, for chaining multiple calls
8891 * into a single statement.
8892 *
8893 * @see #getType
8894 * @see #setTypeAndNormalize
8895 * @see #setDataAndType
8896 * @see #normalizeMimeType
8897 */
8898 public @NonNull Intent setType(@Nullable String type) {
8899 mData = null;
8900 mType = type;
8901 return this;
8902 }
8903
8904 /**
8905 * Normalize and set an explicit MIME data type.
8906 *
8907 * <p>This is used to create intents that only specify a type and not data,
8908 * for example to indicate the type of data to return.
8909 *
8910 * <p>This method automatically clears any data that was
8911 * previously set (for example by {@link #setData}).
8912 *
8913 * <p>The MIME type is normalized using
8914 * {@link #normalizeMimeType} before it is set,
8915 * so really this is just a convenience method for
8916 * <pre>
8917 * setType(Intent.normalizeMimeType(type))
8918 * </pre>
8919 *
8920 * @param type The MIME type of the data being handled by this intent.
8921 *
8922 * @return Returns the same Intent object, for chaining multiple calls
8923 * into a single statement.
8924 *
8925 * @see #getType
8926 * @see #setData
8927 * @see #normalizeMimeType
8928 */
8929 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
8930 return setType(normalizeMimeType(type));
8931 }
8932
8933 /**
8934 * (Usually optional) Set the data for the intent along with an explicit
8935 * MIME data type. This method should very rarely be used -- it allows you
8936 * to override the MIME type that would ordinarily be inferred from the
8937 * data with your own type given here.
8938 *
8939 * <p><em>Note: MIME type and Uri scheme matching in the
8940 * Android framework is case-sensitive, unlike the formal RFC definitions.
8941 * As a result, you should always write these elements with lower case letters,
8942 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
8943 * {@link #setDataAndTypeAndNormalize}
8944 * to ensure that they are converted to lower case.</em>
8945 *
8946 * @param data The Uri of the data this intent is now targeting.
8947 * @param type The MIME type of the data being handled by this intent.
8948 *
8949 * @return Returns the same Intent object, for chaining multiple calls
8950 * into a single statement.
8951 *
8952 * @see #setType
8953 * @see #setData
8954 * @see #normalizeMimeType
8955 * @see android.net.Uri#normalizeScheme
8956 * @see #setDataAndTypeAndNormalize
8957 */
8958 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
8959 mData = data;
8960 mType = type;
8961 return this;
8962 }
8963
8964 /**
8965 * (Usually optional) Normalize and set both the data Uri and an explicit
8966 * MIME data type. This method should very rarely be used -- it allows you
8967 * to override the MIME type that would ordinarily be inferred from the
8968 * data with your own type given here.
8969 *
8970 * <p>The data Uri and the MIME type are normalize using
8971 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
8972 * before they are set, so really this is just a convenience method for
8973 * <pre>
8974 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8975 * </pre>
8976 *
8977 * @param data The Uri of the data this intent is now targeting.
8978 * @param type The MIME type of the data being handled by this intent.
8979 *
8980 * @return Returns the same Intent object, for chaining multiple calls
8981 * into a single statement.
8982 *
8983 * @see #setType
8984 * @see #setData
8985 * @see #setDataAndType
8986 * @see #normalizeMimeType
8987 * @see android.net.Uri#normalizeScheme
8988 */
8989 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
8990 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
8991 }
8992
8993 /**
8994 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent,
8995 * allowing it to be unique from other Intents that would otherwise look the same. In
8996 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two
8997 * Intents are the same as with other fields like {@link #setAction}. However, unlike those
8998 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter};
8999 * it is as if the identifier has not been set on the Intent.
9000 *
9001 * <p>This can be used, for example, to make this Intent unique from other Intents that
9002 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware
9003 * however that the receiver of the PendingIntent will see whatever you put in here.) The
9004 * structure of this string is completely undefined by the platform, however if you are going
9005 * to be exposing identifier strings across different applications you may need to define
9006 * your own structure if there is no central party defining the contents of this field.</p>
9007 *
9008 * @param identifier The identifier for this Intent. The contents of the string have no
9009 * meaning to the system, except whether they are exactly the same as
9010 * another identifier.
9011 *
9012 * @return Returns the same Intent object, for chaining multiple calls
9013 * into a single statement.
9014 *
9015 * @see #getIdentifier
9016 */
9017 public @NonNull Intent setIdentifier(@Nullable String identifier) {
9018 mIdentifier = identifier;
9019 return this;
9020 }
9021
9022 /**
9023 * Add a new category to the intent. Categories provide additional detail
9024 * about the action the intent performs. When resolving an intent, only
9025 * activities that provide <em>all</em> of the requested categories will be
9026 * used.
9027 *
9028 * @param category The desired category. This can be either one of the
9029 * predefined Intent categories, or a custom category in your own
9030 * namespace.
9031 *
9032 * @return Returns the same Intent object, for chaining multiple calls
9033 * into a single statement.
9034 *
9035 * @see #hasCategory
9036 * @see #removeCategory
9037 */
9038 public @NonNull Intent addCategory(String category) {
9039 if (mCategories == null) {
9040 mCategories = new ArraySet<String>();
9041 }
9042 mCategories.add(category.intern());
9043 return this;
9044 }
9045
9046 /**
9047 * Remove a category from an intent.
9048 *
9049 * @param category The category to remove.
9050 *
9051 * @see #addCategory
9052 */
9053 public void removeCategory(String category) {
9054 if (mCategories != null) {
9055 mCategories.remove(category);
9056 if (mCategories.size() == 0) {
9057 mCategories = null;
9058 }
9059 }
9060 }
9061
9062 /**
9063 * Set a selector for this Intent. This is a modification to the kinds of
9064 * things the Intent will match. If the selector is set, it will be used
9065 * when trying to find entities that can handle the Intent, instead of the
9066 * main contents of the Intent. This allows you build an Intent containing
9067 * a generic protocol while targeting it more specifically.
9068 *
9069 * <p>An example of where this may be used is with things like
9070 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
9071 * Intent that will launch the Browser application. However, the correct
9072 * main entry point of an application is actually {@link #ACTION_MAIN}
9073 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
9074 * used to specify the actual Activity to launch. If you launch the browser
9075 * with something different, undesired behavior may happen if the user has
9076 * previously or later launches it the normal way, since they do not match.
9077 * Instead, you can build an Intent with the MAIN action (but no ComponentName
9078 * yet specified) and set a selector with {@link #ACTION_MAIN} and
9079 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
9080 *
9081 * <p>Setting a selector does not impact the behavior of
9082 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
9083 * desired behavior of a selector -- it does not impact the base meaning
9084 * of the Intent, just what kinds of things will be matched against it
9085 * when determining who can handle it.</p>
9086 *
9087 * <p>You can not use both a selector and {@link #setPackage(String)} on
9088 * the same base Intent.</p>
9089 *
9090 * @param selector The desired selector Intent; set to null to not use
9091 * a special selector.
9092 */
9093 public void setSelector(@Nullable Intent selector) {
9094 if (selector == this) {
9095 throw new IllegalArgumentException(
9096 "Intent being set as a selector of itself");
9097 }
9098 if (selector != null && mPackage != null) {
9099 throw new IllegalArgumentException(
9100 "Can't set selector when package name is already set");
9101 }
9102 mSelector = selector;
9103 }
9104
9105 /**
9106 * Set a {@link ClipData} associated with this Intent. This replaces any
9107 * previously set ClipData.
9108 *
9109 * <p>The ClipData in an intent is not used for Intent matching or other
9110 * such operations. Semantically it is like extras, used to transmit
9111 * additional data with the Intent. The main feature of using this over
9112 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
9113 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
9114 * items included in the clip data. This is useful, in particular, if
9115 * you want to transmit an Intent containing multiple <code>content:</code>
9116 * URIs for which the recipient may not have global permission to access the
9117 * content provider.
9118 *
9119 * <p>If the ClipData contains items that are themselves Intents, any
9120 * grant flags in those Intents will be ignored. Only the top-level flags
9121 * of the main Intent are respected, and will be applied to all Uri or
9122 * Intent items in the clip (or sub-items of the clip).
9123 *
9124 * <p>The MIME type, label, and icon in the ClipData object are not
9125 * directly used by Intent. Applications should generally rely on the
9126 * MIME type of the Intent itself, not what it may find in the ClipData.
9127 * A common practice is to construct a ClipData for use with an Intent
9128 * with a MIME type of "*&#47;*".
9129 *
9130 * @param clip The new clip to set. May be null to clear the current clip.
9131 */
9132 public void setClipData(@Nullable ClipData clip) {
9133 mClipData = clip;
9134 }
9135
9136 /**
9137 * This is NOT a secure mechanism to identify the user who sent the intent.
9138 * When the intent is sent to a different user, it is used to fix uris by adding the userId
9139 * who sent the intent.
9140 * @hide
9141 */
9142 public void prepareToLeaveUser(int userId) {
9143 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
9144 // We want mContentUserHint to refer to the original user, so don't do anything.
9145 if (mContentUserHint == UserHandle.USER_CURRENT) {
9146 mContentUserHint = userId;
9147 }
9148 }
9149
9150 /**
9151 * Add extended data to the intent. The name must include a package
9152 * prefix, for example the app com.android.contacts would use names
9153 * like "com.android.contacts.ShowAll".
9154 *
9155 * @param name The name of the extra data, with package prefix.
9156 * @param value The boolean data value.
9157 *
9158 * @return Returns the same Intent object, for chaining multiple calls
9159 * into a single statement.
9160 *
9161 * @see #putExtras
9162 * @see #removeExtra
9163 * @see #getBooleanExtra(String, boolean)
9164 */
9165 public @NonNull Intent putExtra(String name, boolean value) {
9166 if (mExtras == null) {
9167 mExtras = new Bundle();
9168 }
9169 mExtras.putBoolean(name, value);
9170 return this;
9171 }
9172
9173 /**
9174 * Add extended data to the intent. The name must include a package
9175 * prefix, for example the app com.android.contacts would use names
9176 * like "com.android.contacts.ShowAll".
9177 *
9178 * @param name The name of the extra data, with package prefix.
9179 * @param value The byte data value.
9180 *
9181 * @return Returns the same Intent object, for chaining multiple calls
9182 * into a single statement.
9183 *
9184 * @see #putExtras
9185 * @see #removeExtra
9186 * @see #getByteExtra(String, byte)
9187 */
9188 public @NonNull Intent putExtra(String name, byte value) {
9189 if (mExtras == null) {
9190 mExtras = new Bundle();
9191 }
9192 mExtras.putByte(name, value);
9193 return this;
9194 }
9195
9196 /**
9197 * Add extended data to the intent. The name must include a package
9198 * prefix, for example the app com.android.contacts would use names
9199 * like "com.android.contacts.ShowAll".
9200 *
9201 * @param name The name of the extra data, with package prefix.
9202 * @param value The char data value.
9203 *
9204 * @return Returns the same Intent object, for chaining multiple calls
9205 * into a single statement.
9206 *
9207 * @see #putExtras
9208 * @see #removeExtra
9209 * @see #getCharExtra(String, char)
9210 */
9211 public @NonNull Intent putExtra(String name, char value) {
9212 if (mExtras == null) {
9213 mExtras = new Bundle();
9214 }
9215 mExtras.putChar(name, value);
9216 return this;
9217 }
9218
9219 /**
9220 * Add extended data to the intent. The name must include a package
9221 * prefix, for example the app com.android.contacts would use names
9222 * like "com.android.contacts.ShowAll".
9223 *
9224 * @param name The name of the extra data, with package prefix.
9225 * @param value The short data value.
9226 *
9227 * @return Returns the same Intent object, for chaining multiple calls
9228 * into a single statement.
9229 *
9230 * @see #putExtras
9231 * @see #removeExtra
9232 * @see #getShortExtra(String, short)
9233 */
9234 public @NonNull Intent putExtra(String name, short value) {
9235 if (mExtras == null) {
9236 mExtras = new Bundle();
9237 }
9238 mExtras.putShort(name, value);
9239 return this;
9240 }
9241
9242 /**
9243 * Add extended data to the intent. The name must include a package
9244 * prefix, for example the app com.android.contacts would use names
9245 * like "com.android.contacts.ShowAll".
9246 *
9247 * @param name The name of the extra data, with package prefix.
9248 * @param value The integer data value.
9249 *
9250 * @return Returns the same Intent object, for chaining multiple calls
9251 * into a single statement.
9252 *
9253 * @see #putExtras
9254 * @see #removeExtra
9255 * @see #getIntExtra(String, int)
9256 */
9257 public @NonNull Intent putExtra(String name, int value) {
9258 if (mExtras == null) {
9259 mExtras = new Bundle();
9260 }
9261 mExtras.putInt(name, value);
9262 return this;
9263 }
9264
9265 /**
9266 * Add extended data to the intent. The name must include a package
9267 * prefix, for example the app com.android.contacts would use names
9268 * like "com.android.contacts.ShowAll".
9269 *
9270 * @param name The name of the extra data, with package prefix.
9271 * @param value The long data value.
9272 *
9273 * @return Returns the same Intent object, for chaining multiple calls
9274 * into a single statement.
9275 *
9276 * @see #putExtras
9277 * @see #removeExtra
9278 * @see #getLongExtra(String, long)
9279 */
9280 public @NonNull Intent putExtra(String name, long value) {
9281 if (mExtras == null) {
9282 mExtras = new Bundle();
9283 }
9284 mExtras.putLong(name, value);
9285 return this;
9286 }
9287
9288 /**
9289 * Add extended data to the intent. The name must include a package
9290 * prefix, for example the app com.android.contacts would use names
9291 * like "com.android.contacts.ShowAll".
9292 *
9293 * @param name The name of the extra data, with package prefix.
9294 * @param value The float data value.
9295 *
9296 * @return Returns the same Intent object, for chaining multiple calls
9297 * into a single statement.
9298 *
9299 * @see #putExtras
9300 * @see #removeExtra
9301 * @see #getFloatExtra(String, float)
9302 */
9303 public @NonNull Intent putExtra(String name, float value) {
9304 if (mExtras == null) {
9305 mExtras = new Bundle();
9306 }
9307 mExtras.putFloat(name, value);
9308 return this;
9309 }
9310
9311 /**
9312 * Add extended data to the intent. The name must include a package
9313 * prefix, for example the app com.android.contacts would use names
9314 * like "com.android.contacts.ShowAll".
9315 *
9316 * @param name The name of the extra data, with package prefix.
9317 * @param value The double data value.
9318 *
9319 * @return Returns the same Intent object, for chaining multiple calls
9320 * into a single statement.
9321 *
9322 * @see #putExtras
9323 * @see #removeExtra
9324 * @see #getDoubleExtra(String, double)
9325 */
9326 public @NonNull Intent putExtra(String name, double value) {
9327 if (mExtras == null) {
9328 mExtras = new Bundle();
9329 }
9330 mExtras.putDouble(name, value);
9331 return this;
9332 }
9333
9334 /**
9335 * Add extended data to the intent. The name must include a package
9336 * prefix, for example the app com.android.contacts would use names
9337 * like "com.android.contacts.ShowAll".
9338 *
9339 * @param name The name of the extra data, with package prefix.
9340 * @param value The String data value.
9341 *
9342 * @return Returns the same Intent object, for chaining multiple calls
9343 * into a single statement.
9344 *
9345 * @see #putExtras
9346 * @see #removeExtra
9347 * @see #getStringExtra(String)
9348 */
9349 public @NonNull Intent putExtra(String name, @Nullable String value) {
9350 if (mExtras == null) {
9351 mExtras = new Bundle();
9352 }
9353 mExtras.putString(name, value);
9354 return this;
9355 }
9356
9357 /**
9358 * Add extended data to the intent. The name must include a package
9359 * prefix, for example the app com.android.contacts would use names
9360 * like "com.android.contacts.ShowAll".
9361 *
9362 * @param name The name of the extra data, with package prefix.
9363 * @param value The CharSequence data value.
9364 *
9365 * @return Returns the same Intent object, for chaining multiple calls
9366 * into a single statement.
9367 *
9368 * @see #putExtras
9369 * @see #removeExtra
9370 * @see #getCharSequenceExtra(String)
9371 */
9372 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
9373 if (mExtras == null) {
9374 mExtras = new Bundle();
9375 }
9376 mExtras.putCharSequence(name, value);
9377 return this;
9378 }
9379
9380 /**
9381 * Add extended data to the intent. The name must include a package
9382 * prefix, for example the app com.android.contacts would use names
9383 * like "com.android.contacts.ShowAll".
9384 *
9385 * @param name The name of the extra data, with package prefix.
9386 * @param value The Parcelable data value.
9387 *
9388 * @return Returns the same Intent object, for chaining multiple calls
9389 * into a single statement.
9390 *
9391 * @see #putExtras
9392 * @see #removeExtra
9393 * @see #getParcelableExtra(String)
9394 */
9395 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
9396 if (mExtras == null) {
9397 mExtras = new Bundle();
9398 }
9399 mExtras.putParcelable(name, value);
9400 return this;
9401 }
9402
9403 /**
9404 * Add extended data to the intent. The name must include a package
9405 * prefix, for example the app com.android.contacts would use names
9406 * like "com.android.contacts.ShowAll".
9407 *
9408 * @param name The name of the extra data, with package prefix.
9409 * @param value The Parcelable[] data value.
9410 *
9411 * @return Returns the same Intent object, for chaining multiple calls
9412 * into a single statement.
9413 *
9414 * @see #putExtras
9415 * @see #removeExtra
9416 * @see #getParcelableArrayExtra(String)
9417 */
9418 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
9419 if (mExtras == null) {
9420 mExtras = new Bundle();
9421 }
9422 mExtras.putParcelableArray(name, value);
9423 return this;
9424 }
9425
9426 /**
9427 * Add extended data to the intent. The name must include a package
9428 * prefix, for example the app com.android.contacts would use names
9429 * like "com.android.contacts.ShowAll".
9430 *
9431 * @param name The name of the extra data, with package prefix.
9432 * @param value The ArrayList<Parcelable> data value.
9433 *
9434 * @return Returns the same Intent object, for chaining multiple calls
9435 * into a single statement.
9436 *
9437 * @see #putExtras
9438 * @see #removeExtra
9439 * @see #getParcelableArrayListExtra(String)
9440 */
9441 public @NonNull Intent putParcelableArrayListExtra(String name,
9442 @Nullable ArrayList<? extends Parcelable> value) {
9443 if (mExtras == null) {
9444 mExtras = new Bundle();
9445 }
9446 mExtras.putParcelableArrayList(name, value);
9447 return this;
9448 }
9449
9450 /**
9451 * Add extended data to the intent. The name must include a package
9452 * prefix, for example the app com.android.contacts would use names
9453 * like "com.android.contacts.ShowAll".
9454 *
9455 * @param name The name of the extra data, with package prefix.
9456 * @param value The ArrayList<Integer> data value.
9457 *
9458 * @return Returns the same Intent object, for chaining multiple calls
9459 * into a single statement.
9460 *
9461 * @see #putExtras
9462 * @see #removeExtra
9463 * @see #getIntegerArrayListExtra(String)
9464 */
9465 public @NonNull Intent putIntegerArrayListExtra(String name,
9466 @Nullable ArrayList<Integer> value) {
9467 if (mExtras == null) {
9468 mExtras = new Bundle();
9469 }
9470 mExtras.putIntegerArrayList(name, value);
9471 return this;
9472 }
9473
9474 /**
9475 * Add extended data to the intent. The name must include a package
9476 * prefix, for example the app com.android.contacts would use names
9477 * like "com.android.contacts.ShowAll".
9478 *
9479 * @param name The name of the extra data, with package prefix.
9480 * @param value The ArrayList<String> data value.
9481 *
9482 * @return Returns the same Intent object, for chaining multiple calls
9483 * into a single statement.
9484 *
9485 * @see #putExtras
9486 * @see #removeExtra
9487 * @see #getStringArrayListExtra(String)
9488 */
9489 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
9490 if (mExtras == null) {
9491 mExtras = new Bundle();
9492 }
9493 mExtras.putStringArrayList(name, value);
9494 return this;
9495 }
9496
9497 /**
9498 * Add extended data to the intent. The name must include a package
9499 * prefix, for example the app com.android.contacts would use names
9500 * like "com.android.contacts.ShowAll".
9501 *
9502 * @param name The name of the extra data, with package prefix.
9503 * @param value The ArrayList<CharSequence> data value.
9504 *
9505 * @return Returns the same Intent object, for chaining multiple calls
9506 * into a single statement.
9507 *
9508 * @see #putExtras
9509 * @see #removeExtra
9510 * @see #getCharSequenceArrayListExtra(String)
9511 */
9512 public @NonNull Intent putCharSequenceArrayListExtra(String name,
9513 @Nullable ArrayList<CharSequence> value) {
9514 if (mExtras == null) {
9515 mExtras = new Bundle();
9516 }
9517 mExtras.putCharSequenceArrayList(name, value);
9518 return this;
9519 }
9520
9521 /**
9522 * Add extended data to the intent. The name must include a package
9523 * prefix, for example the app com.android.contacts would use names
9524 * like "com.android.contacts.ShowAll".
9525 *
9526 * @param name The name of the extra data, with package prefix.
9527 * @param value The Serializable data value.
9528 *
9529 * @return Returns the same Intent object, for chaining multiple calls
9530 * into a single statement.
9531 *
9532 * @see #putExtras
9533 * @see #removeExtra
9534 * @see #getSerializableExtra(String)
9535 */
9536 public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
9537 if (mExtras == null) {
9538 mExtras = new Bundle();
9539 }
9540 mExtras.putSerializable(name, value);
9541 return this;
9542 }
9543
9544 /**
9545 * Add extended data to the intent. The name must include a package
9546 * prefix, for example the app com.android.contacts would use names
9547 * like "com.android.contacts.ShowAll".
9548 *
9549 * @param name The name of the extra data, with package prefix.
9550 * @param value The boolean array data value.
9551 *
9552 * @return Returns the same Intent object, for chaining multiple calls
9553 * into a single statement.
9554 *
9555 * @see #putExtras
9556 * @see #removeExtra
9557 * @see #getBooleanArrayExtra(String)
9558 */
9559 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
9560 if (mExtras == null) {
9561 mExtras = new Bundle();
9562 }
9563 mExtras.putBooleanArray(name, value);
9564 return this;
9565 }
9566
9567 /**
9568 * Add extended data to the intent. The name must include a package
9569 * prefix, for example the app com.android.contacts would use names
9570 * like "com.android.contacts.ShowAll".
9571 *
9572 * @param name The name of the extra data, with package prefix.
9573 * @param value The byte array data value.
9574 *
9575 * @return Returns the same Intent object, for chaining multiple calls
9576 * into a single statement.
9577 *
9578 * @see #putExtras
9579 * @see #removeExtra
9580 * @see #getByteArrayExtra(String)
9581 */
9582 public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
9583 if (mExtras == null) {
9584 mExtras = new Bundle();
9585 }
9586 mExtras.putByteArray(name, value);
9587 return this;
9588 }
9589
9590 /**
9591 * Add extended data to the intent. The name must include a package
9592 * prefix, for example the app com.android.contacts would use names
9593 * like "com.android.contacts.ShowAll".
9594 *
9595 * @param name The name of the extra data, with package prefix.
9596 * @param value The short array data value.
9597 *
9598 * @return Returns the same Intent object, for chaining multiple calls
9599 * into a single statement.
9600 *
9601 * @see #putExtras
9602 * @see #removeExtra
9603 * @see #getShortArrayExtra(String)
9604 */
9605 public @NonNull Intent putExtra(String name, @Nullable short[] value) {
9606 if (mExtras == null) {
9607 mExtras = new Bundle();
9608 }
9609 mExtras.putShortArray(name, value);
9610 return this;
9611 }
9612
9613 /**
9614 * Add extended data to the intent. The name must include a package
9615 * prefix, for example the app com.android.contacts would use names
9616 * like "com.android.contacts.ShowAll".
9617 *
9618 * @param name The name of the extra data, with package prefix.
9619 * @param value The char array data value.
9620 *
9621 * @return Returns the same Intent object, for chaining multiple calls
9622 * into a single statement.
9623 *
9624 * @see #putExtras
9625 * @see #removeExtra
9626 * @see #getCharArrayExtra(String)
9627 */
9628 public @NonNull Intent putExtra(String name, @Nullable char[] value) {
9629 if (mExtras == null) {
9630 mExtras = new Bundle();
9631 }
9632 mExtras.putCharArray(name, value);
9633 return this;
9634 }
9635
9636 /**
9637 * Add extended data to the intent. The name must include a package
9638 * prefix, for example the app com.android.contacts would use names
9639 * like "com.android.contacts.ShowAll".
9640 *
9641 * @param name The name of the extra data, with package prefix.
9642 * @param value The int array data value.
9643 *
9644 * @return Returns the same Intent object, for chaining multiple calls
9645 * into a single statement.
9646 *
9647 * @see #putExtras
9648 * @see #removeExtra
9649 * @see #getIntArrayExtra(String)
9650 */
9651 public @NonNull Intent putExtra(String name, @Nullable int[] value) {
9652 if (mExtras == null) {
9653 mExtras = new Bundle();
9654 }
9655 mExtras.putIntArray(name, value);
9656 return this;
9657 }
9658
9659 /**
9660 * Add extended data to the intent. The name must include a package
9661 * prefix, for example the app com.android.contacts would use names
9662 * like "com.android.contacts.ShowAll".
9663 *
9664 * @param name The name of the extra data, with package prefix.
9665 * @param value The byte array data value.
9666 *
9667 * @return Returns the same Intent object, for chaining multiple calls
9668 * into a single statement.
9669 *
9670 * @see #putExtras
9671 * @see #removeExtra
9672 * @see #getLongArrayExtra(String)
9673 */
9674 public @NonNull Intent putExtra(String name, @Nullable long[] value) {
9675 if (mExtras == null) {
9676 mExtras = new Bundle();
9677 }
9678 mExtras.putLongArray(name, value);
9679 return this;
9680 }
9681
9682 /**
9683 * Add extended data to the intent. The name must include a package
9684 * prefix, for example the app com.android.contacts would use names
9685 * like "com.android.contacts.ShowAll".
9686 *
9687 * @param name The name of the extra data, with package prefix.
9688 * @param value The float array data value.
9689 *
9690 * @return Returns the same Intent object, for chaining multiple calls
9691 * into a single statement.
9692 *
9693 * @see #putExtras
9694 * @see #removeExtra
9695 * @see #getFloatArrayExtra(String)
9696 */
9697 public @NonNull Intent putExtra(String name, @Nullable float[] value) {
9698 if (mExtras == null) {
9699 mExtras = new Bundle();
9700 }
9701 mExtras.putFloatArray(name, value);
9702 return this;
9703 }
9704
9705 /**
9706 * Add extended data to the intent. The name must include a package
9707 * prefix, for example the app com.android.contacts would use names
9708 * like "com.android.contacts.ShowAll".
9709 *
9710 * @param name The name of the extra data, with package prefix.
9711 * @param value The double array data value.
9712 *
9713 * @return Returns the same Intent object, for chaining multiple calls
9714 * into a single statement.
9715 *
9716 * @see #putExtras
9717 * @see #removeExtra
9718 * @see #getDoubleArrayExtra(String)
9719 */
9720 public @NonNull Intent putExtra(String name, @Nullable double[] value) {
9721 if (mExtras == null) {
9722 mExtras = new Bundle();
9723 }
9724 mExtras.putDoubleArray(name, value);
9725 return this;
9726 }
9727
9728 /**
9729 * Add extended data to the intent. The name must include a package
9730 * prefix, for example the app com.android.contacts would use names
9731 * like "com.android.contacts.ShowAll".
9732 *
9733 * @param name The name of the extra data, with package prefix.
9734 * @param value The String array data value.
9735 *
9736 * @return Returns the same Intent object, for chaining multiple calls
9737 * into a single statement.
9738 *
9739 * @see #putExtras
9740 * @see #removeExtra
9741 * @see #getStringArrayExtra(String)
9742 */
9743 public @NonNull Intent putExtra(String name, @Nullable String[] value) {
9744 if (mExtras == null) {
9745 mExtras = new Bundle();
9746 }
9747 mExtras.putStringArray(name, value);
9748 return this;
9749 }
9750
9751 /**
9752 * Add extended data to the intent. The name must include a package
9753 * prefix, for example the app com.android.contacts would use names
9754 * like "com.android.contacts.ShowAll".
9755 *
9756 * @param name The name of the extra data, with package prefix.
9757 * @param value The CharSequence array data value.
9758 *
9759 * @return Returns the same Intent object, for chaining multiple calls
9760 * into a single statement.
9761 *
9762 * @see #putExtras
9763 * @see #removeExtra
9764 * @see #getCharSequenceArrayExtra(String)
9765 */
9766 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
9767 if (mExtras == null) {
9768 mExtras = new Bundle();
9769 }
9770 mExtras.putCharSequenceArray(name, value);
9771 return this;
9772 }
9773
9774 /**
9775 * Add extended data to the intent. The name must include a package
9776 * prefix, for example the app com.android.contacts would use names
9777 * like "com.android.contacts.ShowAll".
9778 *
9779 * @param name The name of the extra data, with package prefix.
9780 * @param value The Bundle data value.
9781 *
9782 * @return Returns the same Intent object, for chaining multiple calls
9783 * into a single statement.
9784 *
9785 * @see #putExtras
9786 * @see #removeExtra
9787 * @see #getBundleExtra(String)
9788 */
9789 public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
9790 if (mExtras == null) {
9791 mExtras = new Bundle();
9792 }
9793 mExtras.putBundle(name, value);
9794 return this;
9795 }
9796
9797 /**
9798 * Add extended data to the intent. The name must include a package
9799 * prefix, for example the app com.android.contacts would use names
9800 * like "com.android.contacts.ShowAll".
9801 *
9802 * @param name The name of the extra data, with package prefix.
9803 * @param value The IBinder data value.
9804 *
9805 * @return Returns the same Intent object, for chaining multiple calls
9806 * into a single statement.
9807 *
9808 * @see #putExtras
9809 * @see #removeExtra
9810 * @see #getIBinderExtra(String)
9811 *
9812 * @deprecated
9813 * @hide
9814 */
9815 @Deprecated
9816 @UnsupportedAppUsage
9817 public @NonNull Intent putExtra(String name, IBinder value) {
9818 if (mExtras == null) {
9819 mExtras = new Bundle();
9820 }
9821 mExtras.putIBinder(name, value);
9822 return this;
9823 }
9824
9825 /**
9826 * Copy all extras in 'src' in to this intent.
9827 *
9828 * @param src Contains the extras to copy.
9829 *
9830 * @see #putExtra
9831 */
9832 public @NonNull Intent putExtras(@NonNull Intent src) {
9833 if (src.mExtras != null) {
9834 if (mExtras == null) {
9835 mExtras = new Bundle(src.mExtras);
9836 } else {
9837 mExtras.putAll(src.mExtras);
9838 }
9839 }
9840 return this;
9841 }
9842
9843 /**
9844 * Add a set of extended data to the intent. The keys must include a package
9845 * prefix, for example the app com.android.contacts would use names
9846 * like "com.android.contacts.ShowAll".
9847 *
9848 * @param extras The Bundle of extras to add to this intent.
9849 *
9850 * @see #putExtra
9851 * @see #removeExtra
9852 */
9853 public @NonNull Intent putExtras(@NonNull Bundle extras) {
9854 if (mExtras == null) {
9855 mExtras = new Bundle();
9856 }
9857 mExtras.putAll(extras);
9858 return this;
9859 }
9860
9861 /**
9862 * Completely replace the extras in the Intent with the extras in the
9863 * given Intent.
9864 *
9865 * @param src The exact extras contained in this Intent are copied
9866 * into the target intent, replacing any that were previously there.
9867 */
9868 public @NonNull Intent replaceExtras(@NonNull Intent src) {
9869 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9870 return this;
9871 }
9872
9873 /**
9874 * Completely replace the extras in the Intent with the given Bundle of
9875 * extras.
9876 *
9877 * @param extras The new set of extras in the Intent, or null to erase
9878 * all extras.
9879 */
9880 public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
9881 mExtras = extras != null ? new Bundle(extras) : null;
9882 return this;
9883 }
9884
9885 /**
9886 * Remove extended data from the intent.
9887 *
9888 * @see #putExtra
9889 */
9890 public void removeExtra(String name) {
9891 if (mExtras != null) {
9892 mExtras.remove(name);
9893 if (mExtras.size() == 0) {
9894 mExtras = null;
9895 }
9896 }
9897 }
9898
9899 /**
9900 * Set special flags controlling how this intent is handled. Most values
9901 * here depend on the type of component being executed by the Intent,
9902 * specifically the FLAG_ACTIVITY_* flags are all for use with
9903 * {@link Context#startActivity Context.startActivity()} and the
9904 * FLAG_RECEIVER_* flags are all for use with
9905 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9906 *
9907 * <p>See the
9908 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9909 * Stack</a> documentation for important information on how some of these options impact
9910 * the behavior of your application.
9911 *
9912 * @param flags The desired flags.
9913 * @return Returns the same Intent object, for chaining multiple calls
9914 * into a single statement.
9915 * @see #getFlags
9916 * @see #addFlags
9917 * @see #removeFlags
9918 */
9919 public @NonNull Intent setFlags(@Flags int flags) {
9920 mFlags = flags;
9921 return this;
9922 }
9923
9924 /**
9925 * Add additional flags to the intent (or with existing flags value).
9926 *
9927 * @param flags The new flags to set.
9928 * @return Returns the same Intent object, for chaining multiple calls into
9929 * a single statement.
9930 * @see #setFlags
9931 * @see #getFlags
9932 * @see #removeFlags
9933 */
9934 public @NonNull Intent addFlags(@Flags int flags) {
9935 mFlags |= flags;
9936 return this;
9937 }
9938
9939 /**
9940 * Remove these flags from the intent.
9941 *
9942 * @param flags The flags to remove.
9943 * @see #setFlags
9944 * @see #getFlags
9945 * @see #addFlags
9946 */
9947 public void removeFlags(@Flags int flags) {
9948 mFlags &= ~flags;
9949 }
9950
9951 /**
9952 * (Usually optional) Set an explicit application package name that limits
9953 * the components this Intent will resolve to. If left to the default
9954 * value of null, all components in all applications will considered.
9955 * If non-null, the Intent can only match the components in the given
9956 * application package.
9957 *
9958 * @param packageName The name of the application package to handle the
9959 * intent, or null to allow any application package.
9960 *
9961 * @return Returns the same Intent object, for chaining multiple calls
9962 * into a single statement.
9963 *
9964 * @see #getPackage
9965 * @see #resolveActivity
9966 */
9967 public @NonNull Intent setPackage(@Nullable String packageName) {
9968 if (packageName != null && mSelector != null) {
9969 throw new IllegalArgumentException(
9970 "Can't set package name when selector is already set");
9971 }
9972 mPackage = packageName;
9973 return this;
9974 }
9975
9976 /**
9977 * (Usually optional) Explicitly set the component to handle the intent.
9978 * If left with the default value of null, the system will determine the
9979 * appropriate class to use based on the other fields (action, data,
9980 * type, categories) in the Intent. If this class is defined, the
9981 * specified class will always be used regardless of the other fields. You
9982 * should only set this value when you know you absolutely want a specific
9983 * class to be used; otherwise it is better to let the system find the
9984 * appropriate class so that you will respect the installed applications
9985 * and user preferences.
9986 *
9987 * @param component The name of the application component to handle the
9988 * intent, or null to let the system find one for you.
9989 *
9990 * @return Returns the same Intent object, for chaining multiple calls
9991 * into a single statement.
9992 *
9993 * @see #setClass
9994 * @see #setClassName(Context, String)
9995 * @see #setClassName(String, String)
9996 * @see #getComponent
9997 * @see #resolveActivity
9998 */
9999 public @NonNull Intent setComponent(@Nullable ComponentName component) {
10000 mComponent = component;
10001 return this;
10002 }
10003
10004 /**
10005 * Convenience for calling {@link #setComponent} with an
10006 * explicit class name.
10007 *
10008 * @param packageContext A Context of the application package implementing
10009 * this class.
10010 * @param className The name of a class inside of the application package
10011 * that will be used as the component for this Intent.
10012 *
10013 * @return Returns the same Intent object, for chaining multiple calls
10014 * into a single statement.
10015 *
10016 * @see #setComponent
10017 * @see #setClass
10018 */
10019 public @NonNull Intent setClassName(@NonNull Context packageContext,
10020 @NonNull String className) {
10021 mComponent = new ComponentName(packageContext, className);
10022 return this;
10023 }
10024
10025 /**
10026 * Convenience for calling {@link #setComponent} with an
10027 * explicit application package name and class name.
10028 *
10029 * @param packageName The name of the package implementing the desired
10030 * component.
10031 * @param className The name of a class inside of the application package
10032 * that will be used as the component for this Intent.
10033 *
10034 * @return Returns the same Intent object, for chaining multiple calls
10035 * into a single statement.
10036 *
10037 * @see #setComponent
10038 * @see #setClass
10039 */
10040 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
10041 mComponent = new ComponentName(packageName, className);
10042 return this;
10043 }
10044
10045 /**
10046 * Convenience for calling {@link #setComponent(ComponentName)} with the
10047 * name returned by a {@link Class} object.
10048 *
10049 * @param packageContext A Context of the application package implementing
10050 * this class.
10051 * @param cls The class name to set, equivalent to
10052 * <code>setClassName(context, cls.getName())</code>.
10053 *
10054 * @return Returns the same Intent object, for chaining multiple calls
10055 * into a single statement.
10056 *
10057 * @see #setComponent
10058 */
10059 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
10060 mComponent = new ComponentName(packageContext, cls);
10061 return this;
10062 }
10063
10064 /**
10065 * Set the bounds of the sender of this intent, in screen coordinates. This can be
10066 * used as a hint to the receiver for animations and the like. Null means that there
10067 * is no source bounds.
10068 */
10069 public void setSourceBounds(@Nullable Rect r) {
10070 if (r != null) {
10071 mSourceBounds = new Rect(r);
10072 } else {
10073 mSourceBounds = null;
10074 }
10075 }
10076
10077 /** @hide */
10078 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
10079 FILL_IN_ACTION,
10080 FILL_IN_DATA,
10081 FILL_IN_CATEGORIES,
10082 FILL_IN_COMPONENT,
10083 FILL_IN_PACKAGE,
10084 FILL_IN_SOURCE_BOUNDS,
10085 FILL_IN_SELECTOR,
10086 FILL_IN_CLIP_DATA
10087 })
10088 @Retention(RetentionPolicy.SOURCE)
10089 public @interface FillInFlags {}
10090
10091 /**
10092 * Use with {@link #fillIn} to allow the current action value to be
10093 * overwritten, even if it is already set.
10094 */
10095 public static final int FILL_IN_ACTION = 1<<0;
10096
10097 /**
10098 * Use with {@link #fillIn} to allow the current data or type value
10099 * overwritten, even if it is already set.
10100 */
10101 public static final int FILL_IN_DATA = 1<<1;
10102
10103 /**
10104 * Use with {@link #fillIn} to allow the current categories to be
10105 * overwritten, even if they are already set.
10106 */
10107 public static final int FILL_IN_CATEGORIES = 1<<2;
10108
10109 /**
10110 * Use with {@link #fillIn} to allow the current component value to be
10111 * overwritten, even if it is already set.
10112 */
10113 public static final int FILL_IN_COMPONENT = 1<<3;
10114
10115 /**
10116 * Use with {@link #fillIn} to allow the current package value to be
10117 * overwritten, even if it is already set.
10118 */
10119 public static final int FILL_IN_PACKAGE = 1<<4;
10120
10121 /**
10122 * Use with {@link #fillIn} to allow the current bounds rectangle to be
10123 * overwritten, even if it is already set.
10124 */
10125 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
10126
10127 /**
10128 * Use with {@link #fillIn} to allow the current selector to be
10129 * overwritten, even if it is already set.
10130 */
10131 public static final int FILL_IN_SELECTOR = 1<<6;
10132
10133 /**
10134 * Use with {@link #fillIn} to allow the current ClipData to be
10135 * overwritten, even if it is already set.
10136 */
10137 public static final int FILL_IN_CLIP_DATA = 1<<7;
10138
10139 /**
10140 * Use with {@link #fillIn} to allow the current identifier value to be
10141 * overwritten, even if it is already set.
10142 */
10143 public static final int FILL_IN_IDENTIFIER = 1<<8;
10144
10145 /**
10146 * Copy the contents of <var>other</var> in to this object, but only
10147 * where fields are not defined by this object. For purposes of a field
10148 * being defined, the following pieces of data in the Intent are
10149 * considered to be separate fields:
10150 *
10151 * <ul>
10152 * <li> action, as set by {@link #setAction}.
10153 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
10154 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
10155 * <li> identifier, as set by {@link #setIdentifier}.
10156 * <li> categories, as set by {@link #addCategory}.
10157 * <li> package, as set by {@link #setPackage}.
10158 * <li> component, as set by {@link #setComponent(ComponentName)} or
10159 * related methods.
10160 * <li> source bounds, as set by {@link #setSourceBounds}.
10161 * <li> selector, as set by {@link #setSelector(Intent)}.
10162 * <li> clip data, as set by {@link #setClipData(ClipData)}.
10163 * <li> each top-level name in the associated extras.
10164 * </ul>
10165 *
10166 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
10167 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES},
10168 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10169 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
10170 * the restriction where the corresponding field will not be replaced if
10171 * it is already set.
10172 *
10173 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
10174 * is explicitly specified. The selector will only be copied if
10175 * {@link #FILL_IN_SELECTOR} is explicitly specified.
10176 *
10177 * <p>For example, consider Intent A with {data="foo", categories="bar"}
10178 * and Intent B with {action="gotit", data-type="some/thing",
10179 * categories="one","two"}.
10180 *
10181 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
10182 * containing: {action="gotit", data-type="some/thing",
10183 * categories="bar"}.
10184 *
10185 * @param other Another Intent whose values are to be used to fill in
10186 * the current one.
10187 * @param flags Options to control which fields can be filled in.
10188 *
10189 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
10190 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
10191 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10192 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
10193 * changed.
10194 */
10195 @FillInFlags
10196 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
10197 int changes = 0;
10198 boolean mayHaveCopiedUris = false;
10199 if (other.mAction != null
10200 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
10201 mAction = other.mAction;
10202 changes |= FILL_IN_ACTION;
10203 }
10204 if ((other.mData != null || other.mType != null)
10205 && ((mData == null && mType == null)
10206 || (flags&FILL_IN_DATA) != 0)) {
10207 mData = other.mData;
10208 mType = other.mType;
10209 changes |= FILL_IN_DATA;
10210 mayHaveCopiedUris = true;
10211 }
10212 if (other.mIdentifier != null
10213 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) {
10214 mIdentifier = other.mIdentifier;
10215 changes |= FILL_IN_IDENTIFIER;
10216 }
10217 if (other.mCategories != null
10218 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
10219 if (other.mCategories != null) {
10220 mCategories = new ArraySet<String>(other.mCategories);
10221 }
10222 changes |= FILL_IN_CATEGORIES;
10223 }
10224 if (other.mPackage != null
10225 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
10226 // Only do this if mSelector is not set.
10227 if (mSelector == null) {
10228 mPackage = other.mPackage;
10229 changes |= FILL_IN_PACKAGE;
10230 }
10231 }
10232 // Selector is special: it can only be set if explicitly allowed,
10233 // for the same reason as the component name.
10234 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
10235 if (mPackage == null) {
10236 mSelector = new Intent(other.mSelector);
10237 mPackage = null;
10238 changes |= FILL_IN_SELECTOR;
10239 }
10240 }
10241 if (other.mClipData != null
10242 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
10243 mClipData = other.mClipData;
10244 changes |= FILL_IN_CLIP_DATA;
10245 mayHaveCopiedUris = true;
10246 }
10247 // Component is special: it can -only- be set if explicitly allowed,
10248 // since otherwise the sender could force the intent somewhere the
10249 // originator didn't intend.
10250 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
10251 mComponent = other.mComponent;
10252 changes |= FILL_IN_COMPONENT;
10253 }
10254 mFlags |= other.mFlags;
10255 if (other.mSourceBounds != null
10256 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
10257 mSourceBounds = new Rect(other.mSourceBounds);
10258 changes |= FILL_IN_SOURCE_BOUNDS;
10259 }
10260 if (mExtras == null) {
10261 if (other.mExtras != null) {
10262 mExtras = new Bundle(other.mExtras);
10263 mayHaveCopiedUris = true;
10264 }
10265 } else if (other.mExtras != null) {
10266 try {
10267 Bundle newb = new Bundle(other.mExtras);
10268 newb.putAll(mExtras);
10269 mExtras = newb;
10270 mayHaveCopiedUris = true;
10271 } catch (RuntimeException e) {
10272 // Modifying the extras can cause us to unparcel the contents
10273 // of the bundle, and if we do this in the system process that
10274 // may fail. We really should handle this (i.e., the Bundle
10275 // impl shouldn't be on top of a plain map), but for now just
10276 // ignore it and keep the original contents. :(
10277 Log.w(TAG, "Failure filling in extras", e);
10278 }
10279 }
10280 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
10281 && other.mContentUserHint != UserHandle.USER_CURRENT) {
10282 mContentUserHint = other.mContentUserHint;
10283 }
10284 return changes;
10285 }
10286
10287 /**
10288 * Wrapper class holding an Intent and implementing comparisons on it for
10289 * the purpose of filtering. The class implements its
10290 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
10291 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
10292 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
10293 * on the wrapped Intent.
10294 */
10295 public static final class FilterComparison {
10296 private final Intent mIntent;
10297 private final int mHashCode;
10298
10299 public FilterComparison(Intent intent) {
10300 mIntent = intent;
10301 mHashCode = intent.filterHashCode();
10302 }
10303
10304 /**
10305 * Return the Intent that this FilterComparison represents.
10306 * @return Returns the Intent held by the FilterComparison. Do
10307 * not modify!
10308 */
10309 public Intent getIntent() {
10310 return mIntent;
10311 }
10312
10313 @Override
10314 public boolean equals(Object obj) {
10315 if (obj instanceof FilterComparison) {
10316 Intent other = ((FilterComparison)obj).mIntent;
10317 return mIntent.filterEquals(other);
10318 }
10319 return false;
10320 }
10321
10322 @Override
10323 public int hashCode() {
10324 return mHashCode;
10325 }
10326 }
10327
10328 /**
10329 * Determine if two intents are the same for the purposes of intent
10330 * resolution (filtering). That is, if their action, data, type, identity,
10331 * class, and categories are the same. This does <em>not</em> compare
10332 * any extra data included in the intents. Note that technically when actually
10333 * matching against an {@link IntentFilter} the identifier is ignored, while here
10334 * it is directly compared for equality like the other fields.
10335 *
10336 * @param other The other Intent to compare against.
10337 *
10338 * @return Returns true if action, data, type, class, and categories
10339 * are the same.
10340 */
10341 public boolean filterEquals(Intent other) {
10342 if (other == null) {
10343 return false;
10344 }
10345 if (!Objects.equals(this.mAction, other.mAction)) return false;
10346 if (!Objects.equals(this.mData, other.mData)) return false;
10347 if (!Objects.equals(this.mType, other.mType)) return false;
10348 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false;
10349 if (!(this.hasPackageEquivalentComponent() && other.hasPackageEquivalentComponent())
10350 && !Objects.equals(this.mPackage, other.mPackage)) {
10351 return false;
10352 }
10353 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
10354 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
10355
10356 return true;
10357 }
10358
10359 /**
10360 * Return {@code true} if the component name is not null and is in the same package that this
10361 * intent limited to. otherwise return {@code false}.
10362 */
10363 private boolean hasPackageEquivalentComponent() {
10364 return mComponent != null
10365 && (mPackage == null || mPackage.equals(mComponent.getPackageName()));
10366 }
10367
10368 /**
10369 * Generate hash code that matches semantics of filterEquals().
10370 *
10371 * @return Returns the hash value of the action, data, type, class, and
10372 * categories.
10373 *
10374 * @see #filterEquals
10375 */
10376 public int filterHashCode() {
10377 int code = 0;
10378 if (mAction != null) {
10379 code += mAction.hashCode();
10380 }
10381 if (mData != null) {
10382 code += mData.hashCode();
10383 }
10384 if (mType != null) {
10385 code += mType.hashCode();
10386 }
10387 if (mIdentifier != null) {
10388 code += mIdentifier.hashCode();
10389 }
10390 if (mPackage != null) {
10391 code += mPackage.hashCode();
10392 }
10393 if (mComponent != null) {
10394 code += mComponent.hashCode();
10395 }
10396 if (mCategories != null) {
10397 code += mCategories.hashCode();
10398 }
10399 return code;
10400 }
10401
10402 @Override
10403 public String toString() {
10404 StringBuilder b = new StringBuilder(128);
10405
10406 b.append("Intent { ");
10407 toShortString(b, true, true, true, false);
10408 b.append(" }");
10409
10410 return b.toString();
10411 }
10412
10413 /** @hide */
10414 @UnsupportedAppUsage
10415 public String toInsecureString() {
10416 StringBuilder b = new StringBuilder(128);
10417
10418 b.append("Intent { ");
10419 toShortString(b, false, true, true, false);
10420 b.append(" }");
10421
10422 return b.toString();
10423 }
10424
10425 /** @hide */
10426 public String toInsecureStringWithClip() {
10427 StringBuilder b = new StringBuilder(128);
10428
10429 b.append("Intent { ");
10430 toShortString(b, false, true, true, true);
10431 b.append(" }");
10432
10433 return b.toString();
10434 }
10435
10436 /** @hide */
10437 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
10438 StringBuilder b = new StringBuilder(128);
10439 toShortString(b, secure, comp, extras, clip);
10440 return b.toString();
10441 }
10442
10443 /** @hide */
10444 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
10445 boolean clip) {
10446 boolean first = true;
10447 if (mAction != null) {
10448 b.append("act=").append(mAction);
10449 first = false;
10450 }
10451 if (mCategories != null) {
10452 if (!first) {
10453 b.append(' ');
10454 }
10455 first = false;
10456 b.append("cat=[");
10457 for (int i=0; i<mCategories.size(); i++) {
10458 if (i > 0) b.append(',');
10459 b.append(mCategories.valueAt(i));
10460 }
10461 b.append("]");
10462 }
10463 if (mData != null) {
10464 if (!first) {
10465 b.append(' ');
10466 }
10467 first = false;
10468 b.append("dat=");
10469 if (secure) {
10470 b.append(mData.toSafeString());
10471 } else {
10472 b.append(mData);
10473 }
10474 }
10475 if (mType != null) {
10476 if (!first) {
10477 b.append(' ');
10478 }
10479 first = false;
10480 b.append("typ=").append(mType);
10481 }
10482 if (mIdentifier != null) {
10483 if (!first) {
10484 b.append(' ');
10485 }
10486 first = false;
10487 b.append("id=").append(mIdentifier);
10488 }
10489 if (mFlags != 0) {
10490 if (!first) {
10491 b.append(' ');
10492 }
10493 first = false;
10494 b.append("flg=0x").append(Integer.toHexString(mFlags));
10495 }
10496 if (mPackage != null) {
10497 if (!first) {
10498 b.append(' ');
10499 }
10500 first = false;
10501 b.append("pkg=").append(mPackage);
10502 }
10503 if (comp && mComponent != null) {
10504 if (!first) {
10505 b.append(' ');
10506 }
10507 first = false;
10508 b.append("cmp=").append(mComponent.flattenToShortString());
10509 }
10510 if (mSourceBounds != null) {
10511 if (!first) {
10512 b.append(' ');
10513 }
10514 first = false;
10515 b.append("bnds=").append(mSourceBounds.toShortString());
10516 }
10517 if (mClipData != null) {
10518 if (!first) {
10519 b.append(' ');
10520 }
10521 b.append("clip={");
10522 if (clip) {
10523 mClipData.toShortString(b);
10524 } else {
10525 if (mClipData.getDescription() != null) {
10526 first = !mClipData.getDescription().toShortStringTypesOnly(b);
10527 } else {
10528 first = true;
10529 }
10530 mClipData.toShortStringShortItems(b, first);
10531 }
10532 first = false;
10533 b.append('}');
10534 }
10535 if (extras && mExtras != null) {
10536 if (!first) {
10537 b.append(' ');
10538 }
10539 first = false;
10540 b.append("(has extras)");
10541 }
10542 if (mContentUserHint != UserHandle.USER_CURRENT) {
10543 if (!first) {
10544 b.append(' ');
10545 }
10546 first = false;
10547 b.append("u=").append(mContentUserHint);
10548 }
10549 if (mSelector != null) {
10550 b.append(" sel=");
10551 mSelector.toShortString(b, secure, comp, extras, clip);
10552 b.append("}");
10553 }
10554 }
10555
10556 /** @hide */
10557 public void dumpDebug(ProtoOutputStream proto, long fieldId) {
10558 // Same input parameters that toString() gives to toShortString().
10559 dumpDebug(proto, fieldId, true, true, true, false);
10560 }
10561
10562 /** @hide */
10563 public void dumpDebug(ProtoOutputStream proto) {
10564 // Same input parameters that toString() gives to toShortString().
10565 dumpDebugWithoutFieldId(proto, true, true, true, false);
10566 }
10567
10568 /** @hide */
10569 public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
10570 boolean extras, boolean clip) {
10571 long token = proto.start(fieldId);
10572 dumpDebugWithoutFieldId(proto, secure, comp, extras, clip);
10573 proto.end(token);
10574 }
10575
10576 private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
10577 boolean extras, boolean clip) {
10578 if (mAction != null) {
10579 proto.write(IntentProto.ACTION, mAction);
10580 }
10581 if (mCategories != null) {
10582 for (String category : mCategories) {
10583 proto.write(IntentProto.CATEGORIES, category);
10584 }
10585 }
10586 if (mData != null) {
10587 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
10588 }
10589 if (mType != null) {
10590 proto.write(IntentProto.TYPE, mType);
10591 }
10592 if (mIdentifier != null) {
10593 proto.write(IntentProto.IDENTIFIER, mIdentifier);
10594 }
10595 if (mFlags != 0) {
10596 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
10597 }
10598 if (mPackage != null) {
10599 proto.write(IntentProto.PACKAGE, mPackage);
10600 }
10601 if (comp && mComponent != null) {
10602 mComponent.dumpDebug(proto, IntentProto.COMPONENT);
10603 }
10604 if (mSourceBounds != null) {
10605 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
10606 }
10607 if (mClipData != null) {
10608 StringBuilder b = new StringBuilder();
10609 if (clip) {
10610 mClipData.toShortString(b);
10611 } else {
10612 mClipData.toShortStringShortItems(b, false);
10613 }
10614 proto.write(IntentProto.CLIP_DATA, b.toString());
10615 }
10616 if (extras && mExtras != null) {
10617 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
10618 }
10619 if (mContentUserHint != 0) {
10620 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
10621 }
10622 if (mSelector != null) {
10623 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
10624 }
10625 }
10626
10627 /**
10628 * Call {@link #toUri} with 0 flags.
10629 * @deprecated Use {@link #toUri} instead.
10630 */
10631 @Deprecated
10632 public String toURI() {
10633 return toUri(0);
10634 }
10635
10636 /**
10637 * Convert this Intent into a String holding a URI representation of it.
10638 * The returned URI string has been properly URI encoded, so it can be
10639 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
10640 * Intent's data as the base URI, with an additional fragment describing
10641 * the action, categories, type, flags, package, component, and extras.
10642 *
10643 * <p>You can convert the returned string back to an Intent with
10644 * {@link #getIntent}.
10645 *
10646 * @param flags Additional operating flags.
10647 *
10648 * @return Returns a URI encoding URI string describing the entire contents
10649 * of the Intent.
10650 */
10651 public String toUri(@UriFlags int flags) {
10652 StringBuilder uri = new StringBuilder(128);
10653 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
10654 if (mPackage == null) {
10655 throw new IllegalArgumentException(
10656 "Intent must include an explicit package name to build an android-app: "
10657 + this);
10658 }
10659 uri.append("android-app://");
10660 uri.append(mPackage);
10661 String scheme = null;
10662 if (mData != null) {
10663 scheme = mData.getScheme();
10664 if (scheme != null) {
10665 uri.append('/');
10666 uri.append(scheme);
10667 String authority = mData.getEncodedAuthority();
10668 if (authority != null) {
10669 uri.append('/');
10670 uri.append(authority);
10671 String path = mData.getEncodedPath();
10672 if (path != null) {
10673 uri.append(path);
10674 }
10675 String queryParams = mData.getEncodedQuery();
10676 if (queryParams != null) {
10677 uri.append('?');
10678 uri.append(queryParams);
10679 }
10680 String fragment = mData.getEncodedFragment();
10681 if (fragment != null) {
10682 uri.append('#');
10683 uri.append(fragment);
10684 }
10685 }
10686 }
10687 }
10688 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
10689 mPackage, flags);
10690 return uri.toString();
10691 }
10692 String scheme = null;
10693 if (mData != null) {
10694 String data = mData.toString();
10695 if ((flags&URI_INTENT_SCHEME) != 0) {
10696 final int N = data.length();
10697 for (int i=0; i<N; i++) {
10698 char c = data.charAt(i);
10699 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
10700 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
10701 continue;
10702 }
10703 if (c == ':' && i > 0) {
10704 // Valid scheme.
10705 scheme = data.substring(0, i);
10706 uri.append("intent:");
10707 data = data.substring(i+1);
10708 break;
10709 }
10710
10711 // No scheme.
10712 break;
10713 }
10714 }
10715 uri.append(data);
10716
10717 } else if ((flags&URI_INTENT_SCHEME) != 0) {
10718 uri.append("intent:");
10719 }
10720
10721 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
10722
10723 return uri.toString();
10724 }
10725
10726 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
10727 String defPackage, int flags) {
10728 StringBuilder frag = new StringBuilder(128);
10729
10730 toUriInner(frag, scheme, defAction, defPackage, flags);
10731 if (mSelector != null) {
10732 frag.append("SEL;");
10733 // Note that for now we are not going to try to handle the
10734 // data part; not clear how to represent this as a URI, and
10735 // not much utility in it.
10736 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
10737 null, null, flags);
10738 }
10739
10740 if (frag.length() > 0) {
10741 uri.append("#Intent;");
10742 uri.append(frag);
10743 uri.append("end");
10744 }
10745 }
10746
10747 private void toUriInner(StringBuilder uri, String scheme, String defAction,
10748 String defPackage, int flags) {
10749 if (scheme != null) {
10750 uri.append("scheme=").append(scheme).append(';');
10751 }
10752 if (mAction != null && !mAction.equals(defAction)) {
10753 uri.append("action=").append(Uri.encode(mAction)).append(';');
10754 }
10755 if (mCategories != null) {
10756 for (int i=0; i<mCategories.size(); i++) {
10757 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
10758 }
10759 }
10760 if (mType != null) {
10761 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
10762 }
10763 if (mIdentifier != null) {
10764 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';');
10765 }
10766 if (mFlags != 0) {
10767 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
10768 }
10769 if (mPackage != null && !mPackage.equals(defPackage)) {
10770 uri.append("package=").append(Uri.encode(mPackage)).append(';');
10771 }
10772 if (mComponent != null) {
10773 uri.append("component=").append(Uri.encode(
10774 mComponent.flattenToShortString(), "/")).append(';');
10775 }
10776 if (mSourceBounds != null) {
10777 uri.append("sourceBounds=")
10778 .append(Uri.encode(mSourceBounds.flattenToString()))
10779 .append(';');
10780 }
10781 if (mExtras != null) {
10782 for (String key : mExtras.keySet()) {
10783 final Object value = mExtras.get(key);
10784 char entryType =
10785 value instanceof String ? 'S' :
10786 value instanceof Boolean ? 'B' :
10787 value instanceof Byte ? 'b' :
10788 value instanceof Character ? 'c' :
10789 value instanceof Double ? 'd' :
10790 value instanceof Float ? 'f' :
10791 value instanceof Integer ? 'i' :
10792 value instanceof Long ? 'l' :
10793 value instanceof Short ? 's' :
10794 '\0';
10795
10796 if (entryType != '\0') {
10797 uri.append(entryType);
10798 uri.append('.');
10799 uri.append(Uri.encode(key));
10800 uri.append('=');
10801 uri.append(Uri.encode(value.toString()));
10802 uri.append(';');
10803 }
10804 }
10805 }
10806 }
10807
10808 public int describeContents() {
10809 return (mExtras != null) ? mExtras.describeContents() : 0;
10810 }
10811
10812 public void writeToParcel(Parcel out, int flags) {
10813 out.writeString8(mAction);
10814 Uri.writeToParcel(out, mData);
10815 out.writeString8(mType);
10816 out.writeString8(mIdentifier);
10817 out.writeInt(mFlags);
10818 out.writeString8(mPackage);
10819 ComponentName.writeToParcel(mComponent, out);
10820
10821 if (mSourceBounds != null) {
10822 out.writeInt(1);
10823 mSourceBounds.writeToParcel(out, flags);
10824 } else {
10825 out.writeInt(0);
10826 }
10827
10828 if (mCategories != null) {
10829 final int N = mCategories.size();
10830 out.writeInt(N);
10831 for (int i=0; i<N; i++) {
10832 out.writeString8(mCategories.valueAt(i));
10833 }
10834 } else {
10835 out.writeInt(0);
10836 }
10837
10838 if (mSelector != null) {
10839 out.writeInt(1);
10840 mSelector.writeToParcel(out, flags);
10841 } else {
10842 out.writeInt(0);
10843 }
10844
10845 if (mClipData != null) {
10846 out.writeInt(1);
10847 mClipData.writeToParcel(out, flags);
10848 } else {
10849 out.writeInt(0);
10850 }
10851 out.writeInt(mContentUserHint);
10852 out.writeBundle(mExtras);
10853 }
10854
10855 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR
10856 = new Parcelable.Creator<Intent>() {
10857 public Intent createFromParcel(Parcel in) {
10858 return new Intent(in);
10859 }
10860 public Intent[] newArray(int size) {
10861 return new Intent[size];
10862 }
10863 };
10864
10865 /** @hide */
10866 protected Intent(Parcel in) {
10867 readFromParcel(in);
10868 }
10869
10870 public void readFromParcel(Parcel in) {
10871 setAction(in.readString8());
10872 mData = Uri.CREATOR.createFromParcel(in);
10873 mType = in.readString8();
10874 mIdentifier = in.readString8();
10875 mFlags = in.readInt();
10876 mPackage = in.readString8();
10877 mComponent = ComponentName.readFromParcel(in);
10878
10879 if (in.readInt() != 0) {
10880 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10881 }
10882
10883 int N = in.readInt();
10884 if (N > 0) {
10885 mCategories = new ArraySet<String>();
10886 int i;
10887 for (i=0; i<N; i++) {
10888 mCategories.add(in.readString8().intern());
10889 }
10890 } else {
10891 mCategories = null;
10892 }
10893
10894 if (in.readInt() != 0) {
10895 mSelector = new Intent(in);
10896 }
10897
10898 if (in.readInt() != 0) {
10899 mClipData = new ClipData(in);
10900 }
10901 mContentUserHint = in.readInt();
10902 mExtras = in.readBundle();
10903 }
10904
10905 /**
10906 * Parses the "intent" element (and its children) from XML and instantiates
10907 * an Intent object. The given XML parser should be located at the tag
10908 * where parsing should start (often named "intent"), from which the
10909 * basic action, data, type, and package and class name will be
10910 * retrieved. The function will then parse in to any child elements,
10911 * looking for <category android:name="xxx"> tags to add categories and
10912 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10913 * to the intent.
10914 *
10915 * @param resources The Resources to use when inflating resources.
10916 * @param parser The XML parser pointing at an "intent" tag.
10917 * @param attrs The AttributeSet interface for retrieving extended
10918 * attribute data at the current <var>parser</var> location.
10919 * @return An Intent object matching the XML data.
10920 * @throws XmlPullParserException If there was an XML parsing error.
10921 * @throws IOException If there was an I/O error.
10922 */
10923 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10924 @NonNull XmlPullParser parser, AttributeSet attrs)
10925 throws XmlPullParserException, IOException {
10926 Intent intent = new Intent();
10927
10928 TypedArray sa = resources.obtainAttributes(attrs,
10929 com.android.internal.R.styleable.Intent);
10930
10931 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10932
10933 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10934 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10935 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10936
10937 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier));
10938
10939 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10940 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10941 if (packageName != null && className != null) {
10942 intent.setComponent(new ComponentName(packageName, className));
10943 }
10944
10945 sa.recycle();
10946
10947 int outerDepth = parser.getDepth();
10948 int type;
10949 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10950 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10951 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10952 continue;
10953 }
10954
10955 String nodeName = parser.getName();
10956 if (nodeName.equals(TAG_CATEGORIES)) {
10957 sa = resources.obtainAttributes(attrs,
10958 com.android.internal.R.styleable.IntentCategory);
10959 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10960 sa.recycle();
10961
10962 if (cat != null) {
10963 intent.addCategory(cat);
10964 }
10965 XmlUtils.skipCurrentTag(parser);
10966
10967 } else if (nodeName.equals(TAG_EXTRA)) {
10968 if (intent.mExtras == null) {
10969 intent.mExtras = new Bundle();
10970 }
10971 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
10972 XmlUtils.skipCurrentTag(parser);
10973
10974 } else {
10975 XmlUtils.skipCurrentTag(parser);
10976 }
10977 }
10978
10979 return intent;
10980 }
10981
10982 /** @hide */
10983 public void saveToXml(XmlSerializer out) throws IOException {
10984 if (mAction != null) {
10985 out.attribute(null, ATTR_ACTION, mAction);
10986 }
10987 if (mData != null) {
10988 out.attribute(null, ATTR_DATA, mData.toString());
10989 }
10990 if (mType != null) {
10991 out.attribute(null, ATTR_TYPE, mType);
10992 }
10993 if (mIdentifier != null) {
10994 out.attribute(null, ATTR_IDENTIFIER, mIdentifier);
10995 }
10996 if (mComponent != null) {
10997 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10998 }
10999 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
11000
11001 if (mCategories != null) {
11002 out.startTag(null, TAG_CATEGORIES);
11003 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
11004 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
11005 }
11006 out.endTag(null, TAG_CATEGORIES);
11007 }
11008 }
11009
11010 /** @hide */
11011 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
11012 XmlPullParserException {
11013 Intent intent = new Intent();
11014 final int outerDepth = in.getDepth();
11015
11016 int attrCount = in.getAttributeCount();
11017 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11018 final String attrName = in.getAttributeName(attrNdx);
11019 final String attrValue = in.getAttributeValue(attrNdx);
11020 if (ATTR_ACTION.equals(attrName)) {
11021 intent.setAction(attrValue);
11022 } else if (ATTR_DATA.equals(attrName)) {
11023 intent.setData(Uri.parse(attrValue));
11024 } else if (ATTR_TYPE.equals(attrName)) {
11025 intent.setType(attrValue);
11026 } else if (ATTR_IDENTIFIER.equals(attrName)) {
11027 intent.setIdentifier(attrValue);
11028 } else if (ATTR_COMPONENT.equals(attrName)) {
11029 intent.setComponent(ComponentName.unflattenFromString(attrValue));
11030 } else if (ATTR_FLAGS.equals(attrName)) {
11031 intent.setFlags(Integer.parseInt(attrValue, 16));
11032 } else {
11033 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
11034 }
11035 }
11036
11037 int event;
11038 String name;
11039 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
11040 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
11041 if (event == XmlPullParser.START_TAG) {
11042 name = in.getName();
11043 if (TAG_CATEGORIES.equals(name)) {
11044 attrCount = in.getAttributeCount();
11045 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11046 intent.addCategory(in.getAttributeValue(attrNdx));
11047 }
11048 } else {
11049 Log.w(TAG, "restoreFromXml: unknown name=" + name);
11050 XmlUtils.skipCurrentTag(in);
11051 }
11052 }
11053 }
11054
11055 return intent;
11056 }
11057
11058 /**
11059 * Normalize a MIME data type.
11060 *
11061 * <p>A normalized MIME type has white-space trimmed,
11062 * content-type parameters removed, and is lower-case.
11063 * This aligns the type with Android best practices for
11064 * intent filtering.
11065 *
11066 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
11067 * "text/x-vCard" becomes "text/x-vcard".
11068 *
11069 * <p>All MIME types received from outside Android (such as user input,
11070 * or external sources like Bluetooth, NFC, or the Internet) should
11071 * be normalized before they are used to create an Intent.
11072 *
11073 * @param type MIME data type to normalize
11074 * @return normalized MIME data type, or null if the input was null
11075 * @see #setType
11076 * @see #setTypeAndNormalize
11077 */
11078 public static @Nullable String normalizeMimeType(@Nullable String type) {
11079 if (type == null) {
11080 return null;
11081 }
11082
11083 type = type.trim().toLowerCase(Locale.ROOT);
11084
11085 final int semicolonIndex = type.indexOf(';');
11086 if (semicolonIndex != -1) {
11087 type = type.substring(0, semicolonIndex);
11088 }
11089 return type;
11090 }
11091
11092 /**
11093 * Prepare this {@link Intent} to leave an app process.
11094 *
11095 * @hide
11096 */
11097 @UnsupportedAppUsage
11098 public void prepareToLeaveProcess(Context context) {
11099 final boolean leavingPackage = (mComponent == null)
11100 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
11101 prepareToLeaveProcess(leavingPackage);
11102 }
11103
11104 /**
11105 * Prepare this {@link Intent} to leave an app process.
11106 *
11107 * @hide
11108 */
11109 public void prepareToLeaveProcess(boolean leavingPackage) {
11110 setAllowFds(false);
11111
11112 if (mSelector != null) {
11113 mSelector.prepareToLeaveProcess(leavingPackage);
11114 }
11115 if (mClipData != null) {
11116 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
11117 }
11118
11119 if (mExtras != null && !mExtras.isParcelled()) {
11120 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
11121 if (intent instanceof Intent) {
11122 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
11123 }
11124 }
11125
11126 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
11127 && leavingPackage) {
11128 switch (mAction) {
11129 case ACTION_MEDIA_REMOVED:
11130 case ACTION_MEDIA_UNMOUNTED:
11131 case ACTION_MEDIA_CHECKING:
11132 case ACTION_MEDIA_NOFS:
11133 case ACTION_MEDIA_MOUNTED:
11134 case ACTION_MEDIA_SHARED:
11135 case ACTION_MEDIA_UNSHARED:
11136 case ACTION_MEDIA_BAD_REMOVAL:
11137 case ACTION_MEDIA_UNMOUNTABLE:
11138 case ACTION_MEDIA_EJECT:
11139 case ACTION_MEDIA_SCANNER_STARTED:
11140 case ACTION_MEDIA_SCANNER_FINISHED:
11141 case ACTION_MEDIA_SCANNER_SCAN_FILE:
11142 case ACTION_PACKAGE_NEEDS_VERIFICATION:
11143 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION:
11144 case ACTION_PACKAGE_VERIFIED:
11145 case ACTION_PACKAGE_ENABLE_ROLLBACK:
11146 // Ignore legacy actions
11147 break;
11148 default:
11149 mData.checkFileUriExposed("Intent.getData()");
11150 }
11151 }
11152
11153 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
11154 && leavingPackage) {
11155 switch (mAction) {
11156 case ACTION_PROVIDER_CHANGED:
11157 case QuickContact.ACTION_QUICK_CONTACT:
11158 // Ignore actions that don't need to grant
11159 break;
11160 default:
11161 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
11162 }
11163 }
11164
11165 // Translate raw filesystem paths out of storage sandbox
11166 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
11167 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
11168 final StorageManager sm = AppGlobals.getInitialApplication()
11169 .getSystemService(StorageManager.class);
11170 final File before = new File(mData.getPath());
11171 final File after = sm.translateAppToSystem(before,
11172 android.os.Process.myPid(), android.os.Process.myUid());
11173 if (!Objects.equals(before, after)) {
11174 Log.v(TAG, "Translated " + before + " to " + after);
11175 mData = Uri.fromFile(after);
11176 }
11177 }
11178 }
11179
11180 /**
11181 * @hide
11182 */
11183 public void prepareToEnterProcess() {
11184 // We just entered destination process, so we should be able to read all
11185 // parcelables inside.
11186 setDefusable(true);
11187
11188 if (mSelector != null) {
11189 mSelector.prepareToEnterProcess();
11190 }
11191 if (mClipData != null) {
11192 mClipData.prepareToEnterProcess();
11193 }
11194
11195 if (mContentUserHint != UserHandle.USER_CURRENT) {
11196 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
11197 fixUris(mContentUserHint);
11198 mContentUserHint = UserHandle.USER_CURRENT;
11199 }
11200 }
11201 }
11202
11203 /** @hide */
11204 public boolean hasWebURI() {
11205 if (getData() == null) {
11206 return false;
11207 }
11208 final String scheme = getScheme();
11209 if (TextUtils.isEmpty(scheme)) {
11210 return false;
11211 }
11212 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
11213 }
11214
11215 /** @hide */
11216 public boolean isWebIntent() {
11217 return ACTION_VIEW.equals(mAction)
11218 && hasWebURI();
11219 }
11220
11221 private boolean isImageCaptureIntent() {
11222 return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction)
11223 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction)
11224 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction));
11225 }
11226
11227 /** @hide */
11228 public boolean isImplicitImageCaptureIntent() {
11229 return mPackage == null && mComponent == null && isImageCaptureIntent();
11230 }
11231
11232 /**
11233 * @hide
11234 */
11235 public void fixUris(int contentUserHint) {
11236 Uri data = getData();
11237 if (data != null) {
11238 mData = maybeAddUserId(data, contentUserHint);
11239 }
11240 if (mClipData != null) {
11241 mClipData.fixUris(contentUserHint);
11242 }
11243 String action = getAction();
11244 if (ACTION_SEND.equals(action)) {
11245 final Uri stream = getParcelableExtra(EXTRA_STREAM);
11246 if (stream != null) {
11247 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
11248 }
11249 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
11250 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
11251 if (streams != null) {
11252 ArrayList<Uri> newStreams = new ArrayList<Uri>();
11253 for (int i = 0; i < streams.size(); i++) {
11254 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
11255 }
11256 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
11257 }
11258 } else if (isImageCaptureIntent()) {
11259 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11260 if (output != null) {
11261 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
11262 }
11263 }
11264 }
11265
11266 /**
11267 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
11268 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
11269 * intents in {@link #ACTION_CHOOSER}.
11270 *
11271 * @return Whether any contents were migrated.
11272 * @hide
11273 */
11274 public boolean migrateExtraStreamToClipData() {
11275 // Refuse to touch if extras already parcelled
11276 if (mExtras != null && mExtras.isParcelled()) return false;
11277
11278 // Bail when someone already gave us ClipData
11279 if (getClipData() != null) return false;
11280
11281 final String action = getAction();
11282 if (ACTION_CHOOSER.equals(action)) {
11283 // Inspect contained intents to see if we need to migrate extras. We
11284 // don't promote ClipData to the parent, since ChooserActivity will
11285 // already start the picked item as the caller, and we can't combine
11286 // the flags in a safe way.
11287
11288 boolean migrated = false;
11289 try {
11290 final Intent intent = getParcelableExtra(EXTRA_INTENT);
11291 if (intent != null) {
11292 migrated |= intent.migrateExtraStreamToClipData();
11293 }
11294 } catch (ClassCastException e) {
11295 }
11296 try {
11297 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
11298 if (intents != null) {
11299 for (int i = 0; i < intents.length; i++) {
11300 final Intent intent = (Intent) intents[i];
11301 if (intent != null) {
11302 migrated |= intent.migrateExtraStreamToClipData();
11303 }
11304 }
11305 }
11306 } catch (ClassCastException e) {
11307 }
11308 return migrated;
11309
11310 } else if (ACTION_SEND.equals(action)) {
11311 try {
11312 final Uri stream = getParcelableExtra(EXTRA_STREAM);
11313 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
11314 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
11315 if (stream != null || text != null || htmlText != null) {
11316 final ClipData clipData = new ClipData(
11317 null, new String[] { getType() },
11318 new ClipData.Item(text, htmlText, null, stream));
11319 setClipData(clipData);
11320 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
11321 return true;
11322 }
11323 } catch (ClassCastException e) {
11324 }
11325
11326 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
11327 try {
11328 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
11329 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
11330 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
11331 int num = -1;
11332 if (streams != null) {
11333 num = streams.size();
11334 }
11335 if (texts != null) {
11336 if (num >= 0 && num != texts.size()) {
11337 // Wha...! F- you.
11338 return false;
11339 }
11340 num = texts.size();
11341 }
11342 if (htmlTexts != null) {
11343 if (num >= 0 && num != htmlTexts.size()) {
11344 // Wha...! F- you.
11345 return false;
11346 }
11347 num = htmlTexts.size();
11348 }
11349 if (num > 0) {
11350 final ClipData clipData = new ClipData(
11351 null, new String[] { getType() },
11352 makeClipItem(streams, texts, htmlTexts, 0));
11353
11354 for (int i = 1; i < num; i++) {
11355 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
11356 }
11357
11358 setClipData(clipData);
11359 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
11360 return true;
11361 }
11362 } catch (ClassCastException e) {
11363 }
11364 } else if (isImageCaptureIntent()) {
11365 final Uri output;
11366 try {
11367 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11368 } catch (ClassCastException e) {
11369 return false;
11370 }
11371 if (output != null) {
11372 setClipData(ClipData.newRawUri("", output));
11373 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
11374 return true;
11375 }
11376 }
11377
11378 return false;
11379 }
11380
11381 /**
11382 * Convert the dock state to a human readable format.
11383 * @hide
11384 */
11385 public static String dockStateToString(int dock) {
11386 switch (dock) {
11387 case EXTRA_DOCK_STATE_HE_DESK:
11388 return "EXTRA_DOCK_STATE_HE_DESK";
11389 case EXTRA_DOCK_STATE_LE_DESK:
11390 return "EXTRA_DOCK_STATE_LE_DESK";
11391 case EXTRA_DOCK_STATE_CAR:
11392 return "EXTRA_DOCK_STATE_CAR";
11393 case EXTRA_DOCK_STATE_DESK:
11394 return "EXTRA_DOCK_STATE_DESK";
11395 case EXTRA_DOCK_STATE_UNDOCKED:
11396 return "EXTRA_DOCK_STATE_UNDOCKED";
11397 default:
11398 return Integer.toString(dock);
11399 }
11400 }
11401
11402 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
11403 ArrayList<String> htmlTexts, int which) {
11404 Uri uri = streams != null ? streams.get(which) : null;
11405 CharSequence text = texts != null ? texts.get(which) : null;
11406 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
11407 return new ClipData.Item(text, htmlText, null, uri);
11408 }
11409
11410 /** @hide */
11411 public boolean isDocument() {
11412 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
11413 }
11414}