1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.content; 18 19 import static android.app.sdksandbox.SdkSandboxManager.ACTION_START_SANDBOXED_ACTIVITY; 20 import static android.content.ContentProvider.maybeAddUserId; 21 22 import android.Manifest; 23 import android.accessibilityservice.AccessibilityService; 24 import android.annotation.AnyRes; 25 import android.annotation.BroadcastBehavior; 26 import android.annotation.IntDef; 27 import android.annotation.NonNull; 28 import android.annotation.Nullable; 29 import android.annotation.RequiresPermission; 30 import android.annotation.SdkConstant; 31 import android.annotation.SdkConstant.SdkConstantType; 32 import android.annotation.SuppressLint; 33 import android.annotation.SystemApi; 34 import android.annotation.TestApi; 35 import android.app.Activity; 36 import android.app.ActivityThread; 37 import android.app.AppGlobals; 38 import android.app.StatusBarManager; 39 import android.bluetooth.BluetoothDevice; 40 import android.compat.annotation.UnsupportedAppUsage; 41 import android.content.pm.ActivityInfo; 42 import android.content.pm.ApplicationInfo; 43 import android.content.pm.ComponentInfo; 44 import android.content.pm.PackageManager; 45 import android.content.pm.ResolveInfo; 46 import android.content.pm.ShortcutInfo; 47 import android.content.pm.SuspendDialogInfo; 48 import android.content.pm.verify.domain.DomainVerificationManager; 49 import android.content.res.Resources; 50 import android.content.res.TypedArray; 51 import android.graphics.Rect; 52 import android.net.Uri; 53 import android.os.Build; 54 import android.os.Bundle; 55 import android.os.BundleMerger; 56 import android.os.IBinder; 57 import android.os.IncidentManager; 58 import android.os.Parcel; 59 import android.os.Parcelable; 60 import android.os.PersistableBundle; 61 import android.os.Process; 62 import android.os.ResultReceiver; 63 import android.os.ShellCommand; 64 import android.os.StrictMode; 65 import android.os.UserHandle; 66 import android.os.storage.StorageManager; 67 import android.provider.ContactsContract.QuickContact; 68 import android.provider.DocumentsContract; 69 import android.provider.DocumentsProvider; 70 import android.provider.MediaStore; 71 import android.provider.OpenableColumns; 72 import android.service.chooser.ChooserAction; 73 import android.telecom.PhoneAccount; 74 import android.telecom.TelecomManager; 75 import android.text.TextUtils; 76 import android.util.ArraySet; 77 import android.util.AttributeSet; 78 import android.util.Log; 79 import android.util.proto.ProtoOutputStream; 80 81 import com.android.internal.util.XmlUtils; 82 83 import org.xmlpull.v1.XmlPullParser; 84 import org.xmlpull.v1.XmlPullParserException; 85 import org.xmlpull.v1.XmlSerializer; 86 87 import java.io.File; 88 import java.io.IOException; 89 import java.io.PrintWriter; 90 import java.io.Serializable; 91 import java.lang.annotation.Retention; 92 import java.lang.annotation.RetentionPolicy; 93 import java.net.URISyntaxException; 94 import java.util.ArrayList; 95 import java.util.HashSet; 96 import java.util.List; 97 import java.util.Locale; 98 import java.util.Objects; 99 import java.util.Set; 100 import java.util.TimeZone; 101 102 /** 103 * An intent is an abstract description of an operation to be performed. It 104 * can be used with {@link Context#startActivity(Intent) startActivity} to 105 * launch an {@link android.app.Activity}, 106 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to 107 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, 108 * and {@link android.content.Context#startService} or 109 * {@link android.content.Context#bindService} to communicate with a 110 * background {@link android.app.Service}. 111 * 112 * <p>An Intent provides a facility for performing late runtime binding between the code in 113 * different applications. Its most significant use is in the launching of activities, where it 114 * can be thought of as the glue between activities. It is basically a passive data structure 115 * holding an abstract description of an action to be performed.</p> 116 * 117 * <div class="special reference"> 118 * <h3>Developer Guides</h3> 119 * <p>For information about how to create and resolve intents, read the 120 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> 121 * developer guide.</p> 122 * </div> 123 * 124 * <a name="IntentStructure"></a> 125 * <h3>Intent Structure</h3> 126 * <p>The primary pieces of information in an intent are:</p> 127 * 128 * <ul> 129 * <li> <p><b>action</b> -- The general action to be performed, such as 130 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, 131 * etc.</p> 132 * </li> 133 * <li> <p><b>data</b> -- The data to operate on, such as a person record 134 * in the contacts database, expressed as a {@link android.net.Uri}.</p> 135 * </li> 136 * </ul> 137 * 138 * 139 * <p>Some examples of action/data pairs are:</p> 140 * 141 * <ul> 142 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display 143 * information about the person whose identifier is "1".</p> 144 * </li> 145 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display 146 * the phone dialer with the person filled in.</p> 147 * </li> 148 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display 149 * the phone dialer with the given number filled in. Note how the 150 * VIEW action does what is considered the most reasonable thing for 151 * a particular URI.</p> 152 * </li> 153 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display 154 * the phone dialer with the given number filled in.</p> 155 * </li> 156 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit 157 * information about the person whose identifier is "1".</p> 158 * </li> 159 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display 160 * a list of people, which the user can browse through. This example is a 161 * typical top-level entry into the Contacts application, showing you the 162 * list of people. Selecting a particular person to view would result in a 163 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> } 164 * being used to start an activity to display that person.</p> 165 * </li> 166 * </ul> 167 * 168 * <p>In addition to these primary attributes, there are a number of secondary 169 * attributes that you can also include with an intent:</p> 170 * 171 * <ul> 172 * <li> <p><b>category</b> -- Gives additional information about the action 173 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should 174 * appear in the Launcher as a top-level application, while 175 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list 176 * of alternative actions the user can perform on a piece of data.</p> 177 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the 178 * intent data. Normally the type is inferred from the data itself. 179 * By setting this attribute, you disable that evaluation and force 180 * an explicit type.</p> 181 * <li> <p><b>component</b> -- Specifies an explicit name of a component 182 * class to use for the intent. Normally this is determined by looking 183 * at the other information in the intent (the action, data/type, and 184 * categories) and matching that with a component that can handle it. 185 * If this attribute is set then none of the evaluation is performed, 186 * and this component is used exactly as is. By specifying this attribute, 187 * all of the other Intent attributes become optional.</p> 188 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. 189 * This can be used to provide extended information to the component. 190 * For example, if we have a action to send an e-mail message, we could 191 * also include extra pieces of data here to supply a subject, body, 192 * etc.</p> 193 * </ul> 194 * 195 * <p>Here are some examples of other operations you can specify as intents 196 * using these additional parameters:</p> 197 * 198 * <ul> 199 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- 200 * Launch the home screen.</p> 201 * </li> 202 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 203 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI 204 * vnd.android.cursor.item/phone}</i></b> 205 * -- Display the list of people's phone numbers, allowing the user to 206 * browse through them and pick one and return it to the parent activity.</p> 207 * </li> 208 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 209 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> 210 * -- Display all pickers for data that can be opened with 211 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, 212 * allowing the user to pick one of them and then some data inside of it 213 * and returning the resulting URI to the caller. This can be used, 214 * for example, in an e-mail application to allow the user to pick some 215 * data to include as an attachment.</p> 216 * </li> 217 * </ul> 218 * 219 * <p>There are a variety of standard Intent action and category constants 220 * defined in the Intent class, but applications can also define their own. 221 * These strings use Java-style scoping, to ensure they are unique -- for 222 * example, the standard {@link #ACTION_VIEW} is called 223 * "android.intent.action.VIEW".</p> 224 * 225 * <p>Put together, the set of actions, data types, categories, and extra data 226 * defines a language for the system allowing for the expression of phrases 227 * such as "call john smith's cell". As applications are added to the system, 228 * they can extend this language by adding new actions, types, and categories, or 229 * they can modify the behavior of existing phrases by supplying their own 230 * activities that handle them.</p> 231 * 232 * <a name="IntentResolution"></a> 233 * <h3>Intent Resolution</h3> 234 * 235 * <p>There are two primary forms of intents you will use. 236 * 237 * <ul> 238 * <li> <p><b>Explicit Intents</b> have specified a component (via 239 * {@link #setComponent} or {@link #setClass}), which provides the exact 240 * class to be run. Often these will not include any other information, 241 * simply being a way for an application to launch various internal 242 * activities it has as the user interacts with the application. 243 * 244 * <li> <p><b>Implicit Intents</b> have not specified a component; 245 * instead, they must include enough information for the system to 246 * determine which of the available components is best to run for that 247 * intent. 248 * </ul> 249 * 250 * <p>When using implicit intents, given such an arbitrary intent we need to 251 * know what to do with it. This is handled by the process of <em>Intent 252 * resolution</em>, which maps an Intent to an {@link android.app.Activity}, 253 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or 254 * more activities/receivers) that can handle it.</p> 255 * 256 * <p>The intent resolution mechanism basically revolves around matching an 257 * Intent against all of the <intent-filter> descriptions in the 258 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} 259 * objects explicitly registered with {@link Context#registerReceiver}.) More 260 * details on this can be found in the documentation on the {@link 261 * IntentFilter} class.</p> 262 * 263 * <p>There are three pieces of information in the Intent that are used for 264 * resolution: the action, type, and category. Using this information, a query 265 * is done on the {@link PackageManager} for a component that can handle the 266 * intent. The appropriate component is determined based on the intent 267 * information supplied in the <code>AndroidManifest.xml</code> file as 268 * follows:</p> 269 * 270 * <ul> 271 * <li> <p>The <b>action</b>, if given, must be listed by the component as 272 * one it handles.</p> 273 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not 274 * already supplied in the Intent. Like the action, if a type is 275 * included in the intent (either explicitly or implicitly in its 276 * data), then this must be listed by the component as one it handles.</p> 277 * <li> For data that is not a <code>content:</code> URI and where no explicit 278 * type is included in the Intent, instead the <b>scheme</b> of the 279 * intent data (such as <code>http:</code> or <code>mailto:</code>) is 280 * considered. Again like the action, if we are matching a scheme it 281 * must be listed by the component as one it can handle. 282 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed 283 * by the activity as categories it handles. That is, if you include 284 * the categories {@link #CATEGORY_LAUNCHER} and 285 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components 286 * with an intent that lists <em>both</em> of those categories. 287 * Activities will very often need to support the 288 * {@link #CATEGORY_DEFAULT} so that they can be found by 289 * {@link Context#startActivity Context.startActivity()}.</p> 290 * </ul> 291 * 292 * <p>For example, consider the Note Pad sample application that 293 * allows a user to browse through a list of notes data and view details about 294 * individual items. Text in italics indicates places where you would replace a 295 * name with one specific to your own package.</p> 296 * 297 * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 298 * package="<i>com.android.notepad</i>"> 299 * <application android:icon="@drawable/app_notes" 300 * android:label="@string/app_name"> 301 * 302 * <provider class=".NotePadProvider" 303 * android:authorities="<i>com.google.provider.NotePad</i>" /> 304 * 305 * <activity class=".NotesList" android:label="@string/title_notes_list"> 306 * <intent-filter> 307 * <action android:name="android.intent.action.MAIN" /> 308 * <category android:name="android.intent.category.LAUNCHER" /> 309 * </intent-filter> 310 * <intent-filter> 311 * <action android:name="android.intent.action.VIEW" /> 312 * <action android:name="android.intent.action.EDIT" /> 313 * <action android:name="android.intent.action.PICK" /> 314 * <category android:name="android.intent.category.DEFAULT" /> 315 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 316 * </intent-filter> 317 * <intent-filter> 318 * <action android:name="android.intent.action.GET_CONTENT" /> 319 * <category android:name="android.intent.category.DEFAULT" /> 320 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 321 * </intent-filter> 322 * </activity> 323 * 324 * <activity class=".NoteEditor" android:label="@string/title_note"> 325 * <intent-filter android:label="@string/resolve_edit"> 326 * <action android:name="android.intent.action.VIEW" /> 327 * <action android:name="android.intent.action.EDIT" /> 328 * <category android:name="android.intent.category.DEFAULT" /> 329 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 330 * </intent-filter> 331 * 332 * <intent-filter> 333 * <action android:name="android.intent.action.INSERT" /> 334 * <category android:name="android.intent.category.DEFAULT" /> 335 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 336 * </intent-filter> 337 * 338 * </activity> 339 * 340 * <activity class=".TitleEditor" android:label="@string/title_edit_title" 341 * android:theme="@android:style/Theme.Dialog"> 342 * <intent-filter android:label="@string/resolve_title"> 343 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 344 * <category android:name="android.intent.category.DEFAULT" /> 345 * <category android:name="android.intent.category.ALTERNATIVE" /> 346 * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> 347 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 348 * </intent-filter> 349 * </activity> 350 * 351 * </application> 352 * </manifest></pre> 353 * 354 * <p>The first activity, 355 * <code>com.android.notepad.NotesList</code>, serves as our main 356 * entry into the app. It can do three things as described by its three intent 357 * templates: 358 * <ol> 359 * <li><pre> 360 * <intent-filter> 361 * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> 362 * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> 363 * </intent-filter></pre> 364 * <p>This provides a top-level entry into the NotePad application: the standard 365 * MAIN action is a main entry point (not requiring any other information in 366 * the Intent), and the LAUNCHER category says that this entry point should be 367 * listed in the application launcher.</p> 368 * <li><pre> 369 * <intent-filter> 370 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 371 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 372 * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> 373 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 374 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 375 * </intent-filter></pre> 376 * <p>This declares the things that the activity can do on a directory of 377 * notes. The type being supported is given with the <type> tag, where 378 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which 379 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can 380 * be retrieved which holds our note pad data (<code>vnd.google.note</code>). 381 * The activity allows the user to view or edit the directory of data (via 382 * the VIEW and EDIT actions), or to pick a particular note and return it 383 * to the caller (via the PICK action). Note also the DEFAULT category 384 * supplied here: this is <em>required</em> for the 385 * {@link Context#startActivity Context.startActivity} method to resolve your 386 * activity when its component name is not explicitly specified.</p> 387 * <li><pre> 388 * <intent-filter> 389 * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> 390 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 391 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 392 * </intent-filter></pre> 393 * <p>This filter describes the ability to return to the caller a note selected by 394 * the user without needing to know where it came from. The data type 395 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which 396 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can 397 * be retrieved which contains our note pad data (<code>vnd.google.note</code>). 398 * The GET_CONTENT action is similar to the PICK action, where the activity 399 * will return to its caller a piece of data selected by the user. Here, 400 * however, the caller specifies the type of data they desire instead of 401 * the type of data the user will be picking from.</p> 402 * </ol> 403 * 404 * <p>Given these capabilities, the following intents will resolve to the 405 * NotesList activity:</p> 406 * 407 * <ul> 408 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the 409 * activities that can be used as top-level entry points into an 410 * application.</p> 411 * <li> <p><b>{ action=android.app.action.MAIN, 412 * category=android.app.category.LAUNCHER }</b> is the actual intent 413 * used by the Launcher to populate its top-level list.</p> 414 * <li> <p><b>{ action=android.intent.action.VIEW 415 * data=content://com.google.provider.NotePad/notes }</b> 416 * displays a list of all the notes under 417 * "content://com.google.provider.NotePad/notes", which 418 * the user can browse through and see the details on.</p> 419 * <li> <p><b>{ action=android.app.action.PICK 420 * data=content://com.google.provider.NotePad/notes }</b> 421 * provides a list of the notes under 422 * "content://com.google.provider.NotePad/notes", from which 423 * the user can pick a note whose data URL is returned back to the caller.</p> 424 * <li> <p><b>{ action=android.app.action.GET_CONTENT 425 * type=vnd.android.cursor.item/vnd.google.note }</b> 426 * is similar to the pick action, but allows the caller to specify the 427 * kind of data they want back so that the system can find the appropriate 428 * activity to pick something of that data type.</p> 429 * </ul> 430 * 431 * <p>The second activity, 432 * <code>com.android.notepad.NoteEditor</code>, shows the user a single 433 * note entry and allows them to edit it. It can do two things as described 434 * by its two intent templates: 435 * <ol> 436 * <li><pre> 437 * <intent-filter android:label="@string/resolve_edit"> 438 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 439 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 440 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 441 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 442 * </intent-filter></pre> 443 * <p>The first, primary, purpose of this activity is to let the user interact 444 * with a single note, as decribed by the MIME type 445 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can 446 * either VIEW a note or allow the user to EDIT it. Again we support the 447 * DEFAULT category to allow the activity to be launched without explicitly 448 * specifying its component.</p> 449 * <li><pre> 450 * <intent-filter> 451 * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> 452 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 453 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 454 * </intent-filter></pre> 455 * <p>The secondary use of this activity is to insert a new note entry into 456 * an existing directory of notes. This is used when the user creates a new 457 * note: the INSERT action is executed on the directory of notes, causing 458 * this activity to run and have the user create the new note data which 459 * it then adds to the content provider.</p> 460 * </ol> 461 * 462 * <p>Given these capabilities, the following intents will resolve to the 463 * NoteEditor activity:</p> 464 * 465 * <ul> 466 * <li> <p><b>{ action=android.intent.action.VIEW 467 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 468 * shows the user the content of note <var>{ID}</var>.</p> 469 * <li> <p><b>{ action=android.app.action.EDIT 470 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 471 * allows the user to edit the content of note <var>{ID}</var>.</p> 472 * <li> <p><b>{ action=android.app.action.INSERT 473 * data=content://com.google.provider.NotePad/notes }</b> 474 * creates a new, empty note in the notes list at 475 * "content://com.google.provider.NotePad/notes" 476 * and allows the user to edit it. If they keep their changes, the URI 477 * of the newly created note is returned to the caller.</p> 478 * </ul> 479 * 480 * <p>The last activity, 481 * <code>com.android.notepad.TitleEditor</code>, allows the user to 482 * edit the title of a note. This could be implemented as a class that the 483 * application directly invokes (by explicitly setting its component in 484 * the Intent), but here we show a way you can publish alternative 485 * operations on existing data:</p> 486 * 487 * <pre> 488 * <intent-filter android:label="@string/resolve_title"> 489 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 490 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 491 * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> 492 * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> 493 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 494 * </intent-filter></pre> 495 * 496 * <p>In the single intent template here, we 497 * have created our own private action called 498 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to 499 * edit the title of a note. It must be invoked on a specific note 500 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous 501 * view and edit actions, but here displays and edits the title contained 502 * in the note data. 503 * 504 * <p>In addition to supporting the default category as usual, our title editor 505 * also supports two other standard categories: ALTERNATIVE and 506 * SELECTED_ALTERNATIVE. Implementing 507 * these categories allows others to find the special action it provides 508 * without directly knowing about it, through the 509 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or 510 * more often to build dynamic menu items with 511 * {@link android.view.Menu#addIntentOptions}. Note that in the intent 512 * template here was also supply an explicit name for the template 513 * (via <code>android:label="@string/resolve_title"</code>) to better control 514 * what the user sees when presented with this activity as an alternative 515 * action to the data they are viewing. 516 * 517 * <p>Given these capabilities, the following intent will resolve to the 518 * TitleEditor activity:</p> 519 * 520 * <ul> 521 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE 522 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 523 * displays and allows the user to edit the title associated 524 * with note <var>{ID}</var>.</p> 525 * </ul> 526 * 527 * <h3>Standard Activity Actions</h3> 528 * 529 * <p>These are the current standard actions that Intent defines for launching 530 * activities (usually through {@link Context#startActivity}. The most 531 * important, and by far most frequently used, are {@link #ACTION_MAIN} and 532 * {@link #ACTION_EDIT}. 533 * 534 * <ul> 535 * <li> {@link #ACTION_MAIN} 536 * <li> {@link #ACTION_VIEW} 537 * <li> {@link #ACTION_ATTACH_DATA} 538 * <li> {@link #ACTION_EDIT} 539 * <li> {@link #ACTION_PICK} 540 * <li> {@link #ACTION_CHOOSER} 541 * <li> {@link #ACTION_GET_CONTENT} 542 * <li> {@link #ACTION_DIAL} 543 * <li> {@link #ACTION_CALL} 544 * <li> {@link #ACTION_SEND} 545 * <li> {@link #ACTION_SENDTO} 546 * <li> {@link #ACTION_ANSWER} 547 * <li> {@link #ACTION_INSERT} 548 * <li> {@link #ACTION_DELETE} 549 * <li> {@link #ACTION_RUN} 550 * <li> {@link #ACTION_SYNC} 551 * <li> {@link #ACTION_PICK_ACTIVITY} 552 * <li> {@link #ACTION_SEARCH} 553 * <li> {@link #ACTION_WEB_SEARCH} 554 * <li> {@link #ACTION_FACTORY_TEST} 555 * </ul> 556 * 557 * <h3>Standard Broadcast Actions</h3> 558 * 559 * <p>These are the current standard actions that Intent defines for receiving 560 * broadcasts (usually through {@link Context#registerReceiver} or a 561 * <receiver> tag in a manifest). 562 * 563 * <ul> 564 * <li> {@link #ACTION_TIME_TICK} 565 * <li> {@link #ACTION_TIME_CHANGED} 566 * <li> {@link #ACTION_TIMEZONE_CHANGED} 567 * <li> {@link #ACTION_BOOT_COMPLETED} 568 * <li> {@link #ACTION_PACKAGE_ADDED} 569 * <li> {@link #ACTION_PACKAGE_CHANGED} 570 * <li> {@link #ACTION_PACKAGE_REMOVED} 571 * <li> {@link #ACTION_PACKAGE_RESTARTED} 572 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} 573 * <li> {@link #ACTION_PACKAGES_SUSPENDED} 574 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} 575 * <li> {@link #ACTION_UID_REMOVED} 576 * <li> {@link #ACTION_BATTERY_CHANGED} 577 * <li> {@link #ACTION_POWER_CONNECTED} 578 * <li> {@link #ACTION_POWER_DISCONNECTED} 579 * <li> {@link #ACTION_SHUTDOWN} 580 * </ul> 581 * 582 * <p class="note"><strong>Note: </strong>If your app targets Android 11 583 * (API level 30) or higher, registering broadcast such as 584 * {@link #ACTION_PACKAGES_SUSPENDED} that includes package details in the 585 * extras receives a filtered list of apps or nothing. Learn more about how to 586 * <a href="/training/basics/intents/package-visibility">manage package visibility</a>. 587 * </p> 588 * 589 * <h3>Standard Categories</h3> 590 * 591 * <p>These are the current standard categories that can be used to further 592 * clarify an Intent via {@link #addCategory}. 593 * 594 * <ul> 595 * <li> {@link #CATEGORY_DEFAULT} 596 * <li> {@link #CATEGORY_BROWSABLE} 597 * <li> {@link #CATEGORY_TAB} 598 * <li> {@link #CATEGORY_ALTERNATIVE} 599 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} 600 * <li> {@link #CATEGORY_LAUNCHER} 601 * <li> {@link #CATEGORY_INFO} 602 * <li> {@link #CATEGORY_HOME} 603 * <li> {@link #CATEGORY_PREFERENCE} 604 * <li> {@link #CATEGORY_TEST} 605 * <li> {@link #CATEGORY_CAR_DOCK} 606 * <li> {@link #CATEGORY_DESK_DOCK} 607 * <li> {@link #CATEGORY_LE_DESK_DOCK} 608 * <li> {@link #CATEGORY_HE_DESK_DOCK} 609 * <li> {@link #CATEGORY_CAR_MODE} 610 * <li> {@link #CATEGORY_APP_MARKET} 611 * <li> {@link #CATEGORY_VR_HOME} 612 * </ul> 613 * 614 * <h3>Standard Extra Data</h3> 615 * 616 * <p>These are the current standard fields that can be used as extra data via 617 * {@link #putExtra}. 618 * 619 * <ul> 620 * <li> {@link #EXTRA_ALARM_COUNT} 621 * <li> {@link #EXTRA_BCC} 622 * <li> {@link #EXTRA_CC} 623 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} 624 * <li> {@link #EXTRA_DATA_REMOVED} 625 * <li> {@link #EXTRA_DOCK_STATE} 626 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} 627 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} 628 * <li> {@link #EXTRA_DOCK_STATE_CAR} 629 * <li> {@link #EXTRA_DOCK_STATE_DESK} 630 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} 631 * <li> {@link #EXTRA_DONT_KILL_APP} 632 * <li> {@link #EXTRA_EMAIL} 633 * <li> {@link #EXTRA_INITIAL_INTENTS} 634 * <li> {@link #EXTRA_INTENT} 635 * <li> {@link #EXTRA_KEY_EVENT} 636 * <li> {@link #EXTRA_ORIGINATING_URI} 637 * <li> {@link #EXTRA_PHONE_NUMBER} 638 * <li> {@link #EXTRA_REFERRER} 639 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} 640 * <li> {@link #EXTRA_REPLACING} 641 * <li> {@link #EXTRA_SHORTCUT_ICON} 642 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} 643 * <li> {@link #EXTRA_SHORTCUT_INTENT} 644 * <li> {@link #EXTRA_STREAM} 645 * <li> {@link #EXTRA_SHORTCUT_NAME} 646 * <li> {@link #EXTRA_SUBJECT} 647 * <li> {@link #EXTRA_TEMPLATE} 648 * <li> {@link #EXTRA_TEXT} 649 * <li> {@link #EXTRA_TITLE} 650 * <li> {@link #EXTRA_UID} 651 * <li> {@link #EXTRA_USER_INITIATED} 652 * </ul> 653 * 654 * <h3>Flags</h3> 655 * 656 * <p>These are the possible flags that can be used in the Intent via 657 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list 658 * of all possible flags. 659 */ 660 public class Intent implements Parcelable, Cloneable { 661 private static final String TAG = "Intent"; 662 663 private static final String ATTR_ACTION = "action"; 664 private static final String TAG_CATEGORIES = "categories"; 665 private static final String ATTR_CATEGORY = "category"; 666 private static final String TAG_EXTRA = "extra"; 667 private static final String ATTR_TYPE = "type"; 668 private static final String ATTR_IDENTIFIER = "ident"; 669 private static final String ATTR_COMPONENT = "component"; 670 private static final String ATTR_DATA = "data"; 671 private static final String ATTR_FLAGS = "flags"; 672 673 // --------------------------------------------------------------------- 674 // --------------------------------------------------------------------- 675 // Standard intent activity actions (see action variable). 676 677 /** 678 * Activity Action: Start as a main entry point, does not expect to 679 * receive data. 680 * <p>Input: nothing 681 * <p>Output: nothing 682 */ 683 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 684 public static final String ACTION_MAIN = "android.intent.action.MAIN"; 685 686 /** 687 * Activity Action: Display the data to the user. This is the most common 688 * action performed on data -- it is the generic action you can use on 689 * a piece of data to get the most reasonable thing to occur. For example, 690 * when used on a contacts entry it will view the entry; when used on a 691 * mailto: URI it will bring up a compose window filled with the information 692 * supplied by the URI; when used with a tel: URI it will invoke the 693 * dialer. 694 * <p>Input: {@link #getData} is URI from which to retrieve data. 695 * <p>Output: nothing. 696 */ 697 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 698 public static final String ACTION_VIEW = "android.intent.action.VIEW"; 699 700 /** 701 * Extra that can be included on activity intents coming from the storage UI 702 * when it launches sub-activities to manage various types of storage. For example, 703 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show 704 * the images on the device, and in that case also include this extra to tell the 705 * app it is coming from the storage UI so should help the user manage storage of 706 * this type. 707 */ 708 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE"; 709 710 /** 711 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is 712 * performed on a piece of data. 713 */ 714 public static final String ACTION_DEFAULT = ACTION_VIEW; 715 716 /** 717 * Activity Action: Quick view the data. Launches a quick viewer for 718 * a URI or a list of URIs. 719 * <p>Activities handling this intent action should handle the vast majority of 720 * MIME types rather than only specific ones. 721 * <p>Quick viewers must render the quick view image locally, and must not send 722 * file content outside current device. 723 * <p>Input: {@link #getData} is a mandatory content URI of the item to 724 * preview. {@link #getClipData} contains an optional list of content URIs 725 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an 726 * optional index of the URI in the clip data to show first. 727 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features 728 * that can be shown in the quick view UI. 729 * <p>Output: nothing. 730 * @see #EXTRA_INDEX 731 * @see #EXTRA_QUICK_VIEW_FEATURES 732 */ 733 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 734 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; 735 736 /** 737 * Used to indicate that some piece of data should be attached to some other 738 * place. For example, image data could be attached to a contact. It is up 739 * to the recipient to decide where the data should be attached; the intent 740 * does not specify the ultimate destination. 741 * <p>Input: {@link #getData} is URI of data to be attached. 742 * <p>Output: nothing. 743 */ 744 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 745 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; 746 747 /** 748 * Activity Action: Provide explicit editable access to the given data. 749 * <p>Input: {@link #getData} is URI of data to be edited. 750 * <p>Output: nothing. 751 */ 752 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 753 public static final String ACTION_EDIT = "android.intent.action.EDIT"; 754 755 /** 756 * Activity Action: Pick an existing item, or insert a new item, and then edit it. 757 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. 758 * The extras can contain type specific data to pass through to the editing/creating 759 * activity. 760 * <p>Output: The URI of the item that was picked. This must be a content: 761 * URI so that any receiver can access it. 762 */ 763 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 764 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; 765 766 /** 767 * Activity Action: Pick an item from the data, returning what was selected. 768 * <p>Input: {@link #getData} is URI containing a directory of data 769 * (vnd.android.cursor.dir/*) from which to pick an item. 770 * <p>Output: The URI of the item that was picked. 771 */ 772 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 773 public static final String ACTION_PICK = "android.intent.action.PICK"; 774 775 /** 776 * Activity Action: Creates a reminder. 777 * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user. 778 * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at 779 * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will 780 * be shown to the user. The time is specified in milliseconds since the Epoch (optional). 781 * </p> 782 * <p>Output: Nothing.</p> 783 * 784 * @see #EXTRA_TITLE 785 * @see #EXTRA_TEXT 786 * @see #EXTRA_TIME 787 */ 788 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 789 public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER"; 790 791 /** 792 * Activity Action: Creates a shortcut. 793 * <p>Input: Nothing.</p> 794 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> 795 * <p>For compatibility with older versions of android the intent may also contain three 796 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), 797 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE 798 * (value: ShortcutIconResource).</p> 799 * 800 * @see android.content.pm.ShortcutManager#createShortcutResultIntent 801 * @see #EXTRA_SHORTCUT_INTENT 802 * @see #EXTRA_SHORTCUT_NAME 803 * @see #EXTRA_SHORTCUT_ICON 804 * @see #EXTRA_SHORTCUT_ICON_RESOURCE 805 * @see android.content.Intent.ShortcutIconResource 806 */ 807 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 808 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; 809 810 /** 811 * The name of the extra used to define the Intent of a shortcut. 812 * 813 * @see #ACTION_CREATE_SHORTCUT 814 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 815 */ 816 @Deprecated 817 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; 818 /** 819 * The name of the extra used to define the name of a shortcut. 820 * 821 * @see #ACTION_CREATE_SHORTCUT 822 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 823 */ 824 @Deprecated 825 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; 826 /** 827 * The name of the extra used to define the icon, as a Bitmap, of a shortcut. 828 * 829 * @see #ACTION_CREATE_SHORTCUT 830 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 831 */ 832 @Deprecated 833 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; 834 /** 835 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. 836 * 837 * @see #ACTION_CREATE_SHORTCUT 838 * @see android.content.Intent.ShortcutIconResource 839 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 840 */ 841 @Deprecated 842 public static final String EXTRA_SHORTCUT_ICON_RESOURCE = 843 "android.intent.extra.shortcut.ICON_RESOURCE"; 844 845 /** 846 * An activity that provides a user interface for adjusting application preferences. 847 * Optional but recommended settings for all applications which have settings. 848 */ 849 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 850 public static final String ACTION_APPLICATION_PREFERENCES 851 = "android.intent.action.APPLICATION_PREFERENCES"; 852 853 /** 854 * Activity Action: Launch an activity showing the app information. 855 * For applications which install other applications (such as app stores), it is recommended 856 * to handle this action for providing the app information to the user. 857 * 858 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs 859 * to be displayed. 860 * <p>Output: Nothing. 861 */ 862 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 863 public static final String ACTION_SHOW_APP_INFO 864 = "android.intent.action.SHOW_APP_INFO"; 865 866 /** 867 * Activity Action: Placeholder that the component handling it can do activity 868 * recognition. Can be placed on a service. Only one service per package is 869 * supported. 870 * 871 * <p>Input: Nothing.</p> 872 * <p>Output: Nothing </p> 873 * 874 * @hide 875 */ 876 @SystemApi 877 @SdkConstant(SdkConstantType.SERVICE_ACTION) 878 public static final String ACTION_ACTIVITY_RECOGNIZER = 879 "android.intent.action.ACTIVITY_RECOGNIZER"; 880 881 /** 882 * Represents a shortcut/live folder icon resource. 883 * 884 * @see Intent#ACTION_CREATE_SHORTCUT 885 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE 886 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER 887 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON 888 */ 889 public static class ShortcutIconResource implements Parcelable { 890 /** 891 * The package name of the application containing the icon. 892 */ 893 public String packageName; 894 895 /** 896 * The resource name of the icon, including package, name and type. 897 */ 898 public String resourceName; 899 900 /** 901 * Creates a new ShortcutIconResource for the specified context and resource 902 * identifier. 903 * 904 * @param context The context of the application. 905 * @param resourceId The resource identifier for the icon. 906 * @return A new ShortcutIconResource with the specified's context package name 907 * and icon resource identifier.`` 908 */ fromContext(Context context, @AnyRes int resourceId)909 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { 910 ShortcutIconResource icon = new ShortcutIconResource(); 911 icon.packageName = context.getPackageName(); 912 icon.resourceName = context.getResources().getResourceName(resourceId); 913 return icon; 914 } 915 916 /** 917 * Used to read a ShortcutIconResource from a Parcel. 918 */ 919 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR = 920 new Parcelable.Creator<ShortcutIconResource>() { 921 922 public ShortcutIconResource createFromParcel(Parcel source) { 923 ShortcutIconResource icon = new ShortcutIconResource(); 924 icon.packageName = source.readString8(); 925 icon.resourceName = source.readString8(); 926 return icon; 927 } 928 929 public ShortcutIconResource[] newArray(int size) { 930 return new ShortcutIconResource[size]; 931 } 932 }; 933 934 /** 935 * No special parcel contents. 936 */ describeContents()937 public int describeContents() { 938 return 0; 939 } 940 writeToParcel(Parcel dest, int flags)941 public void writeToParcel(Parcel dest, int flags) { 942 dest.writeString8(packageName); 943 dest.writeString8(resourceName); 944 } 945 946 @Override toString()947 public String toString() { 948 return resourceName; 949 } 950 } 951 952 /** 953 * Activity Action: Display an activity chooser, allowing the user to pick 954 * what they want to before proceeding. This can be used as an alternative 955 * to the standard activity picker that is displayed by the system when 956 * you try to start an activity with multiple possible matches, with these 957 * differences in behavior: 958 * <ul> 959 * <li>You can specify the title that will appear in the activity chooser. 960 * <li>The user does not have the option to make one of the matching 961 * activities a preferred activity, and all possible activities will 962 * always be shown even if one of them is currently marked as the 963 * preferred activity. 964 * </ul> 965 * <p> 966 * This action should be used when the user will naturally expect to 967 * select an activity in order to proceed. An example if when not to use 968 * it is when the user clicks on a "mailto:" link. They would naturally 969 * expect to go directly to their mail app, so startActivity() should be 970 * called directly: it will 971 * either launch the current preferred app, or put up a dialog allowing the 972 * user to pick an app to use and optionally marking that as preferred. 973 * <p> 974 * In contrast, if the user is selecting a menu item to send a picture 975 * they are viewing to someone else, there are many different things they 976 * may want to do at this point: send it through e-mail, upload it to a 977 * web service, etc. In this case the CHOOSER action should be used, to 978 * always present to the user a list of the things they can do, with a 979 * nice title given by the caller such as "Send this photo with:". 980 * <p> 981 * If you need to grant URI permissions through a chooser, you must specify 982 * the permissions to be granted on the ACTION_CHOOSER Intent 983 * <em>in addition</em> to the EXTRA_INTENT inside. This means using 984 * {@link #setClipData} to specify the URIs to be granted as well as 985 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 986 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. 987 * <p> 988 * As a convenience, an Intent of this form can be created with the 989 * {@link #createChooser} function. 990 * <p> 991 * Input: No data should be specified. get*Extra must have 992 * a {@link #EXTRA_INTENT} field containing the Intent being executed, 993 * and can optionally have a {@link #EXTRA_TITLE} field containing the 994 * title text to display in the chooser. 995 * <p> 996 * Output: Depends on the protocol of {@link #EXTRA_INTENT}. 997 */ 998 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 999 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; 1000 1001 /** 1002 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 1003 * 1004 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 1005 * target intent, also optionally supplying a title. If the target 1006 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 1007 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 1008 * set in the returned chooser intent, with its ClipData set appropriately: 1009 * either a direct reflection of {@link #getClipData()} if that is non-null, 1010 * or a new ClipData built from {@link #getData()}. 1011 * 1012 * @param target The Intent that the user will be selecting an activity 1013 * to perform. 1014 * @param title Optional title that will be displayed in the chooser, 1015 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1016 * @return Return a new Intent object that you can hand to 1017 * {@link Context#startActivity(Intent) Context.startActivity()} and 1018 * related methods. 1019 */ createChooser(Intent target, CharSequence title)1020 public static Intent createChooser(Intent target, CharSequence title) { 1021 return createChooser(target, title, null); 1022 } 1023 1024 /** 1025 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 1026 * 1027 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 1028 * target intent, also optionally supplying a title. If the target 1029 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 1030 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 1031 * set in the returned chooser intent, with its ClipData set appropriately: 1032 * either a direct reflection of {@link #getClipData()} if that is non-null, 1033 * or a new ClipData built from {@link #getData()}.</p> 1034 * 1035 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback 1036 * when the user makes a choice. This can be useful if the calling application wants 1037 * to remember the last chosen target and surface it as a more prominent or one-touch 1038 * affordance elsewhere in the UI for next time.</p> 1039 * 1040 * @param target The Intent that the user will be selecting an activity 1041 * to perform. 1042 * @param title Optional title that will be displayed in the chooser, 1043 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1044 * @param sender Optional IntentSender to be called when a choice is made. 1045 * @return Return a new Intent object that you can hand to 1046 * {@link Context#startActivity(Intent) Context.startActivity()} and 1047 * related methods. 1048 */ createChooser(Intent target, CharSequence title, IntentSender sender)1049 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) { 1050 Intent intent = new Intent(ACTION_CHOOSER); 1051 intent.putExtra(EXTRA_INTENT, target); 1052 if (title != null) { 1053 intent.putExtra(EXTRA_TITLE, title); 1054 } 1055 1056 if (sender != null) { 1057 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); 1058 } 1059 1060 // Migrate any clip data and flags from target. 1061 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION 1062 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 1063 | FLAG_GRANT_PREFIX_URI_PERMISSION); 1064 if (permFlags != 0) { 1065 ClipData targetClipData = target.getClipData(); 1066 if (targetClipData == null && target.getData() != null) { 1067 ClipData.Item item = new ClipData.Item(target.getData()); 1068 String[] mimeTypes; 1069 if (target.getType() != null) { 1070 mimeTypes = new String[] { target.getType() }; 1071 } else { 1072 mimeTypes = new String[] { }; 1073 } 1074 targetClipData = new ClipData(null, mimeTypes, item); 1075 } 1076 if (targetClipData != null) { 1077 intent.setClipData(targetClipData); 1078 intent.addFlags(permFlags); 1079 } 1080 } 1081 1082 return intent; 1083 } 1084 1085 /** 1086 * Activity Action: Allow the user to select a particular kind of data and 1087 * return it. This is different than {@link #ACTION_PICK} in that here we 1088 * just say what kind of data is desired, not a URI of existing data from 1089 * which the user can pick. An ACTION_GET_CONTENT could allow the user to 1090 * create the data as it runs (for example taking a picture or recording a 1091 * sound), let them browse over the web and download the desired data, 1092 * etc. 1093 * <p> 1094 * There are two main ways to use this action: if you want a specific kind 1095 * of data, such as a person contact, you set the MIME type to the kind of 1096 * data you want and launch it with {@link Context#startActivity(Intent)}. 1097 * The system will then launch the best application to select that kind 1098 * of data for you. 1099 * <p> 1100 * You may also be interested in any of a set of types of content the user 1101 * can pick. For example, an e-mail application that wants to allow the 1102 * user to add an attachment to an e-mail message can use this action to 1103 * bring up a list of all of the types of content the user can attach. 1104 * <p> 1105 * In this case, you should wrap the GET_CONTENT intent with a chooser 1106 * (through {@link #createChooser}), which will give the proper interface 1107 * for the user to pick how to send your data and allow you to specify 1108 * a prompt indicating what they are doing. You will usually specify a 1109 * broad MIME type (such as image/* or {@literal *}/*), resulting in a 1110 * broad range of content types the user can select from. 1111 * <p> 1112 * When using such a broad GET_CONTENT action, it is often desirable to 1113 * only pick from data that can be represented as a stream. This is 1114 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. 1115 * <p> 1116 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that 1117 * the launched content chooser only returns results representing data that 1118 * is locally available on the device. For example, if this extra is set 1119 * to true then an image picker should not show any pictures that are available 1120 * from a remote server but not already on the local device (thus requiring 1121 * they be downloaded when opened). 1122 * <p> 1123 * If the caller can handle multiple returned items (the user performing 1124 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} 1125 * to indicate this. 1126 * <p> 1127 * Input: {@link #getType} is the desired MIME type to retrieve. Note 1128 * that no URI is supplied in the intent, as there are no constraints on 1129 * where the returned data originally comes from. You may also include the 1130 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be 1131 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content 1132 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to 1133 * allow the user to select multiple items. 1134 * <p> 1135 * Output: The URI of the item that was picked. This must be a content: 1136 * URI so that any receiver can access it. 1137 */ 1138 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1139 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; 1140 /** 1141 * Activity Action: Dial a number as specified by the data. This shows a 1142 * UI with the number being dialed, allowing the user to explicitly 1143 * initiate the call. 1144 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1145 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1146 * number. 1147 * <p>Output: nothing. 1148 */ 1149 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1150 public static final String ACTION_DIAL = "android.intent.action.DIAL"; 1151 /** 1152 * Activity Action: Perform a call to someone specified by the data. 1153 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1154 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1155 * number. 1156 * <p>Output: nothing. 1157 * 1158 * <p>Note: there will be restrictions on which applications can initiate a 1159 * call; most applications should use the {@link #ACTION_DIAL}. 1160 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency 1161 * numbers. Applications can <strong>dial</strong> emergency numbers using 1162 * {@link #ACTION_DIAL}, however. 1163 * 1164 * <p>Note: An app filling the {@link android.app.role.RoleManager#ROLE_DIALER} role should use 1165 * {@link android.telecom.TelecomManager#placeCall(Uri, Bundle)} to place calls rather than 1166 * relying on this intent. 1167 * 1168 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M} 1169 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE} 1170 * permission which is not granted, then attempting to use this action will 1171 * result in a {@link java.lang.SecurityException}. 1172 */ 1173 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1174 public static final String ACTION_CALL = "android.intent.action.CALL"; 1175 /** 1176 * Activity Action: Perform a call to an emergency number specified by the 1177 * data. 1178 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1179 * tel: URI of an explicit phone number. 1180 * <p>Output: nothing. 1181 * 1182 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on 1183 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} 1184 * extra (if specified) and may be placed on another {@link PhoneAccount} with the 1185 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external 1186 * factors, such as network conditions and Modem/SIM status. 1187 * @hide 1188 */ 1189 @SystemApi 1190 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1191 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; 1192 /** 1193 * Activity Action: Dial a emergency number specified by the data. This shows a 1194 * UI with the number being dialed, allowing the user to explicitly 1195 * initiate the call. 1196 * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData} 1197 * is a tel: URI of an explicit emergency phone number. 1198 * <p>Output: nothing. 1199 * @hide 1200 */ 1201 @SystemApi 1202 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1203 public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY"; 1204 /** 1205 * Activity action: Perform a call to any number (emergency or not) 1206 * specified by the data. 1207 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1208 * tel: URI of an explicit phone number. 1209 * <p>Output: nothing. 1210 * @hide 1211 */ 1212 @SystemApi 1213 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1214 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; 1215 1216 /** 1217 * Activity Action: Main entry point for carrier setup apps. 1218 * <p>Carrier apps that provide an implementation for this action may be invoked to configure 1219 * carrier service and typically require 1220 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to 1221 * fulfill their duties. 1222 */ 1223 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1224 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP"; 1225 /** 1226 * Activity Action: Send a message to someone specified by the data. 1227 * <p>Input: {@link #getData} is URI describing the target. 1228 * <p>Output: nothing. 1229 */ 1230 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1231 public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; 1232 /** 1233 * Activity Action: Deliver some data to someone else. Who the data is 1234 * being delivered to is not specified; it is up to the receiver of this 1235 * action to ask the user where the data should be sent. 1236 * <p> 1237 * When launching a SEND intent, you should usually wrap it in a chooser 1238 * (through {@link #createChooser}), which will give the proper interface 1239 * for the user to pick how to send your data and allow you to specify 1240 * a prompt indicating what they are doing. 1241 * <p> 1242 * Input: {@link #getType} is the MIME type of the data being sent. 1243 * get*Extra can have either a {@link #EXTRA_TEXT} 1244 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If 1245 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it 1246 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* 1247 * if the MIME type is unknown (this will only allow senders that can 1248 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can 1249 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve 1250 * your text with HTML formatting. 1251 * <p> 1252 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1253 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1254 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1255 * content: URIs and other advanced features of {@link ClipData}. If 1256 * using this approach, you still must supply the same data through the 1257 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1258 * for compatibility with old applications. If you don't set a ClipData, 1259 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1260 * <p> 1261 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1262 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1263 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1264 * be openable only as asset typed files using 1265 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1266 * <p> 1267 * Optional standard extras, which may be interpreted by some recipients as 1268 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1269 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1270 * <p> 1271 * Output: nothing. 1272 */ 1273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1274 public static final String ACTION_SEND = "android.intent.action.SEND"; 1275 /** 1276 * Activity Action: Deliver multiple data to someone else. 1277 * <p> 1278 * Like {@link #ACTION_SEND}, except the data is multiple. 1279 * <p> 1280 * Input: {@link #getType} is the MIME type of the data being sent. 1281 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link 1282 * #EXTRA_STREAM} field, containing the data to be sent. If using 1283 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} 1284 * for clients to retrieve your text with HTML formatting. 1285 * <p> 1286 * Multiple types are supported, and receivers should handle mixed types 1287 * whenever possible. The right way for the receiver to check them is to 1288 * use the content resolver on each URI. The intent sender should try to 1289 * put the most concrete mime type in the intent type, but it can fall 1290 * back to {@literal <type>/*} or {@literal *}/* as needed. 1291 * <p> 1292 * e.g. if you are sending image/jpg and image/jpg, the intent's type can 1293 * be image/jpg, but if you are sending image/jpg and image/png, then the 1294 * intent's type should be image/*. 1295 * <p> 1296 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1297 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1298 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1299 * content: URIs and other advanced features of {@link ClipData}. If 1300 * using this approach, you still must supply the same data through the 1301 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1302 * for compatibility with old applications. If you don't set a ClipData, 1303 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1304 * <p> 1305 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1306 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1307 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1308 * be openable only as asset typed files using 1309 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1310 * <p> 1311 * Optional standard extras, which may be interpreted by some recipients as 1312 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1313 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1314 * <p> 1315 * Output: nothing. 1316 */ 1317 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1318 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; 1319 /** 1320 * Activity Action: Handle an incoming phone call. 1321 * <p>Input: nothing. 1322 * <p>Output: nothing. 1323 */ 1324 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1325 public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; 1326 /** 1327 * Activity Action: Insert an empty item into the given container. 1328 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1329 * in which to place the data. 1330 * <p>Output: URI of the new data that was created. 1331 */ 1332 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1333 public static final String ACTION_INSERT = "android.intent.action.INSERT"; 1334 /** 1335 * Activity Action: Create a new item in the given container, initializing it 1336 * from the current contents of the clipboard. 1337 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1338 * in which to place the data. 1339 * <p>Output: URI of the new data that was created. 1340 */ 1341 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1342 public static final String ACTION_PASTE = "android.intent.action.PASTE"; 1343 /** 1344 * Activity Action: Delete the given data from its container. 1345 * <p>Input: {@link #getData} is URI of data to be deleted. 1346 * <p>Output: nothing. 1347 */ 1348 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1349 public static final String ACTION_DELETE = "android.intent.action.DELETE"; 1350 /** 1351 * Activity Action: Run the data, whatever that means. 1352 * <p>Input: ? (Note: this is currently specific to the test harness.) 1353 * <p>Output: nothing. 1354 */ 1355 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1356 public static final String ACTION_RUN = "android.intent.action.RUN"; 1357 /** 1358 * Activity Action: Perform a data synchronization. 1359 * <p>Input: ? 1360 * <p>Output: ? 1361 */ 1362 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1363 public static final String ACTION_SYNC = "android.intent.action.SYNC"; 1364 /** 1365 * Activity Action: Pick an activity given an intent, returning the class 1366 * selected. 1367 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent 1368 * used with {@link PackageManager#queryIntentActivities} to determine the 1369 * set of activities from which to pick. 1370 * <p>Output: Class name of the activity that was selected. 1371 */ 1372 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1373 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; 1374 /** 1375 * Activity Action: Perform a search. 1376 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1377 * is the text to search for. If empty, simply 1378 * enter your search results Activity with the search UI activated. 1379 * <p>Output: nothing. 1380 */ 1381 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1382 public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; 1383 /** 1384 * Activity Action: Start the platform-defined tutorial 1385 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1386 * is the text to search for. If empty, simply 1387 * enter your search results Activity with the search UI activated. 1388 * <p>Output: nothing. 1389 */ 1390 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1391 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; 1392 /** 1393 * Activity Action: Perform a web search. 1394 * <p> 1395 * Input: {@link android.app.SearchManager#QUERY 1396 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is 1397 * a url starts with http or https, the site will be opened. If it is plain 1398 * text, Google search will be applied. 1399 * <p> 1400 * Output: nothing. 1401 */ 1402 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1403 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; 1404 1405 /** 1406 * Activity Action: Perform assist action. 1407 * <p> 1408 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1409 * additional optional contextual information about where the user was when they 1410 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer 1411 * information. 1412 * Output: nothing. 1413 */ 1414 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1415 public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; 1416 1417 /** 1418 * Activity Action: Perform voice assist action. 1419 * <p> 1420 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1421 * additional optional contextual information about where the user was when they 1422 * requested the voice assist. 1423 * Output: nothing. 1424 * @hide 1425 */ 1426 @SystemApi 1427 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1428 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; 1429 1430 /** 1431 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground 1432 * application package at the time the assist was invoked. 1433 */ 1434 public static final String EXTRA_ASSIST_PACKAGE 1435 = "android.intent.extra.ASSIST_PACKAGE"; 1436 1437 /** 1438 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground 1439 * application package at the time the assist was invoked. 1440 */ 1441 public static final String EXTRA_ASSIST_UID 1442 = "android.intent.extra.ASSIST_UID"; 1443 1444 /** 1445 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual 1446 * information supplied by the current foreground app at the time of the assist request. 1447 * This is a {@link Bundle} of additional data. 1448 */ 1449 public static final String EXTRA_ASSIST_CONTEXT 1450 = "android.intent.extra.ASSIST_CONTEXT"; 1451 1452 /** 1453 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a 1454 * keyboard as the primary input device for assistance. 1455 */ 1456 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = 1457 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; 1458 1459 /** 1460 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id 1461 * that was used to invoke the assist. 1462 */ 1463 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = 1464 "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; 1465 1466 /** 1467 * Activity Action: List all available applications. 1468 * <p>Input: Nothing. 1469 * <p>Output: nothing. 1470 */ 1471 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1472 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; 1473 1474 /** 1475 * Activity Action: Action to show the list of all work apps in the launcher. For example, 1476 * shows the work apps folder or tab. 1477 * 1478 * <p>Input: Nothing. 1479 * <p>Output: nothing. 1480 */ 1481 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1482 public static final String ACTION_SHOW_WORK_APPS = 1483 "android.intent.action.SHOW_WORK_APPS"; 1484 1485 /** 1486 * Activity Action: Show settings for choosing wallpaper. 1487 * <p>Input: Nothing. 1488 * <p>Output: Nothing. 1489 */ 1490 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1491 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; 1492 1493 /** 1494 * Activity Action: Show activity for reporting a bug. 1495 * <p>Input: Nothing. 1496 * <p>Output: Nothing. 1497 */ 1498 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1499 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; 1500 1501 /** 1502 * Activity Action: Main entry point for factory tests. Only used when 1503 * the device is booting in factory test node. The implementing package 1504 * must be installed in the system image. 1505 * <p>Input: nothing 1506 * <p>Output: nothing 1507 */ 1508 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1509 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; 1510 1511 /** 1512 * Activity Action: The user pressed the "call" button to go to the dialer 1513 * or other appropriate UI for placing a call. 1514 * <p>Input: Nothing. 1515 * <p>Output: Nothing. 1516 */ 1517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1518 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; 1519 1520 /** 1521 * Activity Action: Start Voice Command. 1522 * <p>Input: Nothing. 1523 * <p>Output: Nothing. 1524 * <p class="note"> 1525 * In some cases, a matching Activity may not exist, so ensure you 1526 * safeguard against this. 1527 */ 1528 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1529 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; 1530 1531 /** 1532 * Activity Action: Start action associated with long pressing on the 1533 * search key. 1534 * <p>Input: Nothing. 1535 * <p>Output: Nothing. 1536 */ 1537 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1538 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; 1539 1540 /** 1541 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. 1542 * This intent is delivered to the package which installed the application, usually 1543 * Google Play. 1544 * <p>Input: No data is specified. The bug report is passed in using 1545 * an {@link #EXTRA_BUG_REPORT} field. 1546 * <p>Output: Nothing. 1547 * 1548 * @see #EXTRA_BUG_REPORT 1549 */ 1550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1551 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; 1552 1553 /** 1554 * An incident or bug report has been taken, and a system app has requested it to be shared, 1555 * so trigger the confirmation screen. 1556 * 1557 * This will be sent directly to the registered receiver with the 1558 * android.permission.APPROVE_INCIDENT_REPORTS permission. 1559 * @hide 1560 */ 1561 @SystemApi 1562 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED = 1563 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED"; 1564 1565 /** 1566 * An incident report has been taken, and the user has approved it for sharing. 1567 * <p> 1568 * This will be sent directly to the registered receiver, which must have 1569 * both the DUMP and USAGE_STATS permissions. 1570 * <p> 1571 * After receiving this, the application should wait until a suitable time 1572 * (e.g. network available), get the list of available reports with 1573 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)} 1574 * and then when the reports have been successfully uploaded, call 1575 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}. 1576 * 1577 * @hide 1578 */ 1579 @SystemApi 1580 public static final String ACTION_INCIDENT_REPORT_READY = 1581 "android.intent.action.INCIDENT_REPORT_READY"; 1582 1583 /** 1584 * Activity Action: Show power usage information to the user. 1585 * <p>Input: Nothing. 1586 * <p>Output: Nothing. 1587 */ 1588 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1589 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; 1590 1591 /** 1592 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs 1593 * to run. 1594 * <p>Input: Nothing. 1595 * <p>Output: Nothing. 1596 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified 1597 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD} 1598 * @hide 1599 * @removed 1600 */ 1601 @Deprecated 1602 @SystemApi 1603 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = 1604 "android.intent.action.DEVICE_INITIALIZATION_WIZARD"; 1605 1606 /** 1607 * Activity Action: Setup wizard to launch after a platform update. This 1608 * activity should have a string meta-data field associated with it, 1609 * {@link #METADATA_SETUP_VERSION}, which defines the current version of 1610 * the platform for setup. The activity will be launched only if 1611 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the 1612 * same value. 1613 * <p>Input: Nothing. 1614 * <p>Output: Nothing. 1615 * @hide 1616 */ 1617 @SystemApi 1618 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1619 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; 1620 1621 /** 1622 * Activity Action: Start the Keyboard Shortcuts Helper screen. 1623 * <p>Input: Nothing. 1624 * <p>Output: Nothing. 1625 * @hide 1626 */ 1627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1628 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = 1629 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; 1630 1631 /** 1632 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. 1633 * <p>Input: Nothing. 1634 * <p>Output: Nothing. 1635 * @hide 1636 */ 1637 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1638 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = 1639 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; 1640 1641 /** 1642 * Activity Action: Show settings for managing network data usage of a 1643 * specific application. Applications should define an activity that offers 1644 * options to control data usage. 1645 */ 1646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1647 public static final String ACTION_MANAGE_NETWORK_USAGE = 1648 "android.intent.action.MANAGE_NETWORK_USAGE"; 1649 1650 /** 1651 * Activity Action: Launch application installer. 1652 * <p> 1653 * Input: The data must be a content: URI at which the application 1654 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, 1655 * you can also use "package:<package-name>" to install an application for the 1656 * current user that is already installed for another user. You can optionally supply 1657 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, 1658 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. 1659 * <p> 1660 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1661 * succeeded. 1662 * <p> 1663 * <strong>Note:</strong>If your app is targeting API level higher than 25 you 1664 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} 1665 * in order to launch the application installer. 1666 * </p> 1667 * 1668 * @see #EXTRA_INSTALLER_PACKAGE_NAME 1669 * @see #EXTRA_NOT_UNKNOWN_SOURCE 1670 * @see #EXTRA_RETURN_RESULT 1671 * 1672 * @deprecated use {@link android.content.pm.PackageInstaller} instead 1673 */ 1674 @Deprecated 1675 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1676 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; 1677 1678 /** 1679 * Activity Action: Activity to handle split installation failures. 1680 * <p>Splits may be installed dynamically. This happens when an Activity is launched, 1681 * but the split that contains the application isn't installed. When a split is 1682 * installed in this manner, the containing package usually doesn't know this is 1683 * happening. However, if an error occurs during installation, the containing 1684 * package can define a single activity handling this action to deal with such 1685 * failures. 1686 * <p>The activity handling this action must be in the base package. 1687 * <p> 1688 * Input: {@link #EXTRA_INTENT} the original intent that started split installation. 1689 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed. 1690 */ 1691 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1692 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE"; 1693 1694 /** 1695 * Activity Action: Launch instant application installer. 1696 * <p class="note"> 1697 * This is a protected intent that can only be sent by the system. 1698 * </p> 1699 * 1700 * @hide 1701 */ 1702 @SystemApi 1703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1704 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE 1705 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE"; 1706 1707 /** 1708 * Service Action: Resolve instant application. 1709 * <p> 1710 * The system will have a persistent connection to this service. 1711 * This is a protected intent that can only be sent by the system. 1712 * </p> 1713 * 1714 * @hide 1715 */ 1716 @SystemApi 1717 @SdkConstant(SdkConstantType.SERVICE_ACTION) 1718 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE 1719 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; 1720 1721 /** 1722 * Activity Action: Launch instant app settings. 1723 * 1724 * <p class="note"> 1725 * This is a protected intent that can only be sent by the system. 1726 * </p> 1727 * 1728 * @hide 1729 */ 1730 @SystemApi 1731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1732 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS 1733 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS"; 1734 1735 /** 1736 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1737 * package. Specifies the installer package name; this package will receive the 1738 * {@link #ACTION_APP_ERROR} intent. 1739 */ 1740 public static final String EXTRA_INSTALLER_PACKAGE_NAME 1741 = "android.intent.extra.INSTALLER_PACKAGE_NAME"; 1742 1743 /** 1744 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1745 * package. Specifies that the application being installed should not be 1746 * treated as coming from an unknown source, but as coming from the app 1747 * invoking the Intent. For this to work you must start the installer with 1748 * startActivityForResult(). 1749 */ 1750 public static final String EXTRA_NOT_UNKNOWN_SOURCE 1751 = "android.intent.extra.NOT_UNKNOWN_SOURCE"; 1752 1753 /** 1754 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and 1755 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent 1756 * data field originated from. 1757 */ 1758 public static final String EXTRA_ORIGINATING_URI 1759 = "android.intent.extra.ORIGINATING_URI"; 1760 1761 /** 1762 * This extra can be used with any Intent used to launch an activity, supplying information 1763 * about who is launching that activity. This field contains a {@link android.net.Uri} 1764 * object, typically an http: or https: URI of the web site that the referral came from; 1765 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify 1766 * a native application that it came from. 1767 * 1768 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} 1769 * instead of directly retrieving the extra. It is also valid for applications to 1770 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create 1771 * a string, not a Uri; the field here, if supplied, will always take precedence, 1772 * however.</p> 1773 * 1774 * @see #EXTRA_REFERRER_NAME 1775 */ 1776 public static final String EXTRA_REFERRER 1777 = "android.intent.extra.REFERRER"; 1778 1779 /** 1780 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather 1781 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can 1782 * not be created, in particular when Intent extras are supplied through the 1783 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} 1784 * schemes. 1785 * 1786 * @see #EXTRA_REFERRER 1787 */ 1788 public static final String EXTRA_REFERRER_NAME 1789 = "android.intent.extra.REFERRER_NAME"; 1790 1791 /** 1792 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and 1793 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install 1794 * Currently only a system app that hosts the provider authority "downloads" or holds the 1795 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this. 1796 * @hide 1797 */ 1798 @SystemApi 1799 public static final String EXTRA_ORIGINATING_UID 1800 = "android.intent.extra.ORIGINATING_UID"; 1801 1802 /** 1803 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1804 * package. Tells the installer UI to skip the confirmation with the user 1805 * if the .apk is replacing an existing one. 1806 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android 1807 * will no longer show an interstitial message about updating existing 1808 * applications so this is no longer needed. 1809 */ 1810 @Deprecated 1811 public static final String EXTRA_ALLOW_REPLACE 1812 = "android.intent.extra.ALLOW_REPLACE"; 1813 1814 /** 1815 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or 1816 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should 1817 * return to the application the result code of the install/uninstall. The returned result 1818 * code will be {@link android.app.Activity#RESULT_OK} on success or 1819 * {@link android.app.Activity#RESULT_FIRST_USER} on failure. 1820 */ 1821 public static final String EXTRA_RETURN_RESULT 1822 = "android.intent.extra.RETURN_RESULT"; 1823 1824 /** 1825 * Package manager install result code. @hide because result codes are not 1826 * yet ready to be exposed. 1827 */ 1828 @SystemApi 1829 public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT"; 1830 1831 /** 1832 * Activity Action: Launch application uninstaller. 1833 * <p> 1834 * Input: The data must be a package: URI whose scheme specific part is 1835 * the package name of the current installed package to be uninstalled. 1836 * You can optionally supply {@link #EXTRA_RETURN_RESULT}. 1837 * <p> 1838 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the uninstall 1839 * succeeded. 1840 * <p> 1841 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} 1842 * since {@link Build.VERSION_CODES#P}. 1843 * 1844 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)} 1845 * instead 1846 */ 1847 @Deprecated 1848 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1849 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; 1850 1851 /** 1852 * Specify whether the package should be uninstalled for all users. 1853 * @hide because these should not be part of normal application flow. 1854 */ 1855 @SystemApi 1856 public static final String EXTRA_UNINSTALL_ALL_USERS 1857 = "android.intent.extra.UNINSTALL_ALL_USERS"; 1858 1859 /** 1860 * A string that associates with a metadata entry, indicating the last run version of the 1861 * platform that was setup. 1862 * 1863 * @see #ACTION_UPGRADE_SETUP 1864 * 1865 * @hide 1866 */ 1867 @SystemApi 1868 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; 1869 1870 /** 1871 * Activity action: Launch UI to manage the permissions of an app. 1872 * <p> 1873 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions 1874 * will be managed by the launched UI. 1875 * </p> 1876 * <p> 1877 * Output: Nothing. 1878 * </p> 1879 * 1880 * @see #EXTRA_PACKAGE_NAME 1881 * 1882 * @hide 1883 */ 1884 @SystemApi 1885 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1886 public static final String ACTION_MANAGE_APP_PERMISSIONS = 1887 "android.intent.action.MANAGE_APP_PERMISSIONS"; 1888 1889 /** 1890 * Activity action: Launch UI to manage a specific permission group of an app. 1891 * <p> 1892 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission 1893 * will be managed by the launched UI. 1894 * </p> 1895 * <p> 1896 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission 1897 * whose group should be managed by the launched UI. 1898 * </p> 1899 * <p> 1900 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group 1901 * that should be managed by the launched UI. Do not send both this and EXTRA_PERMISSION_NAME 1902 * together. 1903 * </p> 1904 * <p> 1905 * <li> {@link #EXTRA_USER} specifies the {@link UserHandle} of the user that owns the app. 1906 * </p> 1907 * <p> 1908 * Output: Nothing. 1909 * </p> 1910 * 1911 * @see #EXTRA_PACKAGE_NAME 1912 * @see #EXTRA_PERMISSION_NAME 1913 * @see #EXTRA_PERMISSION_GROUP_NAME 1914 * @see #EXTRA_USER 1915 * 1916 * @hide 1917 */ 1918 @SystemApi 1919 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 1920 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1921 public static final String ACTION_MANAGE_APP_PERMISSION = 1922 "android.intent.action.MANAGE_APP_PERMISSION"; 1923 1924 /** 1925 * Activity action: Launch UI to manage permissions. 1926 * <p> 1927 * Input: Nothing. 1928 * </p> 1929 * <p> 1930 * Output: Nothing. 1931 * </p> 1932 * 1933 * @hide 1934 */ 1935 @SystemApi 1936 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1937 public static final String ACTION_MANAGE_PERMISSIONS = 1938 "android.intent.action.MANAGE_PERMISSIONS"; 1939 1940 /** 1941 * Activity action: Launch UI to manage auto-revoke state. 1942 * 1943 * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS 1944 * 1945 * <p> 1946 * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with 1947 * a package name, whose auto-revoke state will be reviewed (mandatory). 1948 * E.g. {@code Uri.fromParts("package", packageName, null) } 1949 * </p> 1950 * <p> 1951 * Output: Nothing. 1952 * </p> 1953 */ 1954 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1955 public static final String ACTION_AUTO_REVOKE_PERMISSIONS = 1956 "android.intent.action.AUTO_REVOKE_PERMISSIONS"; 1957 1958 /** 1959 * Activity action: Launch UI to manage unused apps (hibernated apps). 1960 * 1961 * <p> 1962 * Input: Nothing. 1963 * </p> 1964 * <p> 1965 * Output: Nothing. 1966 * </p> 1967 */ 1968 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1969 public static final String ACTION_MANAGE_UNUSED_APPS = 1970 "android.intent.action.MANAGE_UNUSED_APPS"; 1971 1972 /** 1973 * Activity action: Launch UI to review permissions for an app. 1974 * The system uses this intent if permission review for apps not 1975 * supporting the new runtime permissions model is enabled. In 1976 * this mode a permission review is required before any of the 1977 * app components can run. 1978 * <p> 1979 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose 1980 * permissions will be reviewed (mandatory). 1981 * </p> 1982 * <p> 1983 * Input: {@link #EXTRA_INTENT} specifies a pending intent to 1984 * be fired after the permission review (optional). 1985 * </p> 1986 * <p> 1987 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to 1988 * be invoked after the permission review (optional). 1989 * </p> 1990 * <p> 1991 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent 1992 * passed via {@link #EXTRA_INTENT} needs a result (optional). 1993 * </p> 1994 * <p> 1995 * Output: Nothing. 1996 * </p> 1997 * 1998 * @see #EXTRA_PACKAGE_NAME 1999 * @see #EXTRA_INTENT 2000 * @see #EXTRA_REMOTE_CALLBACK 2001 * @see #EXTRA_RESULT_NEEDED 2002 * 2003 * @hide 2004 */ 2005 @SystemApi 2006 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2007 public static final String ACTION_REVIEW_PERMISSIONS = 2008 "android.intent.action.REVIEW_PERMISSIONS"; 2009 2010 /** 2011 * Activity action: Launch UI to show information about the usage 2012 * of a given permission group. This action would be handled by apps that 2013 * want to show details about how and why given permission group is being 2014 * used. 2015 * <p> 2016 * <strong>Important:</strong>You must protect the activity that handles 2017 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE 2018 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the 2019 * system can launch this activity. The system will not launch 2020 * activities that are not properly protected. 2021 * 2022 * <p> 2023 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group 2024 * for which the launched UI would be targeted. 2025 * </p> 2026 * <p> 2027 * Output: Nothing. 2028 * </p> 2029 */ 2030 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2031 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2032 public static final String ACTION_VIEW_PERMISSION_USAGE = 2033 "android.intent.action.VIEW_PERMISSION_USAGE"; 2034 2035 /** 2036 * Activity action: Launch UI to show information about the usage of a given permission group in 2037 * a given period. This action would be handled by apps that want to show details about how and 2038 * why given permission group is being used. 2039 * <p> 2040 * <strong>Important:</strong>You must protect the activity that handles this action with the 2041 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that 2042 * only the system can launch this activity. The system will not launch activities that are not 2043 * properly protected. 2044 * 2045 * <p> 2046 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for which the 2047 * launched UI would be targeted. 2048 * </p> 2049 * <p> 2050 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry. 2051 * </p> 2052 * <p> 2053 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in 2054 * millis). Both start time and end time are needed and start time must be <= end time. 2055 * </p> 2056 * <p> 2057 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in 2058 * millis). Both start time and end time are needed and start time must be <= end time. 2059 * </p> 2060 * <p> 2061 * Output: Nothing. 2062 * </p> 2063 */ 2064 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2065 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2066 public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD = 2067 "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD"; 2068 2069 /** 2070 * Activity action: Launch the Safety Center Quick Settings UI. 2071 * 2072 * <p> 2073 * Input: Nothing. 2074 * </p> 2075 * <p> 2076 * Output: Nothing. 2077 * </p> 2078 * 2079 * @hide 2080 */ 2081 @SystemApi 2082 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2083 @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) 2084 public static final String ACTION_VIEW_SAFETY_CENTER_QS = 2085 "android.intent.action.VIEW_SAFETY_CENTER_QS"; 2086 2087 /** 2088 * Activity action: Launch UI to manage a default app. 2089 * <p> 2090 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed 2091 * by the launched UI. 2092 * </p> 2093 * <p> 2094 * Output: Nothing. 2095 * </p> 2096 * 2097 * @hide 2098 */ 2099 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2100 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2101 @SystemApi 2102 public static final String ACTION_MANAGE_DEFAULT_APP = 2103 "android.intent.action.MANAGE_DEFAULT_APP"; 2104 2105 /** 2106 * Intent extra: A role name. 2107 * <p> 2108 * Type: String 2109 * </p> 2110 * 2111 * @see android.app.role.RoleManager 2112 * 2113 * @hide 2114 */ 2115 @SystemApi 2116 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME"; 2117 2118 /** 2119 * Activity action: Launch UI to manage special app accesses. 2120 * <p> 2121 * Input: Nothing. 2122 * </p> 2123 * <p> 2124 * Output: Nothing. 2125 * </p> 2126 * 2127 * @hide 2128 */ 2129 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2130 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2131 @SystemApi 2132 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES = 2133 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES"; 2134 2135 /** 2136 * Intent extra: A callback for reporting remote result as a bundle. 2137 * <p> 2138 * Type: IRemoteCallback 2139 * </p> 2140 * 2141 * @hide 2142 */ 2143 @SystemApi 2144 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; 2145 2146 /** 2147 * Intent extra: An app package name. 2148 * <p> 2149 * Type: String 2150 * </p> 2151 * 2152 */ 2153 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; 2154 2155 /** 2156 * Intent extra: A {@link android.os.LocaleList} 2157 * <p> 2158 * Type: LocaleList 2159 * </p> 2160 */ 2161 public static final String EXTRA_LOCALE_LIST = "android.intent.extra.LOCALE_LIST"; 2162 2163 /** 2164 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an 2165 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}. 2166 * 2167 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the 2168 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}. 2169 * This is meant to enable the suspended app to better handle the state of being suspended. 2170 * 2171 * @see #ACTION_MY_PACKAGE_SUSPENDED 2172 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2173 * @see PackageManager#isPackageSuspended() 2174 * @see PackageManager#getSuspendedPackageAppExtras() 2175 */ 2176 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS"; 2177 2178 /** 2179 * Intent extra: An app split name. 2180 * <p> 2181 * Type: String 2182 * </p> 2183 */ 2184 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; 2185 2186 /** 2187 * Intent extra: A {@link ComponentName} value. 2188 * <p> 2189 * Type: String 2190 * </p> 2191 */ 2192 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME"; 2193 2194 /** 2195 * Intent extra: An extra for specifying whether a result is needed. 2196 * <p> 2197 * Type: boolean 2198 * </p> 2199 * 2200 * @hide 2201 */ 2202 @SystemApi 2203 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; 2204 2205 /** 2206 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with 2207 * {@link #ACTION_SEND}. 2208 * 2209 * @see ShortcutInfo#getId() 2210 * 2211 * <p> 2212 * Type: String 2213 * </p> 2214 */ 2215 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID"; 2216 2217 /** 2218 * Activity action: Launch UI to manage which apps have a given permission. 2219 * <p> 2220 * Input: {@link #EXTRA_PERMISSION_NAME} or {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the 2221 * permission group which will be managed by the launched UI. 2222 * </p> 2223 * <p> 2224 * Output: Nothing. 2225 * </p> 2226 * 2227 * @see #EXTRA_PERMISSION_NAME 2228 * @see #EXTRA_PERMISSION_GROUP_NAME 2229 * 2230 * @hide 2231 */ 2232 @SystemApi 2233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2234 public static final String ACTION_MANAGE_PERMISSION_APPS = 2235 "android.intent.action.MANAGE_PERMISSION_APPS"; 2236 2237 /** 2238 * Intent extra: The name of a permission. 2239 * <p> 2240 * Type: String 2241 * </p> 2242 * 2243 * @hide 2244 */ 2245 @SystemApi 2246 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; 2247 2248 /** 2249 * Intent extra: The name of a permission group. 2250 * <p> 2251 * Type: String 2252 * </p> 2253 */ 2254 public static final String EXTRA_PERMISSION_GROUP_NAME = 2255 "android.intent.extra.PERMISSION_GROUP_NAME"; 2256 2257 /** 2258 * Intent extra: The number of milliseconds. 2259 * <p> 2260 * Type: long 2261 * </p> 2262 */ 2263 public static final String EXTRA_DURATION_MILLIS = 2264 "android.intent.extra.DURATION_MILLIS"; 2265 2266 /** 2267 * Activity action: Launch UI to review app uses of permissions. 2268 * <p> 2269 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name 2270 * that will be displayed by the launched UI. Do not pass both this and 2271 * {@link #EXTRA_PERMISSION_GROUP_NAME} . 2272 * </p> 2273 * <p> 2274 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2275 * that will be displayed by the launched UI. Do not pass both this and 2276 * {@link #EXTRA_PERMISSION_NAME}. 2277 * </p> 2278 * <p> 2279 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2280 * activity to show (optional). Must be non-negative. 2281 * </p> 2282 * <p> 2283 * Output: Nothing. 2284 * </p> 2285 * <p class="note"> 2286 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2287 * </p> 2288 * 2289 * @see #EXTRA_PERMISSION_NAME 2290 * @see #EXTRA_PERMISSION_GROUP_NAME 2291 * @see #EXTRA_DURATION_MILLIS 2292 * 2293 * @hide 2294 */ 2295 @SystemApi 2296 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2297 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2298 public static final String ACTION_REVIEW_PERMISSION_USAGE = 2299 "android.intent.action.REVIEW_PERMISSION_USAGE"; 2300 2301 /** 2302 * Activity action: Launch UI to review the timeline history of permissions. 2303 * <p> 2304 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2305 * that will be displayed by the launched UI. 2306 * </p> 2307 * <p> 2308 * Output: Nothing. 2309 * </p> 2310 * <p class="note"> 2311 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2312 * </p> 2313 * 2314 * @see #EXTRA_PERMISSION_GROUP_NAME 2315 * 2316 * @hide 2317 */ 2318 @SystemApi 2319 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2320 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2321 public static final String ACTION_REVIEW_PERMISSION_HISTORY = 2322 "android.intent.action.REVIEW_PERMISSION_HISTORY"; 2323 2324 /** 2325 * Activity action: Launch UI to review ongoing app uses of permissions. 2326 * <p> 2327 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2328 * activity to show (optional). Must be non-negative. 2329 * </p> 2330 * <p> 2331 * Output: Nothing. 2332 * </p> 2333 * <p class="note"> 2334 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2335 * </p> 2336 * 2337 * @see #EXTRA_DURATION_MILLIS 2338 * 2339 * @hide 2340 */ 2341 @SystemApi 2342 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2343 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2344 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE = 2345 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE"; 2346 2347 /** 2348 * Activity action: Launch UI to review running accessibility services. 2349 * <p> 2350 * Input: Nothing. 2351 * </p> 2352 * <p> 2353 * Output: Nothing. 2354 * </p> 2355 * 2356 * @hide 2357 */ 2358 @SystemApi 2359 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES) 2360 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2361 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES = 2362 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"; 2363 2364 /** 2365 * Activity action: Launch UI to manage the usage of a given permission group. 2366 * This action would be handled by apps that want to show controls about the features 2367 * which use the permission group. 2368 * 2369 * <p> 2370 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for 2371 * which the launched UI would be targeted. 2372 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry. 2373 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in 2374 * millis). If both start time and end time are present, start time must be <= end time. 2375 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in 2376 * millis). If the end time is empty, that implies that the permission usage is still in use. 2377 * If both start time and end time are present, start time must be <= end time. 2378 * Input: {@link #EXTRA_SHOWING_ATTRIBUTION} specifies whether the subattribution was shown 2379 * in the UI. 2380 * </p> 2381 * <p> 2382 * Output: Nothing. 2383 * </p> 2384 * <p class="note"> 2385 * You must protect the activity that handles this action with the 2386 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that 2387 * only the system can launch this activity. The system will not launch activities 2388 * that are not properly protected. 2389 * </p> 2390 * 2391 * @see #EXTRA_PERMISSION_GROUP_NAME 2392 * @see #EXTRA_ATTRIBUTION_TAGS 2393 * @see #EXTRA_START_TIME 2394 * @see #EXTRA_END_TIME 2395 * @see #EXTRA_SHOWING_ATTRIBUTION 2396 * 2397 * @hide 2398 */ 2399 @SystemApi 2400 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2401 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2402 public static final String ACTION_MANAGE_PERMISSION_USAGE = 2403 "android.intent.action.MANAGE_PERMISSION_USAGE"; 2404 2405 /** 2406 * Activity action: Launch UI to view the app's feature's information. 2407 * 2408 * <p> 2409 * Output: Nothing. 2410 * </p> 2411 * <p class="note"> 2412 * You must protect the activity that handles this action with the 2413 * {@link android.Manifest.permission#START_VIEW_APP_FEATURES} permission to ensure that 2414 * only the system can launch this activity. The system will not launch activities 2415 * that are not properly protected. 2416 * 2417 * An optional <meta-data> tag in the activity's manifest with 2418 * android:name=app_features_preference_summary and android:resource=@string/<string name> will 2419 * be used to add a summary line for the "All Services" preference in settings. 2420 * </p> 2421 * @hide 2422 */ 2423 @SystemApi 2424 @RequiresPermission(android.Manifest.permission.START_VIEW_APP_FEATURES) 2425 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2426 public static final String ACTION_VIEW_APP_FEATURES = 2427 "android.intent.action.VIEW_APP_FEATURES"; 2428 2429 /** 2430 * Activity action: Launch UI to open the Safety Center, which highlights the user's security 2431 * and privacy status. 2432 */ 2433 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2434 public static final String ACTION_SAFETY_CENTER = 2435 "android.intent.action.SAFETY_CENTER"; 2436 2437 /** 2438 * Activity action: Launch the UI to view recent updates that installed apps have made to their 2439 * data sharing policy in their safety labels. 2440 * 2441 * <p> 2442 * Input: Nothing. 2443 * </p> 2444 * <p> 2445 * Output: Nothing. 2446 * </p> 2447 * 2448 * <p class="note"> 2449 * This intent action requires the {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} 2450 * permission. 2451 * </p> 2452 * 2453 * @hide 2454 */ 2455 @SystemApi 2456 @RequiresPermission(Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2457 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2458 public static final String ACTION_REVIEW_APP_DATA_SHARING_UPDATES = 2459 "android.intent.action.REVIEW_APP_DATA_SHARING_UPDATES"; 2460 2461 // --------------------------------------------------------------------- 2462 // --------------------------------------------------------------------- 2463 // Standard intent broadcast actions (see action variable). 2464 2465 /** 2466 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. 2467 * <p> 2468 * For historical reasons, the name of this broadcast action refers to the power 2469 * state of the screen but it is actually sent in response to changes in the 2470 * overall interactive state of the device. 2471 * </p><p> 2472 * This broadcast is sent when the device becomes non-interactive which may have 2473 * nothing to do with the screen turning off. To determine the 2474 * actual state of the screen, use {@link android.view.Display#getState}. 2475 * </p><p> 2476 * See {@link android.os.PowerManager#isInteractive} for details. 2477 * </p> 2478 * You <em>cannot</em> receive this through components declared in 2479 * manifests, only by explicitly registering for it with 2480 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2481 * Context.registerReceiver()}. 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_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; 2488 2489 /** 2490 * Broadcast Action: Sent when the device wakes up and becomes interactive. 2491 * <p> 2492 * For historical reasons, the name of this broadcast action refers to the power 2493 * state of the screen but it is actually sent in response to changes in the 2494 * overall interactive state of the device. 2495 * </p><p> 2496 * This broadcast is sent when the device becomes interactive which may have 2497 * nothing to do with the screen turning on. To determine the 2498 * actual state of the screen, use {@link android.view.Display#getState}. 2499 * </p><p> 2500 * See {@link android.os.PowerManager#isInteractive} for details. 2501 * </p> 2502 * You <em>cannot</em> receive this through components declared in 2503 * manifests, only by explicitly registering for it with 2504 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2505 * Context.registerReceiver()}. 2506 * 2507 * <p class="note">This is a protected intent that can only be sent 2508 * by the system. 2509 */ 2510 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2511 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; 2512 2513 /** 2514 * Broadcast Action: Sent after the system stops dreaming. 2515 * 2516 * <p class="note">This is a protected intent that can only be sent by the system. 2517 * It is only sent to registered receivers.</p> 2518 */ 2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2520 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; 2521 2522 /** 2523 * Broadcast Action: Sent after the system starts dreaming. 2524 * 2525 * <p class="note">This is a protected intent that can only be sent by the system. 2526 * It is only sent to registered receivers.</p> 2527 */ 2528 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2529 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; 2530 2531 /** 2532 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the 2533 * keyguard is gone). 2534 * 2535 * <p class="note">This is a protected intent that can only be sent 2536 * by the system. 2537 */ 2538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2539 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; 2540 2541 /** 2542 * Broadcast Action: The current time has changed. Sent every 2543 * minute. You <em>cannot</em> receive this through components declared 2544 * in manifests, only by explicitly registering for it with 2545 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2546 * Context.registerReceiver()}. 2547 * 2548 * <p class="note">This is a protected intent that can only be sent 2549 * by the system. 2550 */ 2551 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2552 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; 2553 /** 2554 * Broadcast Action: The time was set. 2555 */ 2556 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2557 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; 2558 /** 2559 * Broadcast Action: The date has changed. 2560 */ 2561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2562 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; 2563 /** 2564 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> 2565 * <ul> 2566 * <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new 2567 * time zone.</li> 2568 * </ul> 2569 * 2570 * <p class="note">This is a protected intent that can only be sent 2571 * by the system. 2572 */ 2573 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2574 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; 2575 /** 2576 * Alarm Changed Action: This is broadcast when the AlarmClock 2577 * application's alarm is set or unset. It is used by the 2578 * AlarmClock application and the StatusBar service. 2579 * @hide 2580 */ 2581 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2582 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2583 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; 2584 2585 /** 2586 * Broadcast Action: This is broadcast once, after the user has finished 2587 * booting, but while still in the "locked" state. It can be used to perform 2588 * application-specific initialization, such as installing alarms. You must 2589 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} 2590 * permission in order to receive this broadcast. 2591 * <p> 2592 * This broadcast is sent immediately at boot by all devices (regardless of 2593 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or 2594 * higher. Upon receipt of this broadcast, the user is still locked and only 2595 * device-protected storage can be accessed safely. If you want to access 2596 * credential-protected storage, you need to wait for the user to be 2597 * unlocked (typically by entering their lock pattern or PIN for the first 2598 * time), after which the {@link #ACTION_USER_UNLOCKED} and 2599 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. 2600 * <p> 2601 * To receive this broadcast, your receiver component must be marked as 2602 * being {@link ComponentInfo#directBootAware}. 2603 * <p class="note"> 2604 * This is a protected intent that can only be sent by the system. 2605 * 2606 * @see Context#createDeviceProtectedStorageContext() 2607 */ 2608 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2609 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; 2610 2611 /** 2612 * Broadcast Action: This is broadcast once, after the user has finished 2613 * booting. It can be used to perform application-specific initialization, 2614 * such as installing alarms. You must hold the 2615 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in 2616 * order to receive this broadcast. 2617 * <p> 2618 * This broadcast is sent at boot by all devices (both with and without 2619 * direct boot support). Upon receipt of this broadcast, the user is 2620 * unlocked and both device-protected and credential-protected storage can 2621 * accessed safely. 2622 * <p> 2623 * If you need to run while the user is still locked (before they've entered 2624 * their lock pattern or PIN for the first time), you can listen for the 2625 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. 2626 * <p class="note"> 2627 * This is a protected intent that can only be sent by the system. 2628 */ 2629 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2630 @BroadcastBehavior(includeBackground = true) 2631 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; 2632 2633 /** 2634 * Broadcast Action: This is broadcast when a user action should request a 2635 * temporary system dialog to dismiss. Some examples of temporary system 2636 * dialogs are the notification window-shade and the recent tasks dialog. 2637 * 2638 * @deprecated This intent is deprecated for third-party applications starting from Android 2639 * {@link Build.VERSION_CODES#S} for security reasons. Unauthorized usage by applications 2640 * will result in the broadcast intent being dropped for apps targeting API level less than 2641 * {@link Build.VERSION_CODES#S} and in a {@link SecurityException} for apps targeting SDK 2642 * level {@link Build.VERSION_CODES#S} or higher. Instrumentation initiated from the shell 2643 * (eg. tests) is still able to use the intent. The platform will automatically collapse 2644 * the proper system dialogs in the proper use-cases. For all others, the user is the one in 2645 * control of closing dialogs. 2646 * 2647 * @see AccessibilityService#GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE 2648 */ 2649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2650 @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS) 2651 @Deprecated 2652 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; 2653 /** 2654 * Broadcast Action: Trigger the download and eventual installation 2655 * of a package. 2656 * <p>Input: {@link #getData} is the URI of the package file to download. 2657 * 2658 * <p class="note">This is a protected intent that can only be sent 2659 * by the system. 2660 * 2661 * @deprecated This constant has never been used. 2662 */ 2663 @Deprecated 2664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2665 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; 2666 /** 2667 * Broadcast Action: A new application package has been installed on the 2668 * device. The data contains the name of the package. Note that the 2669 * newly installed package does <em>not</em> receive this broadcast. 2670 * <p>May include the following extras: 2671 * <ul> 2672 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2673 * <li> {@link #EXTRA_REPLACING} is set to true if this is following 2674 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. 2675 * </ul> 2676 * 2677 * <p class="note">This is a protected intent that can only be sent 2678 * by the system. 2679 */ 2680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2681 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; 2682 /** 2683 * Broadcast Action: A new version of an application package has been 2684 * installed, replacing an existing version that was previously installed. 2685 * The data contains the name of the package. 2686 * <p>May include the following extras: 2687 * <ul> 2688 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2689 * </ul> 2690 * 2691 * <p class="note">This is a protected intent that can only be sent 2692 * by the system. 2693 */ 2694 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2695 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; 2696 /** 2697 * Broadcast Action: A new version of your application has been installed 2698 * over an existing one. This is only sent to the application that was 2699 * replaced. It does not contain any additional data; to receive it, just 2700 * use an intent filter for this action. 2701 * 2702 * <p class="note">This is a protected intent that can only be sent 2703 * by the system. 2704 */ 2705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2706 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; 2707 /** 2708 * Broadcast Action: An existing application package has been removed from 2709 * the device. The data contains the name of the package. The package 2710 * that is being removed does <em>not</em> receive this Intent. 2711 * <ul> 2712 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2713 * to the package. 2714 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2715 * application -- data and code -- is being removed. 2716 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2717 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2718 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal that the application 2719 * was removed with the user-initiated action. 2720 * </ul> 2721 * 2722 * <p class="note">This is a protected intent that can only be sent 2723 * by the system. 2724 */ 2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2726 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; 2727 /** 2728 * Broadcast Action: An existing application package has been removed from 2729 * the device. The data contains the name of the package and the visibility 2730 * allow list. The package that is being removed does <em>not</em> receive 2731 * this Intent. 2732 * <ul> 2733 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2734 * to the package. 2735 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2736 * application -- data and code -- is being removed. 2737 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2738 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2739 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal 2740 * that the application was removed with the user-initiated action. 2741 * <li> {@link #EXTRA_VISIBILITY_ALLOW_LIST} containing an int array to 2742 * indicate the visibility allow list. 2743 * </ul> 2744 * 2745 * <p class="note">This is a protected intent that can only be sent 2746 * by the system. 2747 * 2748 * @hide This broadcast is used internally by the system. 2749 */ 2750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2751 public static final String ACTION_PACKAGE_REMOVED_INTERNAL = 2752 "android.intent.action.PACKAGE_REMOVED_INTERNAL"; 2753 /** 2754 * Broadcast Action: An existing application package has been completely 2755 * removed from the device. The data contains the name of the package. 2756 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when 2757 * {@link #EXTRA_DATA_REMOVED} is true and 2758 * {@link #EXTRA_REPLACING} is false of that broadcast. 2759 * 2760 * <ul> 2761 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2762 * to the package. 2763 * </ul> 2764 * 2765 * <p class="note">This is a protected intent that can only be sent 2766 * by the system. 2767 */ 2768 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2769 public static final String ACTION_PACKAGE_FULLY_REMOVED 2770 = "android.intent.action.PACKAGE_FULLY_REMOVED"; 2771 /** 2772 * Broadcast Action: An existing application package has been changed (for 2773 * example, a component has been enabled or disabled). The data contains 2774 * the name of the package. 2775 * <ul> 2776 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2777 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name 2778 * of the changed components (or the package name itself). 2779 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the 2780 * default action of restarting the application. 2781 * </ul> 2782 * 2783 * <p class="note">This is a protected intent that can only be sent 2784 * by the system. 2785 */ 2786 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2787 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; 2788 /** 2789 * Broadcast Action: Sent to the system rollback manager when a package 2790 * needs to have rollback enabled. 2791 * <p class="note"> 2792 * This is a protected intent that can only be sent by the system. 2793 * </p> 2794 * 2795 * @hide This broadcast is used internally by the system. 2796 */ 2797 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2798 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK = 2799 "android.intent.action.PACKAGE_ENABLE_ROLLBACK"; 2800 /** 2801 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain 2802 * package needs to be cancelled. 2803 * 2804 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager 2805 * that enabling a specific rollback has timed out. 2806 * 2807 * @hide 2808 */ 2809 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2810 public static final String ACTION_CANCEL_ENABLE_ROLLBACK = 2811 "android.intent.action.CANCEL_ENABLE_ROLLBACK"; 2812 /** 2813 * Broadcast Action: A rollback has been committed. 2814 * 2815 * <p class="note">This is a protected intent that can only be sent 2816 * by the system. The receiver must hold MANAGE_ROLLBACK permission. 2817 * 2818 * @hide 2819 */ 2820 @SystemApi 2821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2822 public static final String ACTION_ROLLBACK_COMMITTED = 2823 "android.intent.action.ROLLBACK_COMMITTED"; 2824 /** 2825 * @hide 2826 * Broadcast Action: Ask system services if there is any reason to 2827 * restart the given package. The data contains the name of the 2828 * package. 2829 * <ul> 2830 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2831 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. 2832 * </ul> 2833 * 2834 * <p class="note">This is a protected intent that can only be sent 2835 * by the system. 2836 */ 2837 @SystemApi 2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2839 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; 2840 /** 2841 * Broadcast Action: The user has restarted a package, and all of its 2842 * processes have been killed. All runtime state 2843 * associated with it (processes, alarms, notifications, etc) should 2844 * be removed. Note that the restarted package does <em>not</em> 2845 * receive this broadcast. 2846 * The data contains the name of the package. 2847 * <ul> 2848 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2849 * </ul> 2850 * 2851 * <p class="note">This is a protected intent that can only be sent 2852 * by the system. 2853 */ 2854 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2855 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; 2856 /** 2857 * Broadcast Action: The user has cleared the data of a package. This should 2858 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of 2859 * its persistent data is erased and this broadcast sent. 2860 * Note that the cleared package does <em>not</em> 2861 * receive this broadcast. The data contains the name of the package. 2862 * <ul> 2863 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the 2864 * package whose data was cleared is an uninstalled instant app, then the UID 2865 * will be -1. The platform keeps some meta-data associated with instant apps 2866 * after they are uninstalled. 2867 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared 2868 * data was for an instant app. 2869 * </ul> 2870 * 2871 * <p class="note">This is a protected intent that can only be sent 2872 * by the system. 2873 */ 2874 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2875 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; 2876 /** 2877 * Broadcast Action: Packages have been suspended. 2878 * <p>Includes the following extras: 2879 * <ul> 2880 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended 2881 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended 2882 * </ul> 2883 * 2884 * <p class="note">This is a protected intent that can only be sent 2885 * by the system. It is only sent to registered receivers. 2886 */ 2887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2888 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; 2889 /** 2890 * Broadcast Action: Packages have been unsuspended. 2891 * <p>Includes the following extras: 2892 * <ul> 2893 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended 2894 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended 2895 * </ul> 2896 * 2897 * <p class="note">This is a protected intent that can only be sent 2898 * by the system. It is only sent to registered receivers. 2899 */ 2900 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2901 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; 2902 /** 2903 * Broadcast Action: One of the suspend conditions have been modified for the packages. 2904 * <p>Includes the following extras: 2905 * <ul> 2906 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been modified 2907 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been modified 2908 * </ul> 2909 * 2910 * <p class="note">This is a protected intent that can only be sent 2911 * by the system. It is only sent to registered receivers. 2912 * 2913 * @hide 2914 */ 2915 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2916 public static final String ACTION_PACKAGES_SUSPENSION_CHANGED = 2917 "android.intent.action.PACKAGES_SUSPENSION_CHANGED"; 2918 2919 /** 2920 * Broadcast Action: Distracting packages have been changed. 2921 * <p>Includes the following extras: 2922 * <ul> 2923 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed. 2924 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed. 2925 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages. 2926 * </ul> 2927 * 2928 * <p class="note">This is a protected intent that can only be sent 2929 * by the system. It is only sent to registered receivers. 2930 * 2931 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 2932 * @hide 2933 */ 2934 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2935 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED = 2936 "android.intent.action.DISTRACTING_PACKAGES_CHANGED"; 2937 2938 /** 2939 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent 2940 * whenever a package is put into a suspended state or any of its app extras change while in the 2941 * suspended state. 2942 * <p> Optionally includes the following extras: 2943 * <ul> 2944 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain 2945 * useful information for the app being suspended. 2946 * </ul> 2947 * <p class="note">This is a protected intent that can only be sent 2948 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2949 * the manifest.</em> 2950 * 2951 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2952 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2953 * @see PackageManager#isPackageSuspended() 2954 * @see PackageManager#getSuspendedPackageAppExtras() 2955 */ 2956 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2957 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED"; 2958 2959 /** 2960 * Activity Action: Started to show more details about why an application was suspended. 2961 * 2962 * <p>Whenever the system detects an activity launch for a suspended app, this action can 2963 * be used to show more details about the reason for suspension. 2964 * 2965 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity 2966 * handling this intent and protect it with 2967 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}. 2968 * 2969 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package. 2970 * 2971 * <p class="note">This is a protected intent that can only be sent 2972 * by the system. 2973 * 2974 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2975 * PersistableBundle, String) 2976 * @see PackageManager#isPackageSuspended() 2977 * @see #ACTION_PACKAGES_SUSPENDED 2978 * 2979 * @hide 2980 */ 2981 @SystemApi 2982 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2983 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS = 2984 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS"; 2985 2986 /** 2987 * Broadcast Action: Sent to indicate that the user unsuspended a package. 2988 * 2989 * <p>This can happen when the user taps on the neutral button of the 2990 * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using 2991 * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the 2992 * suspending app that originally specified this dialog while calling 2993 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2994 * PersistableBundle, SuspendDialogInfo)}. 2995 * 2996 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just 2997 * got unsuspended. 2998 * 2999 * <p class="note">This is a protected intent that can only be sent 3000 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 3001 * the manifest.</em> 3002 * 3003 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 3004 * PersistableBundle, SuspendDialogInfo) 3005 * @see PackageManager#isPackageSuspended() 3006 * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS 3007 * @hide 3008 */ 3009 @SystemApi 3010 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3011 public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY = 3012 "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY"; 3013 3014 /** 3015 * Broadcast Action: Sent to a package that has been unsuspended. 3016 * 3017 * <p class="note">This is a protected intent that can only be sent 3018 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 3019 * the manifest.</em> 3020 * 3021 * @see #ACTION_MY_PACKAGE_SUSPENDED 3022 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 3023 * @see PackageManager#isPackageSuspended() 3024 * @see PackageManager#getSuspendedPackageAppExtras() 3025 */ 3026 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3027 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED"; 3028 3029 /** 3030 * Broadcast Action: A uid has been removed from the system. The uid 3031 * number is stored in the extra data under {@link #EXTRA_UID}. 3032 * 3033 * In certain instances, {@link #EXTRA_REPLACING} is set to true if the UID is not being 3034 * fully removed. 3035 * 3036 * <p class="note">This is a protected intent that can only be sent 3037 * by the system. 3038 */ 3039 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3040 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; 3041 3042 /** 3043 * Broadcast Action: Sent to the installer package of an application when 3044 * that application is first launched (that is the first time it is moved 3045 * out of the stopped state). The data contains the name of the package. 3046 * 3047 * <p>When the application is first launched, the application itself doesn't receive this 3048 * broadcast.</p> 3049 * 3050 * <p class="note">This is a protected intent that can only be sent 3051 * by the system. 3052 */ 3053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3054 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; 3055 3056 /** 3057 * Broadcast Action: Sent to the system package verifier when a package 3058 * needs to be verified. The data contains the package URI. 3059 * <p class="note"> 3060 * This is a protected intent that can only be sent by the system. 3061 * </p> 3062 */ 3063 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3064 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; 3065 3066 /** 3067 * Broadcast Action: Sent to the system package verifier when a package is 3068 * verified. The data contains the package URI. 3069 * <p class="note"> 3070 * This is a protected intent that can only be sent by the system. 3071 */ 3072 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3073 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; 3074 3075 /** 3076 * Broadcast Action: Sent to the system intent filter verifier when an 3077 * intent filter needs to be verified. The data contains the filter data 3078 * hosts to be verified against. 3079 * <p class="note"> 3080 * This is a protected intent that can only be sent by the system. 3081 * </p> 3082 * 3083 * @hide 3084 * @deprecated Superseded by domain verification APIs. See {@link DomainVerificationManager}. 3085 */ 3086 @Deprecated 3087 @SystemApi 3088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3089 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = 3090 "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; 3091 3092 3093 /** 3094 * Broadcast Action: Sent to the system domain verification agent when an app's domains need 3095 * to be verified. The data contains the domains hosts to be verified against. 3096 * <p class="note"> 3097 * This is a protected intent that can only be sent by the system. 3098 * </p> 3099 * 3100 * @hide 3101 */ 3102 @SystemApi 3103 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3104 public static final String ACTION_DOMAINS_NEED_VERIFICATION = 3105 "android.intent.action.DOMAINS_NEED_VERIFICATION"; 3106 3107 /** 3108 * Broadcast Action: Resources for a set of packages (which were 3109 * previously unavailable) are currently 3110 * available since the media on which they exist is available. 3111 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 3112 * list of packages whose availability changed. 3113 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 3114 * list of uids of packages whose availability changed. 3115 * Note that the 3116 * packages in this list do <em>not</em> receive this broadcast. 3117 * The specified set of packages are now available on the system. 3118 * <p>Includes the following extras: 3119 * <ul> 3120 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 3121 * whose resources(were previously unavailable) are currently available. 3122 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the 3123 * packages whose resources(were previously unavailable) 3124 * are currently available. 3125 * </ul> 3126 * 3127 * <p class="note">This is a protected intent that can only be sent 3128 * by the system. 3129 */ 3130 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3131 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = 3132 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; 3133 3134 /** 3135 * Broadcast Action: Resources for a set of packages are currently 3136 * unavailable since the media on which they exist is unavailable. 3137 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 3138 * list of packages whose availability changed. 3139 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 3140 * list of uids of packages whose availability changed. 3141 * The specified set of packages can no longer be 3142 * launched and are practically unavailable on the system. 3143 * <p>Inclues the following extras: 3144 * <ul> 3145 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 3146 * whose resources are no longer available. 3147 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages 3148 * whose resources are no longer available. 3149 * </ul> 3150 * 3151 * <p class="note">This is a protected intent that can only be sent 3152 * by the system. 3153 */ 3154 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3155 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = 3156 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; 3157 3158 /** 3159 * Broadcast Action: preferred activities have changed *explicitly*. 3160 * 3161 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. 3162 * when an app is installed or uninstalled, but in such cases this broadcast will *not* 3163 * be sent. 3164 * 3165 * {@link #EXTRA_USER_HANDLE} contains the user ID in question. 3166 * 3167 * @hide 3168 */ 3169 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3170 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = 3171 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; 3172 3173 3174 /** 3175 * Broadcast Action: The current system wallpaper has changed. See 3176 * {@link android.app.WallpaperManager} for retrieving the new wallpaper. 3177 * This should <em>only</em> be used to determine when the wallpaper 3178 * has changed to show the new wallpaper to the user. You should certainly 3179 * never, in response to this, change the wallpaper or other attributes of 3180 * it such as the suggested size. That would be unexpected, right? You'd cause 3181 * all kinds of loops, especially if other apps are doing similar things, 3182 * right? Of course. So please don't do this. 3183 * 3184 * @deprecated Modern applications should use 3185 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER 3186 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper 3187 * shown behind their UI, rather than watching for this broadcast and 3188 * rendering the wallpaper on their own. 3189 */ 3190 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3191 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; 3192 /** 3193 * Broadcast Action: The current device {@link android.content.res.Configuration} 3194 * (orientation, locale, etc) has changed. When such a change happens, the 3195 * UIs (view hierarchy) will need to be rebuilt based on this new 3196 * information; for the most part, applications don't need to worry about 3197 * this, because the system will take care of stopping and restarting the 3198 * application to make sure it sees the new changes. Some system code that 3199 * can not be restarted will need to watch for this action and handle it 3200 * appropriately. 3201 * 3202 * <p class="note"> 3203 * You <em>cannot</em> receive this through components declared 3204 * in manifests, only by explicitly registering for it with 3205 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3206 * Context.registerReceiver()}. 3207 * 3208 * <p class="note">This is a protected intent that can only be sent 3209 * by the system. 3210 * 3211 * @see android.content.res.Configuration 3212 */ 3213 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3214 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; 3215 3216 /** 3217 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed 3218 * such that the device may be eligible for the installation of additional configuration splits. 3219 * Configuration properties that can trigger this broadcast include locale and display density. 3220 * 3221 * <p class="note"> 3222 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through 3223 * components declared in manifests. However, the receiver <em>must</em> hold the 3224 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. 3225 * 3226 * <p class="note"> 3227 * This is a protected intent that can only be sent by the system. 3228 * 3229 * @hide 3230 */ 3231 @SystemApi 3232 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3233 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = 3234 "android.intent.action.SPLIT_CONFIGURATION_CHANGED"; 3235 /** 3236 * Broadcast Action: The receiver's effective locale has changed. 3237 * 3238 * This happens when the device locale, the receiving app's locale 3239 * (set via {@link android.app.LocaleManager#setApplicationLocales}) or language tags 3240 * of Regional preferences changed. 3241 * 3242 * Can be received by manifest-declared receivers. 3243 * 3244 * <p class="note"> If only the app locale changed, includes the following extras: 3245 * <ul> 3246 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed. 3247 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app 3248 * </ul> 3249 * 3250 * <p class="note">This is a protected intent that can only be sent 3251 * by the system. 3252 */ 3253 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3254 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; 3255 /** 3256 * Broadcast Action: Locale of a particular app has changed. 3257 * 3258 * <p class="note"> This broadcast is explicitly sent to the 3259 * {@link android.content.pm.InstallSourceInfo#getInstallingPackageName} installer 3260 * of the app whose locale has changed. 3261 * <p class="note"> The broadcast could also be received by manifest-declared receivers with 3262 * {@code android.permission.READ_APP_SPECIFIC_LOCALES} 3263 * 3264 * <p class="note">This is a protected intent that can only be sent 3265 * by the system. 3266 * 3267 * <p>Includes the following extras: 3268 * <ul> 3269 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed. 3270 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app 3271 * </ul> 3272 */ 3273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3274 public static final String ACTION_APPLICATION_LOCALE_CHANGED = 3275 "android.intent.action.APPLICATION_LOCALE_CHANGED"; 3276 /** 3277 * Broadcast Action: This is a <em>sticky broadcast</em> containing the 3278 * charging state, level, and other information about the battery. 3279 * See {@link android.os.BatteryManager} for documentation on the 3280 * contents of the Intent. 3281 * 3282 * <p class="note"> 3283 * You <em>cannot</em> receive this through components declared 3284 * in manifests, only by explicitly registering for it with 3285 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3286 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, 3287 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, 3288 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related 3289 * broadcasts that are sent and can be received through manifest 3290 * receivers. 3291 * 3292 * <p class="note">This is a protected intent that can only be sent 3293 * by the system. 3294 */ 3295 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3296 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; 3297 3298 3299 /** 3300 * Broadcast Action: Sent when the current battery level or plug type changes. 3301 * 3302 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle} 3303 * instances representing individual battery level changes with associated 3304 * extras from {@link #ACTION_BATTERY_CHANGED}. 3305 * 3306 * <p class="note"> 3307 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission. 3308 * 3309 * @hide 3310 */ 3311 @SystemApi 3312 public static final String ACTION_BATTERY_LEVEL_CHANGED = 3313 "android.intent.action.BATTERY_LEVEL_CHANGED"; 3314 /** 3315 * Broadcast Action: Indicates low battery condition on the device. 3316 * This broadcast corresponds to the "Low battery warning" system dialog. 3317 * 3318 * <p class="note">This is a protected intent that can only be sent 3319 * by the system. 3320 */ 3321 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3322 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; 3323 /** 3324 * Broadcast Action: Indicates the battery is now okay after being low. 3325 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has 3326 * gone back up to an okay state. 3327 * 3328 * <p class="note">This is a protected intent that can only be sent 3329 * by the system. 3330 */ 3331 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3332 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; 3333 /** 3334 * Broadcast Action: External power has been connected to the device. 3335 * This is intended for applications that wish to register specifically to this notification. 3336 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3337 * stay active to receive this notification. This action can be used to implement actions 3338 * that wait until power is available to trigger. 3339 * 3340 * <p class="note">This is a protected intent that can only be sent 3341 * by the system. 3342 */ 3343 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3344 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; 3345 /** 3346 * Broadcast Action: External power has been removed from the device. 3347 * This is intended for applications that wish to register specifically to this notification. 3348 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3349 * stay active to receive this notification. This action can be used to implement actions 3350 * that wait until power is available to trigger. 3351 * 3352 * <p class="note">This is a protected intent that can only be sent 3353 * by the system. 3354 */ 3355 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3356 public static final String ACTION_POWER_DISCONNECTED = 3357 "android.intent.action.ACTION_POWER_DISCONNECTED"; 3358 /** 3359 * Broadcast Action: Device is shutting down. 3360 * This is broadcast when the device is being shut down (completely turned 3361 * off, not sleeping). Once the broadcast is complete, the final shutdown 3362 * will proceed and all unsaved data lost. Apps will not normally need 3363 * to handle this, since the foreground activity will be paused as well. 3364 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered 3365 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3366 * Context.registerReceiver}. 3367 * 3368 * <p class="note">This is a protected intent that can only be sent 3369 * by the system. 3370 * <p>May include the following extras: 3371 * <ul> 3372 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this 3373 * shutdown is only for userspace processes. If not set, assumed to be false. 3374 * </ul> 3375 */ 3376 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3377 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; 3378 /** 3379 * Activity Action: Start this activity to request system shutdown. 3380 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true 3381 * to request confirmation from the user before shutting down. The optional boolean 3382 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to 3383 * indicate that the shutdown is requested by the user. 3384 * 3385 * <p class="note">This is a protected intent that can only be sent 3386 * by the system. 3387 * 3388 * {@hide} 3389 */ 3390 public static final String ACTION_REQUEST_SHUTDOWN 3391 = "com.android.internal.intent.action.REQUEST_SHUTDOWN"; 3392 /** 3393 * Broadcast Action: A sticky broadcast that indicates low storage space 3394 * condition on the device 3395 * <p class="note"> 3396 * This is a protected intent that can only be sent by the system. 3397 * 3398 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3399 * or above, this broadcast will no longer be delivered to any 3400 * {@link BroadcastReceiver} defined in your manifest. Instead, 3401 * apps are strongly encouraged to use the improved 3402 * {@link Context#getCacheDir()} behavior so the system can 3403 * automatically free up storage when needed. 3404 */ 3405 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3406 @Deprecated 3407 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; 3408 /** 3409 * Broadcast Action: Indicates low storage space condition on the device no 3410 * longer exists 3411 * <p class="note"> 3412 * This is a protected intent that can only be sent by the system. 3413 * 3414 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3415 * or above, this broadcast will no longer be delivered to any 3416 * {@link BroadcastReceiver} defined in your manifest. Instead, 3417 * apps are strongly encouraged to use the improved 3418 * {@link Context#getCacheDir()} behavior so the system can 3419 * automatically free up storage when needed. 3420 */ 3421 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3422 @Deprecated 3423 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; 3424 /** 3425 * Broadcast Action: A sticky broadcast that indicates a storage space full 3426 * condition on the device. This is intended for activities that want to be 3427 * able to fill the data partition completely, leaving only enough free 3428 * space to prevent system-wide SQLite failures. 3429 * <p class="note"> 3430 * This is a protected intent that can only be sent by the system. 3431 * 3432 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3433 * or above, this broadcast will no longer be delivered to any 3434 * {@link BroadcastReceiver} defined in your manifest. Instead, 3435 * apps are strongly encouraged to use the improved 3436 * {@link Context#getCacheDir()} behavior so the system can 3437 * automatically free up storage when needed. 3438 * @hide 3439 */ 3440 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3441 @Deprecated 3442 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; 3443 /** 3444 * Broadcast Action: Indicates storage space full condition on the device no 3445 * longer exists. 3446 * <p class="note"> 3447 * This is a protected intent that can only be sent by the system. 3448 * 3449 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3450 * or above, this broadcast will no longer be delivered to any 3451 * {@link BroadcastReceiver} defined in your manifest. Instead, 3452 * apps are strongly encouraged to use the improved 3453 * {@link Context#getCacheDir()} behavior so the system can 3454 * automatically free up storage when needed. 3455 * @hide 3456 */ 3457 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3458 @Deprecated 3459 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; 3460 /** 3461 * Broadcast Action: Indicates low memory condition notification acknowledged by user 3462 * and package management should be started. 3463 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW 3464 * notification. 3465 */ 3466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3467 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; 3468 /** 3469 * Broadcast Action: The device has entered USB Mass Storage mode. 3470 * This is used mainly for the USB Settings panel. 3471 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3472 * when the SD card file system is mounted or unmounted 3473 * @deprecated replaced by android.os.storage.StorageEventListener 3474 */ 3475 @Deprecated 3476 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3477 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; 3478 3479 /** 3480 * Broadcast Action: The device has exited USB Mass Storage mode. 3481 * This is used mainly for the USB Settings panel. 3482 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3483 * when the SD card file system is mounted or unmounted 3484 * @deprecated replaced by android.os.storage.StorageEventListener 3485 */ 3486 @Deprecated 3487 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3488 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; 3489 3490 /** 3491 * Broadcast Action: External media has been removed. 3492 * The path to the mount point for the removed media is contained in the Intent.mData field. 3493 */ 3494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3495 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; 3496 3497 /** 3498 * Broadcast Action: External media is present, but not mounted at its mount point. 3499 * The path to the mount point for the unmounted media is contained in the Intent.mData field. 3500 */ 3501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3502 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; 3503 3504 /** 3505 * Broadcast Action: External media is present, and being disk-checked 3506 * The path to the mount point for the checking media is contained in the Intent.mData field. 3507 */ 3508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3509 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; 3510 3511 /** 3512 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) 3513 * The path to the mount point for the checking media is contained in the Intent.mData field. 3514 */ 3515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3516 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; 3517 3518 /** 3519 * Broadcast Action: External media is present and mounted at its mount point. 3520 * The path to the mount point for the mounted media is contained in the Intent.mData field. 3521 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the 3522 * media was mounted read only. 3523 */ 3524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3525 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; 3526 3527 /** 3528 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. 3529 * The path to the mount point for the shared media is contained in the Intent.mData field. 3530 */ 3531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3532 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; 3533 3534 /** 3535 * Broadcast Action: External media is no longer being shared via USB mass storage. 3536 * The path to the mount point for the previously shared media is contained in the Intent.mData field. 3537 * 3538 * @hide 3539 */ 3540 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; 3541 3542 /** 3543 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. 3544 * The path to the mount point for the removed media is contained in the Intent.mData field. 3545 */ 3546 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3547 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; 3548 3549 /** 3550 * Broadcast Action: External media is present but cannot be mounted. 3551 * The path to the mount point for the unmountable media is contained in the Intent.mData field. 3552 */ 3553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3554 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; 3555 3556 /** 3557 * Broadcast Action: User has expressed the desire to remove the external storage media. 3558 * Applications should close all files they have open within the mount point when they receive this intent. 3559 * The path to the mount point for the media to be ejected is contained in the Intent.mData field. 3560 */ 3561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3562 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; 3563 3564 /** 3565 * Broadcast Action: The media scanner has started scanning a directory. 3566 * The path to the directory being scanned is contained in the Intent.mData field. 3567 */ 3568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3569 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; 3570 3571 /** 3572 * Broadcast Action: The media scanner has finished scanning a directory. 3573 * The path to the scanned directory is contained in the Intent.mData field. 3574 */ 3575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3576 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; 3577 3578 /** 3579 * Broadcast Action: Request the media scanner to scan a file and add it to 3580 * the media database. 3581 * <p> 3582 * The path to the file is contained in {@link Intent#getData()}. 3583 * 3584 * @deprecated Callers should migrate to inserting items directly into 3585 * {@link MediaStore}, where they will be automatically scanned 3586 * after each mutation. 3587 */ 3588 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3589 @Deprecated 3590 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; 3591 3592 /** 3593 * Broadcast Action: The "Media Button" was pressed. Includes a single 3594 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3595 * caused the broadcast. 3596 */ 3597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3598 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; 3599 3600 /** 3601 * Broadcast Action: The "Camera Button" was pressed. Includes a single 3602 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3603 * caused the broadcast. 3604 */ 3605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3606 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; 3607 3608 // *** NOTE: @todo(*) The following really should go into a more domain-specific 3609 // location; they are not general-purpose actions. 3610 3611 /** 3612 * Broadcast Action: A GTalk connection has been established. 3613 */ 3614 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3615 public static final String ACTION_GTALK_SERVICE_CONNECTED = 3616 "android.intent.action.GTALK_CONNECTED"; 3617 3618 /** 3619 * Broadcast Action: A GTalk connection has been disconnected. 3620 */ 3621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3622 public static final String ACTION_GTALK_SERVICE_DISCONNECTED = 3623 "android.intent.action.GTALK_DISCONNECTED"; 3624 3625 /** 3626 * Broadcast Action: An input method has been changed. 3627 */ 3628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3629 public static final String ACTION_INPUT_METHOD_CHANGED = 3630 "android.intent.action.INPUT_METHOD_CHANGED"; 3631 3632 /** 3633 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or 3634 * more radios have been turned off or on. The intent will have the following extra value:</p> 3635 * <ul> 3636 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, 3637 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been 3638 * turned off</li> 3639 * </ul> 3640 * 3641 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3642 */ 3643 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3644 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; 3645 3646 /** 3647 * Broadcast Action: Some content providers have parts of their namespace 3648 * where they publish new events or items that the user may be especially 3649 * interested in. For these things, they may broadcast this action when the 3650 * set of interesting items change. 3651 * 3652 * For example, GmailProvider sends this notification when the set of unread 3653 * mail in the inbox changes. 3654 * 3655 * <p>The data of the intent identifies which part of which provider 3656 * changed. When queried through the content resolver, the data URI will 3657 * return the data set in question. 3658 * 3659 * <p>The intent will have the following extra values: 3660 * <ul> 3661 * <li><em>count</em> - The number of items in the data set. This is the 3662 * same as the number of items in the cursor returned by querying the 3663 * data URI. </li> 3664 * </ul> 3665 * 3666 * This intent will be sent at boot (if the count is non-zero) and when the 3667 * data set changes. It is possible for the data set to change without the 3668 * count changing (for example, if a new unread message arrives in the same 3669 * sync operation in which a message is archived). The phone should still 3670 * ring/vibrate/etc as normal in this case. 3671 */ 3672 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3673 public static final String ACTION_PROVIDER_CHANGED = 3674 "android.intent.action.PROVIDER_CHANGED"; 3675 3676 /** 3677 * Broadcast Action: Wired Headset plugged in or unplugged. 3678 * 3679 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value 3680 * and documentation. 3681 * <p>If the minimum SDK version of your application is 3682 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer 3683 * to the <code>AudioManager</code> constant in your receiver registration code instead. 3684 */ 3685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3686 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG; 3687 3688 /** 3689 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> 3690 * <ul> 3691 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> 3692 * </ul> 3693 * 3694 * <p class="note">This is a protected intent that can only be sent 3695 * by the system. 3696 * 3697 * @hide 3698 */ 3699 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3700 public static final String ACTION_ADVANCED_SETTINGS_CHANGED 3701 = "android.intent.action.ADVANCED_SETTINGS"; 3702 3703 /** 3704 * Broadcast Action: Sent after application restrictions are changed. 3705 * 3706 * <p class="note">This is a protected intent that can only be sent 3707 * by the system.</p> 3708 */ 3709 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3710 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = 3711 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; 3712 3713 /** 3714 * Broadcast Action: An outgoing call is about to be placed. 3715 * 3716 * <p>The Intent will have the following extra value:</p> 3717 * <ul> 3718 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - 3719 * the phone number originally intended to be dialed.</li> 3720 * </ul> 3721 * <p>Once the broadcast is finished, the resultData is used as the actual 3722 * number to call. If <code>null</code>, no call will be placed.</p> 3723 * <p>It is perfectly acceptable for multiple receivers to process the 3724 * outgoing call in turn: for example, a parental control application 3725 * might verify that the user is authorized to place the call at that 3726 * time, then a number-rewriting application might add an area code if 3727 * one was not specified.</p> 3728 * <p>For consistency, any receiver whose purpose is to prohibit phone 3729 * calls should have a priority of 0, to ensure it will see the final 3730 * phone number to be dialed. 3731 * Any receiver whose purpose is to rewrite phone numbers to be called 3732 * should have a positive priority. 3733 * Negative priorities are reserved for the system for this broadcast; 3734 * using them may cause problems.</p> 3735 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> 3736 * abort the broadcast.</p> 3737 * <p>Emergency calls cannot be intercepted using this mechanism, and 3738 * other calls cannot be modified to call emergency numbers using this 3739 * mechanism. 3740 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing 3741 * call to use their own service instead. Those apps should first prevent 3742 * the call from being placed by setting resultData to <code>null</code> 3743 * and then start their own app to make the call. 3744 * <p>You must hold the 3745 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} 3746 * permission to receive this Intent.</p> 3747 * 3748 * <p class="note">This is a protected intent that can only be sent 3749 * by the system. 3750 * 3751 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to 3752 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast. 3753 * This means that attempts to re-write the outgoing call by other apps using this intent will 3754 * be ignored. 3755 * </p> 3756 * 3757 * @deprecated Apps that redirect outgoing calls should use the 3758 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening 3759 * should use the {@link android.telecom.CallScreeningService} API. Apps which need to be 3760 * notified of basic call state should use 3761 * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine 3762 * when a new outgoing call is placed. 3763 */ 3764 @Deprecated 3765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3766 public static final String ACTION_NEW_OUTGOING_CALL = 3767 "android.intent.action.NEW_OUTGOING_CALL"; 3768 3769 /** 3770 * Broadcast Action: Have the device reboot. This is only for use by 3771 * system code. 3772 * 3773 * <p class="note">This is a protected intent that can only be sent 3774 * by the system. 3775 */ 3776 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3777 public static final String ACTION_REBOOT = 3778 "android.intent.action.REBOOT"; 3779 3780 /** 3781 * Broadcast Action: A sticky broadcast for changes in the physical 3782 * docking state of the device. 3783 * 3784 * <p>The intent will have the following extra values: 3785 * <ul> 3786 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock 3787 * state, indicating which dock the device is physically in.</li> 3788 * </ul> 3789 * <p>This is intended for monitoring the current physical dock state. 3790 * See {@link android.app.UiModeManager} for the normal API dealing with 3791 * dock mode changes. 3792 */ 3793 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3794 public static final String ACTION_DOCK_EVENT = 3795 "android.intent.action.DOCK_EVENT"; 3796 3797 /** 3798 * Broadcast Action: A broadcast when idle maintenance can be started. 3799 * This means that the user is not interacting with the device and is 3800 * not expected to do so soon. Typical use of the idle maintenance is 3801 * to perform somehow expensive tasks that can be postponed at a moment 3802 * when they will not degrade user experience. 3803 * <p> 3804 * <p class="note">In order to keep the device responsive in case of an 3805 * unexpected user interaction, implementations of a maintenance task 3806 * should be interruptible. In such a scenario a broadcast with action 3807 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you 3808 * should not do the maintenance work in 3809 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a 3810 * maintenance service by {@link Context#startService(Intent)}. Also 3811 * you should hold a wake lock while your maintenance service is running 3812 * to prevent the device going to sleep. 3813 * </p> 3814 * <p> 3815 * <p class="note">This is a protected intent that can only be sent by 3816 * the system. 3817 * </p> 3818 * 3819 * @see #ACTION_IDLE_MAINTENANCE_END 3820 * 3821 * @hide 3822 */ 3823 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3824 public static final String ACTION_IDLE_MAINTENANCE_START = 3825 "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; 3826 3827 /** 3828 * Broadcast Action: A broadcast when idle maintenance should be stopped. 3829 * This means that the user was not interacting with the device as a result 3830 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} 3831 * was sent and now the user started interacting with the device. Typical 3832 * use of the idle maintenance is to perform somehow expensive tasks that 3833 * can be postponed at a moment when they will not degrade user experience. 3834 * <p> 3835 * <p class="note">In order to keep the device responsive in case of an 3836 * unexpected user interaction, implementations of a maintenance task 3837 * should be interruptible. Hence, on receiving a broadcast with this 3838 * action, the maintenance task should be interrupted as soon as possible. 3839 * In other words, you should not do the maintenance work in 3840 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the 3841 * maintenance service that was started on receiving of 3842 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake 3843 * lock you acquired when your maintenance service started. 3844 * </p> 3845 * <p class="note">This is a protected intent that can only be sent 3846 * by the system. 3847 * 3848 * @see #ACTION_IDLE_MAINTENANCE_START 3849 * 3850 * @hide 3851 */ 3852 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3853 public static final String ACTION_IDLE_MAINTENANCE_END = 3854 "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; 3855 3856 /** 3857 * Broadcast Action: a remote intent is to be broadcasted. 3858 * 3859 * A remote intent is used for remote RPC between devices. The remote intent 3860 * is serialized and sent from one device to another device. The receiving 3861 * device parses the remote intent and broadcasts it. Note that anyone can 3862 * broadcast a remote intent. However, if the intent receiver of the remote intent 3863 * does not trust intent broadcasts from arbitrary intent senders, it should require 3864 * the sender to hold certain permissions so only trusted sender's broadcast will be 3865 * let through. 3866 * @hide 3867 */ 3868 public static final String ACTION_REMOTE_INTENT = 3869 "com.google.android.c2dm.intent.RECEIVE"; 3870 3871 /** 3872 * Broadcast Action: This is broadcast once when the user is booting after a 3873 * system update. It can be used to perform cleanup or upgrades after a 3874 * system update. 3875 * <p> 3876 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} 3877 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's 3878 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only 3879 * sent to receivers in the system image. 3880 * 3881 * @hide 3882 */ 3883 @SystemApi 3884 public static final String ACTION_PRE_BOOT_COMPLETED = 3885 "android.intent.action.PRE_BOOT_COMPLETED"; 3886 3887 /** 3888 * Broadcast to a specific application to query any supported restrictions to impose 3889 * on restricted users. The broadcast intent contains an extra 3890 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted 3891 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or 3892 * String[] depending on the restriction type.<p/> 3893 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, 3894 * which is of type <code>ArrayList<RestrictionEntry></code>. It can also 3895 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. 3896 * The activity specified by that intent will be launched for a result which must contain 3897 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. 3898 * The keys and values of the returned restrictions will be persisted. 3899 * @see RestrictionEntry 3900 */ 3901 public static final String ACTION_GET_RESTRICTION_ENTRIES = 3902 "android.intent.action.GET_RESTRICTION_ENTRIES"; 3903 3904 /** 3905 * Sent the first time a user is starting, to allow system apps to 3906 * perform one time initialization. (This will not be seen by third 3907 * party applications because a newly initialized user does not have any 3908 * third party applications installed for it.) This is sent early in 3909 * starting the user, around the time the home app is started, before 3910 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground 3911 * broadcast, since it is part of a visible user interaction; be as quick 3912 * as possible when handling it. 3913 */ 3914 public static final String ACTION_USER_INITIALIZE = 3915 "android.intent.action.USER_INITIALIZE"; 3916 3917 /** 3918 * Sent after a user switch is complete, if the switch caused the process's user to be 3919 * brought to the foreground. This is only sent to receivers registered 3920 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3921 * Context.registerReceiver}. It is sent to the user that is going to the 3922 * foreground. This is sent as a foreground 3923 * broadcast, since it is part of a visible user interaction; be as quick 3924 * as possible when handling it. 3925 */ 3926 public static final String ACTION_USER_FOREGROUND = 3927 "android.intent.action.USER_FOREGROUND"; 3928 3929 /** 3930 * Sent after a user switch is complete, if the switch caused the process's user to be 3931 * sent to the background. This is only sent to receivers registered 3932 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3933 * Context.registerReceiver}. It is sent to the user that is going to the 3934 * background. This is sent as a foreground 3935 * broadcast, since it is part of a visible user interaction; be as quick 3936 * as possible when handling it. 3937 */ 3938 public static final String ACTION_USER_BACKGROUND = 3939 "android.intent.action.USER_BACKGROUND"; 3940 3941 /** 3942 * Broadcast sent to the system when a user is added. 3943 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the new user 3944 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 3945 * user's user ID). 3946 * It is sent to all running users. 3947 * You must hold {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3948 * @hide 3949 */ 3950 @SystemApi 3951 public static final String ACTION_USER_ADDED = 3952 "android.intent.action.USER_ADDED"; 3953 3954 /** 3955 * Broadcast sent by the system when a user is started. Carries an extra 3956 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only sent to 3957 * registered receivers, not manifest receivers. It is sent to the user 3958 * that has been started. This is sent as a foreground 3959 * broadcast, since it is part of a visible user interaction; be as quick 3960 * as possible when handling it. 3961 * 3962 * <p> 3963 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 3964 * received. For example, the user could have been removed, started or stopped already, 3965 * regardless of which broadcast you receive. Because of that, receivers should always check 3966 * the current state of the user. 3967 * @hide 3968 */ 3969 public static final String ACTION_USER_STARTED = 3970 "android.intent.action.USER_STARTED"; 3971 3972 /** 3973 * Broadcast sent when a user is in the process of starting. Carries an extra 3974 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only 3975 * sent to registered receivers, not manifest receivers. It is sent to all 3976 * users (including the one that is being started). You must hold 3977 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3978 * this broadcast. This is sent as a background broadcast, since 3979 * its result is not part of the primary UX flow; to safely keep track of 3980 * started/stopped state of a user you can use this in conjunction with 3981 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with 3982 * other user state broadcasts since those are foreground broadcasts so can 3983 * execute in a different order. 3984 * 3985 * <p> 3986 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 3987 * received. For example, the user could have been removed, started or stopped already, 3988 * regardless of which broadcast you receive. Because of that, receivers should always check 3989 * the current state of the user. 3990 * @hide 3991 */ 3992 public static final String ACTION_USER_STARTING = 3993 "android.intent.action.USER_STARTING"; 3994 3995 /** 3996 * Broadcast sent when a user is going to be stopped. Carries an extra 3997 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only 3998 * sent to registered receivers, not manifest receivers. It is sent to all 3999 * users (including the one that is being stopped). You must hold 4000 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 4001 * this broadcast. The user will not stop until all receivers have 4002 * handled the broadcast. This is sent as a background broadcast, since 4003 * its result is not part of the primary UX flow; to safely keep track of 4004 * started/stopped state of a user you can use this in conjunction with 4005 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with 4006 * other user state broadcasts since those are foreground broadcasts so can 4007 * execute in a different order. 4008 * <p> 4009 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4010 * received. For example, the user could have been removed, started or stopped already, 4011 * regardless of which broadcast you receive. Because of that, receivers should always check 4012 * the current state of the user. 4013 * @hide 4014 */ 4015 public static final String ACTION_USER_STOPPING = 4016 "android.intent.action.USER_STOPPING"; 4017 4018 /** 4019 * Broadcast sent to the system when a user is stopped. Carries an extra 4020 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is similar to 4021 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a 4022 * specific package. This is only sent to registered receivers, not manifest 4023 * receivers. It is sent to all running users <em>except</em> the one that 4024 * has just been stopped (which is no longer running). 4025 * 4026 * <p> 4027 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4028 * received. For example, the user could have been removed, started or stopped already, 4029 * regardless of which broadcast you receive. Because of that, receivers should always check 4030 * the current state of the user. 4031 * @hide 4032 */ 4033 @TestApi 4034 public static final String ACTION_USER_STOPPED = 4035 "android.intent.action.USER_STOPPED"; 4036 4037 /** 4038 * Broadcast sent to the system when a user is removed. 4039 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the user that 4040 * was removed 4041 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 4042 * user's user ID). 4043 * It is sent to all running users except the 4044 * one that has been removed. The user will not be completely removed until all receivers have 4045 * handled the broadcast. You must hold 4046 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 4047 * @hide 4048 */ 4049 @SystemApi 4050 public static final String ACTION_USER_REMOVED = 4051 "android.intent.action.USER_REMOVED"; 4052 4053 /** 4054 * Broadcast sent to the system when the user switches. 4055 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} 4056 * of the user to become the current one 4057 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 4058 * user's user ID). 4059 * This is only sent to registered receivers, not manifest receivers. 4060 * It is sent to all running users. 4061 * You must hold 4062 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 4063 * 4064 * <p> 4065 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4066 * received. For example, the user could have been removed, started or stopped already, 4067 * regardless of which broadcast you receive. Because of that, receivers should always check 4068 * the current state of the user. 4069 * @hide 4070 */ 4071 /* 4072 * This broadcast is sent after the user switch is complete. In case a task needs to be done 4073 * while the switch is happening (i.e. while the screen is frozen to hide UI jank), please use 4074 * ActivityManagerService.registerUserSwitchObserver method. 4075 */ 4076 @SystemApi 4077 public static final String ACTION_USER_SWITCHED = 4078 "android.intent.action.USER_SWITCHED"; 4079 4080 /** 4081 * Broadcast Action: Sent when the credential-encrypted private storage has 4082 * become unlocked for the target user. This is only sent to registered 4083 * receivers, not manifest receivers. 4084 * 4085 * <p> 4086 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4087 * received. For example, the user could have been removed, started or stopped already, 4088 * regardless of which broadcast you receive. Because of that, receivers should always check 4089 * the current state of the user. 4090 */ 4091 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4092 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; 4093 4094 /** 4095 * Broadcast sent to the system when a user's information changes. Carries an extra 4096 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. 4097 * This is only sent to registered receivers, not manifest receivers. It is sent to all users. 4098 * @hide 4099 */ 4100 public static final String ACTION_USER_INFO_CHANGED = 4101 "android.intent.action.USER_INFO_CHANGED"; 4102 4103 /** 4104 * Broadcast sent to the primary user when an associated managed profile is added (the profile 4105 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies 4106 * the {@link UserHandle} of the profile that was added. Only applications (for example 4107 * Launchers) that need to display merged content across both primary and managed profiles need 4108 * to worry about this broadcast. This is only sent to registered receivers, 4109 * not manifest receivers. 4110 */ 4111 public static final String ACTION_MANAGED_PROFILE_ADDED = 4112 "android.intent.action.MANAGED_PROFILE_ADDED"; 4113 4114 /** 4115 * Broadcast sent to the primary user when an associated managed profile is removed. 4116 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile 4117 * that was removed. 4118 * Only applications (for example Launchers) that need to display merged content across both 4119 * primary and managed profiles need to worry about this broadcast. This is only sent to 4120 * registered receivers, not manifest receivers. 4121 */ 4122 public static final String ACTION_MANAGED_PROFILE_REMOVED = 4123 "android.intent.action.MANAGED_PROFILE_REMOVED"; 4124 4125 /** 4126 * Broadcast sent to the primary user when the credential-encrypted private storage for 4127 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that 4128 * specifies the {@link UserHandle} of the profile that was unlocked. Only applications (for 4129 * example Launchers) that need to display merged content across both primary and managed 4130 * profiles need to worry about this broadcast. This is only sent to registered receivers, 4131 * not manifest receivers. 4132 */ 4133 public static final String ACTION_MANAGED_PROFILE_UNLOCKED = 4134 "android.intent.action.MANAGED_PROFILE_UNLOCKED"; 4135 4136 /** 4137 * Broadcast sent to the primary user when an associated managed profile has become available. 4138 * Currently this includes when the user disables quiet mode for the profile. Carries an extra 4139 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4140 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4141 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4142 */ 4143 public static final String ACTION_MANAGED_PROFILE_AVAILABLE = 4144 "android.intent.action.MANAGED_PROFILE_AVAILABLE"; 4145 4146 /** 4147 * Broadcast sent to the primary user when an associated managed profile has become unavailable. 4148 * Currently this includes when the user enables quiet mode for the profile. Carries an extra 4149 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4150 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4151 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4152 */ 4153 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = 4154 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; 4155 4156 /** 4157 * Broadcast sent to the parent user when an associated profile has been started and unlocked. 4158 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 4159 * This is only sent to registered receivers, not manifest receivers. 4160 */ 4161 public static final String ACTION_PROFILE_ACCESSIBLE = 4162 "android.intent.action.PROFILE_ACCESSIBLE"; 4163 4164 /** 4165 * Broadcast sent to the parent user when an associated profile has stopped. 4166 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 4167 * This is only sent to registered receivers, not manifest receivers. 4168 */ 4169 public static final String ACTION_PROFILE_INACCESSIBLE = 4170 "android.intent.action.PROFILE_INACCESSIBLE"; 4171 4172 /** 4173 * Broadcast sent to the parent user when an associated profile is removed. 4174 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile 4175 * that was removed. 4176 * 4177 * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_REMOVED} but functions as a 4178 * generic broadcast for all users of type {@link android.content.pm.UserInfo#isProfile()}}. 4179 * It is sent in addition to the {@link #ACTION_MANAGED_PROFILE_REMOVED} broadcast when a 4180 * managed user is removed. 4181 * 4182 * <p>Only applications (for example Launchers) that need to display merged content across both 4183 * the parent user and its associated profiles need to worry about this broadcast. 4184 * This is only sent to registered receivers created with {@link Context#registerReceiver}. 4185 * It is not sent to manifest receivers. 4186 */ 4187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4188 public static final String ACTION_PROFILE_REMOVED = 4189 "android.intent.action.PROFILE_REMOVED"; 4190 4191 /** 4192 * Broadcast sent to the parent user when an associated profile is added (the profile was 4193 * created and is ready to be used). 4194 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile 4195 * that was added. 4196 * 4197 * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_ADDED} but functions as a 4198 * generic broadcast for all users of type {@link android.content.pm.UserInfo#isProfile()}}. 4199 * It is sent in addition to the {@link #ACTION_MANAGED_PROFILE_ADDED} broadcast when a 4200 * managed user is added. 4201 * 4202 * <p>Only applications (for example Launchers) that need to display merged content across both 4203 * the parent user and its associated profiles need to worry about this broadcast. 4204 * This is only sent to registered receivers created with {@link Context#registerReceiver}. 4205 * It is not sent to manifest receivers. 4206 */ 4207 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4208 public static final String ACTION_PROFILE_ADDED = 4209 "android.intent.action.PROFILE_ADDED"; 4210 4211 /** 4212 * Broadcast sent to the system user when the 'device locked' state changes for any user. 4213 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which 4214 * the device was locked or unlocked. 4215 * 4216 * This is only sent to registered receivers. 4217 * 4218 * @hide 4219 */ 4220 public static final String ACTION_DEVICE_LOCKED_CHANGED = 4221 "android.intent.action.DEVICE_LOCKED_CHANGED"; 4222 4223 /** 4224 * Sent when the user taps on the clock widget in the system's "quick settings" area. 4225 */ 4226 public static final String ACTION_QUICK_CLOCK = 4227 "android.intent.action.QUICK_CLOCK"; 4228 4229 /** 4230 * Activity Action: Shows the brightness setting dialog. 4231 * @hide 4232 */ 4233 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = 4234 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; 4235 4236 /** 4237 * Activity Action: Shows the contrast setting dialog. 4238 * @hide 4239 */ 4240 public static final String ACTION_SHOW_CONTRAST_DIALOG = 4241 "com.android.intent.action.SHOW_CONTRAST_DIALOG"; 4242 4243 /** 4244 * Broadcast Action: A global button was pressed. Includes a single 4245 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 4246 * caused the broadcast. 4247 * @hide 4248 */ 4249 @SystemApi 4250 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; 4251 4252 /** 4253 * Broadcast Action: Sent when media resource is granted. 4254 * <p> 4255 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource 4256 * granted. 4257 * </p> 4258 * <p class="note"> 4259 * This is a protected intent that can only be sent by the system. 4260 * </p> 4261 * <p class="note"> 4262 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. 4263 * </p> 4264 * 4265 * @hide 4266 */ 4267 public static final String ACTION_MEDIA_RESOURCE_GRANTED = 4268 "android.intent.action.MEDIA_RESOURCE_GRANTED"; 4269 4270 /** 4271 * Broadcast Action: An overlay package has changed. The data contains the 4272 * name of the overlay package which has changed. This is broadcast on all 4273 * changes to the OverlayInfo returned by {@link 4274 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The 4275 * most common change is a state change that will change whether the 4276 * overlay is enabled or not. 4277 * @hide 4278 */ 4279 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; 4280 4281 /** 4282 * Activity Action: Allow the user to select and return one or more existing 4283 * documents. When invoked, the system will display the various 4284 * {@link DocumentsProvider} instances installed on the device, letting the 4285 * user interactively navigate through them. These documents include local 4286 * media, such as photos and video, and documents provided by installed 4287 * cloud storage providers. 4288 * <p> 4289 * Each document is represented as a {@code content://} URI backed by a 4290 * {@link DocumentsProvider}, which can be opened as a stream with 4291 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 4292 * {@link android.provider.DocumentsContract.Document} metadata. 4293 * <p> 4294 * All selected documents are returned to the calling application with 4295 * persistable read and write permission grants. If you want to maintain 4296 * access to the documents across device reboots, you need to explicitly 4297 * take the persistable permissions using 4298 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. 4299 * <p> 4300 * Callers must indicate the acceptable document MIME types through 4301 * {@link #setType(String)}. For example, to select photos, use 4302 * {@code image/*}. If multiple disjoint MIME types are acceptable, define 4303 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to 4304 * {@literal *}/*. 4305 * <p> 4306 * If the caller can handle multiple returned items (the user performing 4307 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} 4308 * to indicate this. 4309 * <p> 4310 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4311 * URIs that can be opened with 4312 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4313 * <p> 4314 * Callers can set a document URI through 4315 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4316 * location of documents navigator. System will do its best to launch the 4317 * navigator in the specified document if it's a folder, or the folder that 4318 * contains the specified document if not. 4319 * <p> 4320 * Output: The URI of the item that was picked, returned in 4321 * {@link #getData()}. This must be a {@code content://} URI so that any 4322 * receiver can access it. If multiple documents were selected, they are 4323 * returned in {@link #getClipData()}. 4324 * 4325 * @see DocumentsContract 4326 * @see #ACTION_OPEN_DOCUMENT_TREE 4327 * @see #ACTION_CREATE_DOCUMENT 4328 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4329 */ 4330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4331 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; 4332 4333 /** 4334 * Activity Action: Allow the user to create a new document. When invoked, 4335 * the system will display the various {@link DocumentsProvider} instances 4336 * installed on the device, letting the user navigate through them. The 4337 * returned document may be a newly created document with no content, or it 4338 * may be an existing document with the requested MIME type. 4339 * <p> 4340 * Each document is represented as a {@code content://} URI backed by a 4341 * {@link DocumentsProvider}, which can be opened as a stream with 4342 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 4343 * {@link android.provider.DocumentsContract.Document} metadata. 4344 * <p> 4345 * Callers must indicate the concrete MIME type of the document being 4346 * created by setting {@link #setType(String)}. This MIME type cannot be 4347 * changed after the document is created. 4348 * <p> 4349 * Callers can provide an initial display name through {@link #EXTRA_TITLE}, 4350 * but the user may change this value before creating the file. 4351 * <p> 4352 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4353 * URIs that can be opened with 4354 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4355 * <p> 4356 * Callers can set a document URI through 4357 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4358 * location of documents navigator. System will do its best to launch the 4359 * navigator in the specified document if it's a folder, or the folder that 4360 * contains the specified document if not. 4361 * <p> 4362 * Output: The URI of the item that was created. This must be a 4363 * {@code content://} URI so that any receiver can access it. 4364 * 4365 * @see DocumentsContract 4366 * @see #ACTION_OPEN_DOCUMENT 4367 * @see #ACTION_OPEN_DOCUMENT_TREE 4368 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4369 */ 4370 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4371 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; 4372 4373 /** 4374 * Activity Action: Allow the user to pick a directory subtree. When 4375 * invoked, the system will display the various {@link DocumentsProvider} 4376 * instances installed on the device, letting the user navigate through 4377 * them. Apps can fully manage documents within the returned directory. 4378 * <p> 4379 * To gain access to descendant (child, grandchild, etc) documents, use 4380 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and 4381 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} 4382 * with the returned URI. 4383 * <p> 4384 * Callers can set a document URI through 4385 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4386 * location of documents navigator. System will do its best to launch the 4387 * navigator in the specified document if it's a folder, or the folder that 4388 * contains the specified document if not. 4389 * <p> 4390 * Output: The URI representing the selected directory tree. 4391 * 4392 * @see DocumentsContract 4393 */ 4394 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4395 public static final String 4396 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; 4397 4398 4399 /** 4400 * Activity Action: Perform text translation. 4401 * <p> 4402 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate. 4403 * <p> 4404 * Output: nothing. 4405 */ 4406 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4407 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE"; 4408 4409 /** 4410 * Activity Action: Define the meaning of the selected word(s). 4411 * <p> 4412 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define. 4413 * <p> 4414 * Output: nothing. 4415 */ 4416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4417 public static final String ACTION_DEFINE = "android.intent.action.DEFINE"; 4418 4419 /** 4420 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or 4421 * exisiting sensor being disconnected. 4422 * 4423 * <p class="note">This is a protected intent that can only be sent by the system.</p> 4424 * 4425 * {@hide} 4426 */ 4427 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4428 public static final String 4429 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; 4430 4431 /** 4432 * Deprecated - use ACTION_FACTORY_RESET instead. 4433 * @hide 4434 * @removed 4435 */ 4436 @Deprecated 4437 @SystemApi 4438 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; 4439 4440 /** 4441 * Broadcast intent sent by the RecoverySystem to inform listeners that a global clear (wipe) 4442 * is about to be performed. 4443 * @hide 4444 */ 4445 @SystemApi 4446 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4447 public static final String ACTION_MASTER_CLEAR_NOTIFICATION 4448 = "android.intent.action.MASTER_CLEAR_NOTIFICATION"; 4449 4450 /** 4451 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4452 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4453 * 4454 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. 4455 * 4456 * @hide 4457 */ 4458 @Deprecated 4459 public static final String EXTRA_FORCE_MASTER_CLEAR = 4460 "android.intent.extra.FORCE_MASTER_CLEAR"; 4461 4462 /** 4463 * A broadcast action to trigger a factory reset. 4464 * 4465 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The 4466 * reason for the factory reset should be specified as {@link #EXTRA_REASON}. 4467 * 4468 * <p>Not for use by third-party applications. 4469 * 4470 * @see #EXTRA_FORCE_FACTORY_RESET 4471 * 4472 * {@hide} 4473 */ 4474 @SystemApi 4475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4476 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; 4477 4478 /** 4479 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4480 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4481 * 4482 * <p>Not for use by third-party applications. 4483 * 4484 * @hide 4485 */ 4486 @SystemApi 4487 public static final String EXTRA_FORCE_FACTORY_RESET = 4488 "android.intent.extra.FORCE_FACTORY_RESET"; 4489 4490 /** 4491 * Broadcast action: report that a settings element is being restored from backup. The intent 4492 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting, 4493 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE 4494 * is the value of that settings entry prior to the restore operation, and 4495 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been 4496 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three 4497 * values are represented as strings, the fourth one as int. 4498 * 4499 * <p>This broadcast is sent only for settings provider entries known to require special 4500 * handling around restore time to specific receivers. These entries are found in the 4501 * BROADCAST_ON_RESTORE table within the provider's backup agent implementation. 4502 * 4503 * @see #EXTRA_SETTING_NAME 4504 * @see #EXTRA_SETTING_PREVIOUS_VALUE 4505 * @see #EXTRA_SETTING_NEW_VALUE 4506 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT 4507 * {@hide} 4508 */ 4509 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4510 @SuppressLint("ActionValue") 4511 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; 4512 4513 /** 4514 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4515 * Contain the name of the restored setting. 4516 * {@hide} 4517 */ 4518 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4519 @SuppressLint("ActionValue") 4520 public static final String EXTRA_SETTING_NAME = "setting_name"; 4521 4522 /** 4523 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4524 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry prior to the restore 4525 * operation. 4526 * {@hide} 4527 */ 4528 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4529 @SuppressLint("ActionValue") 4530 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; 4531 4532 /** 4533 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4534 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry being restored. 4535 * {@hide} 4536 */ 4537 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4538 @SuppressLint("ActionValue") 4539 public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; 4540 4541 /** 4542 * Int intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4543 * Contain the version of the SDK that the setting has been restored from (corresponds to 4544 * {@link android.os.Build.VERSION#SDK_INT}). 4545 * {@hide} 4546 */ 4547 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4548 @SuppressLint("ActionValue") 4549 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int"; 4550 4551 /** 4552 * Activity Action: Process a piece of text. 4553 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. 4554 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> 4555 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> 4556 */ 4557 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4558 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; 4559 4560 /** 4561 * Broadcast Action: The sim card state has changed. 4562 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here 4563 * because TelephonyIntents is an internal class. 4564 * The intent will have following extras.</p> 4565 * <p> 4566 * @see #EXTRA_SIM_STATE 4567 * @see #EXTRA_SIM_LOCKED_REASON 4568 * @see #EXTRA_REBROADCAST_ON_UNLOCK 4569 * 4570 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or 4571 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4572 * 4573 * @hide 4574 */ 4575 @Deprecated 4576 @SystemApi 4577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4578 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED"; 4579 4580 /** 4581 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4582 * This will have one of the following intent values. 4583 * @see #SIM_STATE_UNKNOWN 4584 * @see #SIM_STATE_NOT_READY 4585 * @see #SIM_STATE_ABSENT 4586 * @see #SIM_STATE_PRESENT 4587 * @see #SIM_STATE_CARD_IO_ERROR 4588 * @see #SIM_STATE_CARD_RESTRICTED 4589 * @see #SIM_STATE_LOCKED 4590 * @see #SIM_STATE_READY 4591 * @see #SIM_STATE_IMSI 4592 * @see #SIM_STATE_LOADED 4593 * @hide 4594 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4595 */ 4596 public static final String EXTRA_SIM_STATE = "ss"; 4597 4598 /** 4599 * The intent value UNKNOWN represents the SIM state unknown 4600 * @hide 4601 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4602 */ 4603 public static final String SIM_STATE_UNKNOWN = "UNKNOWN"; 4604 4605 /** 4606 * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on 4607 * @hide 4608 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4609 */ 4610 public static final String SIM_STATE_NOT_READY = "NOT_READY"; 4611 4612 /** 4613 * The intent value ABSENT means the SIM card is missing 4614 * @hide 4615 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4616 */ 4617 public static final String SIM_STATE_ABSENT = "ABSENT"; 4618 4619 /** 4620 * The intent value PRESENT means the device has a SIM card inserted 4621 * @hide 4622 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4623 */ 4624 public static final String SIM_STATE_PRESENT = "PRESENT"; 4625 4626 /** 4627 * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error 4628 * @hide 4629 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4630 */ 4631 static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR"; 4632 4633 /** 4634 * The intent value CARD_RESTRICTED means card is present but not usable due to carrier 4635 * restrictions 4636 * @hide 4637 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4638 */ 4639 static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED"; 4640 4641 /** 4642 * The intent value LOCKED means the SIM is locked by PIN or by network 4643 * @hide 4644 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4645 */ 4646 public static final String SIM_STATE_LOCKED = "LOCKED"; 4647 4648 /** 4649 * The intent value READY means the SIM is ready to be accessed 4650 * @hide 4651 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4652 */ 4653 public static final String SIM_STATE_READY = "READY"; 4654 4655 /** 4656 * The intent value IMSI means the SIM IMSI is ready in property 4657 * @hide 4658 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4659 */ 4660 public static final String SIM_STATE_IMSI = "IMSI"; 4661 4662 /** 4663 * The intent value LOADED means all SIM records, including IMSI, are loaded 4664 * @hide 4665 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4666 */ 4667 public static final String SIM_STATE_LOADED = "LOADED"; 4668 4669 /** 4670 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4671 * This extra will have one of the following intent values. 4672 * <p> 4673 * @see #SIM_LOCKED_ON_PIN 4674 * @see #SIM_LOCKED_ON_PUK 4675 * @see #SIM_LOCKED_NETWORK 4676 * @see #SIM_ABSENT_ON_PERM_DISABLED 4677 * 4678 * @hide 4679 * @deprecated Use 4680 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4681 */ 4682 public static final String EXTRA_SIM_LOCKED_REASON = "reason"; 4683 4684 /** 4685 * The intent value PIN means the SIM is locked on PIN1 4686 * @hide 4687 * @deprecated Use 4688 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4689 */ 4690 public static final String SIM_LOCKED_ON_PIN = "PIN"; 4691 4692 /** 4693 * The intent value PUK means the SIM is locked on PUK1 4694 * @hide 4695 * @deprecated Use 4696 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4697 */ 4698 /* PUK means ICC is locked on PUK1 */ 4699 public static final String SIM_LOCKED_ON_PUK = "PUK"; 4700 4701 /** 4702 * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION 4703 * @hide 4704 * @deprecated Use 4705 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4706 */ 4707 public static final String SIM_LOCKED_NETWORK = "NETWORK"; 4708 4709 /** 4710 * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails 4711 * @hide 4712 * @deprecated Use 4713 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4714 */ 4715 public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED"; 4716 4717 /** 4718 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast 4719 * is a rebroadcast on unlock. Defaults to {@code false} if not specified. 4720 * 4721 * @hide 4722 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or 4723 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4724 */ 4725 public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock"; 4726 4727 /** 4728 * Broadcast Action: indicate that the phone service state has changed. 4729 * The intent will have the following extra values:</p> 4730 * <p> 4731 * @see #EXTRA_VOICE_REG_STATE 4732 * @see #EXTRA_DATA_REG_STATE 4733 * @see #EXTRA_VOICE_ROAMING_TYPE 4734 * @see #EXTRA_DATA_ROAMING_TYPE 4735 * @see #EXTRA_OPERATOR_ALPHA_LONG 4736 * @see #EXTRA_OPERATOR_ALPHA_SHORT 4737 * @see #EXTRA_OPERATOR_NUMERIC 4738 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG 4739 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT 4740 * @see #EXTRA_DATA_OPERATOR_NUMERIC 4741 * @see #EXTRA_MANUAL 4742 * @see #EXTRA_VOICE_RADIO_TECH 4743 * @see #EXTRA_DATA_RADIO_TECH 4744 * @see #EXTRA_CSS_INDICATOR 4745 * @see #EXTRA_NETWORK_ID 4746 * @see #EXTRA_SYSTEM_ID 4747 * @see #EXTRA_CDMA_ROAMING_INDICATOR 4748 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR 4749 * @see #EXTRA_EMERGENCY_ONLY 4750 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION 4751 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION 4752 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST 4753 * 4754 * <p class="note"> 4755 * Requires the READ_PHONE_STATE permission. 4756 * 4757 * <p class="note">This is a protected intent that can only be sent by the system. 4758 * @hide 4759 * @removed 4760 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper 4761 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and 4762 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState 4763 * for a given subscription id and field with a ContentObserver or using JobScheduler. 4764 */ 4765 @Deprecated 4766 @SystemApi 4767 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 4768 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE"; 4769 4770 /** 4771 * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService} 4772 * for querying Data Loader Service providers. Data loader service providers register this 4773 * intent filter in their manifests, so that they can be looked up and bound to by 4774 * {@code DataLoaderManagerService}. 4775 * 4776 * <p class="note">This is a protected intent that can only be sent by the system. 4777 * 4778 * Data loader service providers must be privileged apps. 4779 * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such 4780 * data loader service provider. 4781 * 4782 * @hide 4783 */ 4784 @SystemApi 4785 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) 4786 public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA"; 4787 4788 /** 4789 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration 4790 * state. 4791 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4792 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4793 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4794 * @see android.telephony.ServiceState#STATE_POWER_OFF 4795 * @hide 4796 * @removed 4797 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}. 4798 */ 4799 @Deprecated 4800 @SystemApi 4801 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState"; 4802 4803 /** 4804 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state. 4805 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4806 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4807 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4808 * @see android.telephony.ServiceState#STATE_POWER_OFF 4809 * @hide 4810 * @removed 4811 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}. 4812 */ 4813 @Deprecated 4814 @SystemApi 4815 public static final String EXTRA_DATA_REG_STATE = "dataRegState"; 4816 4817 /** 4818 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming 4819 * type. 4820 * @hide 4821 * @removed 4822 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}. 4823 */ 4824 @Deprecated 4825 @SystemApi 4826 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType"; 4827 4828 /** 4829 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming 4830 * type. 4831 * @hide 4832 * @removed 4833 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}. 4834 */ 4835 @Deprecated 4836 @SystemApi 4837 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType"; 4838 4839 /** 4840 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4841 * registered voice operator name in long alphanumeric format. 4842 * {@code null} if the operator name is not known or unregistered. 4843 * @hide 4844 * @removed 4845 * @deprecated Use 4846 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}. 4847 */ 4848 @Deprecated 4849 @SystemApi 4850 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long"; 4851 4852 /** 4853 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4854 * registered voice operator name in short alphanumeric format. 4855 * {@code null} if the operator name is not known or unregistered. 4856 * @hide 4857 * @removed 4858 * @deprecated Use 4859 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}. 4860 */ 4861 @Deprecated 4862 @SystemApi 4863 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short"; 4864 4865 /** 4866 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4867 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile 4868 * network. 4869 * @hide 4870 * @removed 4871 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}. 4872 */ 4873 @Deprecated 4874 @SystemApi 4875 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric"; 4876 4877 /** 4878 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4879 * registered data operator name in long alphanumeric format. 4880 * {@code null} if the operator name is not known or unregistered. 4881 * @hide 4882 * @removed 4883 * @deprecated Use 4884 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}. 4885 */ 4886 @Deprecated 4887 @SystemApi 4888 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long"; 4889 4890 /** 4891 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4892 * registered data operator name in short alphanumeric format. 4893 * {@code null} if the operator name is not known or unregistered. 4894 * @hide 4895 * @removed 4896 * @deprecated Use 4897 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}. 4898 */ 4899 @Deprecated 4900 @SystemApi 4901 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short"; 4902 4903 /** 4904 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4905 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the 4906 * data operator. 4907 * @hide 4908 * @removed 4909 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}. 4910 */ 4911 @Deprecated 4912 @SystemApi 4913 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric"; 4914 4915 /** 4916 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current 4917 * network selection mode is manual. 4918 * Will be {@code true} if manual mode, {@code false} if automatic mode. 4919 * @hide 4920 * @removed 4921 * @deprecated Use 4922 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}. 4923 */ 4924 @Deprecated 4925 @SystemApi 4926 public static final String EXTRA_MANUAL = "manual"; 4927 4928 /** 4929 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice 4930 * radio technology. 4931 * @hide 4932 * @removed 4933 * @deprecated Use 4934 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}. 4935 */ 4936 @Deprecated 4937 @SystemApi 4938 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology"; 4939 4940 /** 4941 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data 4942 * radio technology. 4943 * @hide 4944 * @removed 4945 * @deprecated Use 4946 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}. 4947 */ 4948 @Deprecated 4949 @SystemApi 4950 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology"; 4951 4952 /** 4953 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service 4954 * support on CDMA network. 4955 * Will be {@code true} if support, {@code false} otherwise. 4956 * @hide 4957 * @removed 4958 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}. 4959 */ 4960 @Deprecated 4961 @SystemApi 4962 public static final String EXTRA_CSS_INDICATOR = "cssIndicator"; 4963 4964 /** 4965 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network 4966 * id. {@code Integer.MAX_VALUE} if unknown. 4967 * @hide 4968 * @removed 4969 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}. 4970 */ 4971 @Deprecated 4972 @SystemApi 4973 public static final String EXTRA_NETWORK_ID = "networkId"; 4974 4975 /** 4976 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id. 4977 * {@code Integer.MAX_VALUE} if unknown. 4978 * @hide 4979 * @removed 4980 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}. 4981 */ 4982 @Deprecated 4983 @SystemApi 4984 public static final String EXTRA_SYSTEM_ID = "systemId"; 4985 4986 /** 4987 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming 4988 * indicator if registered on a CDMA or EVDO system or {@code -1} if not. 4989 * @hide 4990 * @removed 4991 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}. 4992 */ 4993 @Deprecated 4994 @SystemApi 4995 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator"; 4996 4997 /** 4998 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming 4999 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not. 5000 * @hide 5001 * @removed 5002 * @deprecated Use 5003 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}. 5004 */ 5005 @Deprecated 5006 @SystemApi 5007 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator"; 5008 5009 /** 5010 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency 5011 * only mode. 5012 * {@code true} if in emergency only mode, {@code false} otherwise. 5013 * @hide 5014 * @removed 5015 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}. 5016 */ 5017 @Deprecated 5018 @SystemApi 5019 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly"; 5020 5021 /** 5022 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network 5023 * registration state is roaming. 5024 * {@code true} if registration indicates roaming, {@code false} otherwise 5025 * @hide 5026 * @removed 5027 * @deprecated Use 5028 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}. 5029 */ 5030 @Deprecated 5031 @SystemApi 5032 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION = 5033 "isDataRoamingFromRegistration"; 5034 5035 /** 5036 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier 5037 * aggregation is in use. 5038 * {@code true} if carrier aggregation is in use, {@code false} otherwise. 5039 * @hide 5040 * @removed 5041 * @deprecated Use 5042 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}. 5043 */ 5044 @Deprecated 5045 @SystemApi 5046 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation"; 5047 5048 /** 5049 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which 5050 * is reduced from the rsrp threshold while calculating signal strength level. 5051 * @hide 5052 * @removed 5053 */ 5054 @Deprecated 5055 @SystemApi 5056 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; 5057 5058 /** 5059 * The name of the extra used to define the text to be processed, as a 5060 * CharSequence. Note that this may be a styled CharSequence, so you must use 5061 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. 5062 */ 5063 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; 5064 /** 5065 * The name of the boolean extra used to define if the processed text will be used as read-only. 5066 */ 5067 public static final String EXTRA_PROCESS_TEXT_READONLY = 5068 "android.intent.extra.PROCESS_TEXT_READONLY"; 5069 5070 /** 5071 * Broadcast action: reports when a new thermal event has been reached. When the device 5072 * is reaching its maximum temperatue, the thermal level reported 5073 * {@hide} 5074 */ 5075 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5076 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; 5077 5078 /** {@hide} */ 5079 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; 5080 5081 /** 5082 * Thermal state when the device is normal. This state is sent in the 5083 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 5084 * {@hide} 5085 */ 5086 public static final int EXTRA_THERMAL_STATE_NORMAL = 0; 5087 5088 /** 5089 * Thermal state where the device is approaching its maximum threshold. This state is sent in 5090 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 5091 * {@hide} 5092 */ 5093 public static final int EXTRA_THERMAL_STATE_WARNING = 1; 5094 5095 /** 5096 * Thermal state where the device has reached its maximum threshold. This state is sent in the 5097 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 5098 * {@hide} 5099 */ 5100 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; 5101 5102 /** 5103 * Broadcast Action: Indicates the dock in idle state while device is docked. 5104 * 5105 * <p class="note">This is a protected intent that can only be sent 5106 * by the system. 5107 * 5108 * @hide 5109 */ 5110 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE"; 5111 5112 /** 5113 * Broadcast Action: Indicates the dock in active state while device is docked. 5114 * 5115 * <p class="note">This is a protected intent that can only be sent 5116 * by the system. 5117 * 5118 * @hide 5119 */ 5120 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE"; 5121 5122 /** 5123 * Broadcast Action: Indicates that a new device customization has been 5124 * downloaded and applied (packages installed, runtime resource overlays 5125 * enabled, xml files copied, ...), and that it is time for components that 5126 * need to for example clear their caches to do so now. 5127 * 5128 * @hide 5129 */ 5130 @SystemApi 5131 public static final String ACTION_DEVICE_CUSTOMIZATION_READY = 5132 "android.intent.action.DEVICE_CUSTOMIZATION_READY"; 5133 5134 5135 /** 5136 * Activity Action: Display an activity state associated with an unique {@link LocusId}. 5137 * 5138 * <p>For example, a chat app could use the context to resume a conversation between 2 users. 5139 * 5140 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the 5141 * app domain. Should be stable across reboots and backup / restore. 5142 * <p>Output: nothing. 5143 */ 5144 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5145 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS"; 5146 5147 /** 5148 * Activity Action: Starts a note-taking activity that can be used to create a note. This action 5149 * can be used to start an activity on the lock screen. Activity should ensure to appropriately 5150 * handle privacy sensitive data and features when launched on the lock screen. See 5151 * {@link android.app.KeyguardManager} for lock screen checks. 5152 */ 5153 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5154 public static final String ACTION_CREATE_NOTE = "android.intent.action.CREATE_NOTE"; 5155 5156 /** 5157 * A boolean extra used with {@link #ACTION_CREATE_NOTE} indicating whether the launched 5158 * note-taking activity should show a UI that is suitable to use with stylus input. 5159 */ 5160 public static final String EXTRA_USE_STYLUS_MODE = "android.intent.extra.USE_STYLUS_MODE"; 5161 5162 /** 5163 * Activity Action: Use with startActivityForResult to start a system activity that captures 5164 * content on the screen to take a screenshot and present it to the user for editing. The 5165 * edited screenshot is saved on device and returned to the calling activity as a {@link Uri} 5166 * through {@link #getData()}. User interaction is required to return the edited screenshot to 5167 * the calling activity. 5168 * 5169 * <p>This intent action requires the permission 5170 * {@link android.Manifest.permission#LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE}. 5171 * 5172 * <p>Callers should query 5173 * {@link StatusBarManager#canLaunchCaptureContentActivityForNote(Activity)} before showing a UI 5174 * element that allows users to trigger this flow. 5175 */ 5176 @RequiresPermission(Manifest.permission.LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE) 5177 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5178 public static final String ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE = 5179 "android.intent.action.LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE"; 5180 5181 /** 5182 * An int extra used by activity started with 5183 * {@link #ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE} to indicate status of the response. 5184 * This extra is used along with result code set to {@link android.app.Activity#RESULT_OK}. 5185 * 5186 * <p>The value for this extra can be one of the following: 5187 * <ul> 5188 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_SUCCESS}</li> 5189 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_FAILED}</li> 5190 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_USER_CANCELED}</li> 5191 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED}</li> 5192 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN}</li> 5193 * </ul> 5194 */ 5195 public static final String EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE = 5196 "android.intent.extra.CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE"; 5197 5198 /** 5199 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5200 * that the request was a success. 5201 * 5202 * <p>This code will only be returned after the user has interacted with the system screenshot 5203 * activity to consent to sharing the data with the note. 5204 * 5205 * <p>The captured screenshot is returned as a {@link Uri} through {@link #getData()}. 5206 */ 5207 public static final int CAPTURE_CONTENT_FOR_NOTE_SUCCESS = 0; 5208 5209 /** 5210 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5211 * that something went wrong. 5212 */ 5213 public static final int CAPTURE_CONTENT_FOR_NOTE_FAILED = 1; 5214 5215 /** 5216 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5217 * that user canceled the content capture flow. 5218 */ 5219 public static final int CAPTURE_CONTENT_FOR_NOTE_USER_CANCELED = 2; 5220 5221 /** 5222 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5223 * that the intent action {@link #ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE} was started 5224 * by an activity that is running in a non-supported window mode. 5225 */ 5226 public static final int CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED = 3; 5227 5228 /** 5229 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5230 * that screenshot is blocked by IT admin. 5231 */ 5232 public static final int CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN = 4; 5233 5234 /** @hide */ 5235 @IntDef(value = { 5236 CAPTURE_CONTENT_FOR_NOTE_SUCCESS, CAPTURE_CONTENT_FOR_NOTE_FAILED, 5237 CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED, 5238 CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN}) 5239 @Retention(RetentionPolicy.SOURCE) 5240 public @interface CaptureContentForNoteStatusCodes {} 5241 5242 /** 5243 * Broadcast Action: Sent to the integrity component when a package 5244 * needs to be verified. The data contains the package URI along with other relevant 5245 * information. 5246 * 5247 * <p class="note"> 5248 * This is a protected intent that can only be sent by the system. 5249 * </p> 5250 * 5251 * @hide 5252 */ 5253 @SystemApi 5254 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 5255 public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION = 5256 "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION"; 5257 5258 /** 5259 * Broadcast Action: Start the foreground service manager. 5260 * 5261 * <p class="note"> 5262 * This is a protected intent that can only be sent by the system. 5263 * </p> 5264 * 5265 * @hide 5266 */ 5267 public static final String ACTION_SHOW_FOREGROUND_SERVICE_MANAGER = 5268 "android.intent.action.SHOW_FOREGROUND_SERVICE_MANAGER"; 5269 5270 // --------------------------------------------------------------------- 5271 // --------------------------------------------------------------------- 5272 // Standard intent categories (see addCategory()). 5273 5274 /** 5275 * Set if the activity should be an option for the default action 5276 * (center press) to perform on a piece of data. Setting this will 5277 * hide from the user any activities without it set when performing an 5278 * action on some data. Note that this is normally -not- set in the 5279 * Intent when initiating an action -- it is for use in intent filters 5280 * specified in packages. 5281 */ 5282 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5283 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; 5284 /** 5285 * Activities that can be safely invoked from a browser must support this 5286 * category. For example, if the user is viewing a web page or an e-mail 5287 * and clicks on a link in the text, the Intent generated execute that 5288 * link will require the BROWSABLE category, so that only activities 5289 * supporting this category will be considered as possible actions. By 5290 * supporting this category, you are promising that there is nothing 5291 * damaging (without user intervention) that can happen by invoking any 5292 * matching Intent. 5293 */ 5294 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5295 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; 5296 /** 5297 * Categories for activities that can participate in voice interaction. 5298 * An activity that supports this category must be prepared to run with 5299 * no UI shown at all (though in some case it may have a UI shown), and 5300 * rely on {@link android.app.VoiceInteractor} to interact with the user. 5301 */ 5302 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5303 public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; 5304 /** 5305 * Set if the activity should be considered as an alternative action to 5306 * the data the user is currently viewing. See also 5307 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that 5308 * applies to the selection in a list of items. 5309 * 5310 * <p>Supporting this category means that you would like your activity to be 5311 * displayed in the set of alternative things the user can do, usually as 5312 * part of the current activity's options menu. You will usually want to 5313 * include a specific label in the <intent-filter> of this action 5314 * describing to the user what it does. 5315 * 5316 * <p>The action of IntentFilter with this category is important in that it 5317 * describes the specific action the target will perform. This generally 5318 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather 5319 * a specific name such as "com.android.camera.action.CROP. Only one 5320 * alternative of any particular action will be shown to the user, so using 5321 * a specific action like this makes sure that your alternative will be 5322 * displayed while also allowing other applications to provide their own 5323 * overrides of that particular action. 5324 */ 5325 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5326 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; 5327 /** 5328 * Set if the activity should be considered as an alternative selection 5329 * action to the data the user has currently selected. This is like 5330 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list 5331 * of items from which the user can select, giving them alternatives to the 5332 * default action that will be performed on it. 5333 */ 5334 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5335 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; 5336 /** 5337 * Intended to be used as a tab inside of a containing TabActivity. 5338 */ 5339 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5340 public static final String CATEGORY_TAB = "android.intent.category.TAB"; 5341 /** 5342 * Should be displayed in the top-level launcher. 5343 */ 5344 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5345 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; 5346 /** 5347 * Indicates an activity optimized for Leanback mode, and that should 5348 * be displayed in the Leanback launcher. 5349 */ 5350 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5351 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; 5352 /** 5353 * Indicates the preferred entry-point activity when an application is launched from a Car 5354 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a 5355 * fallback, or exclude the application entirely. 5356 * @hide 5357 */ 5358 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5359 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER"; 5360 /** 5361 * Used to indicate that the activity can be used in communal mode. 5362 * @hide 5363 */ 5364 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5365 public static final String CATEGORY_COMMUNAL_MODE = "android.intent.category.COMMUNAL_MODE"; 5366 /** 5367 * Indicates a Leanback settings activity to be displayed in the Leanback launcher. 5368 * @hide 5369 */ 5370 @SystemApi 5371 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; 5372 /** 5373 * Provides information about the package it is in; typically used if 5374 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide 5375 * a front-door to the user without having to be shown in the all apps list. 5376 */ 5377 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5378 public static final String CATEGORY_INFO = "android.intent.category.INFO"; 5379 /** 5380 * This is the home activity, that is the first activity that is displayed 5381 * when the device boots. 5382 */ 5383 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5384 public static final String CATEGORY_HOME = "android.intent.category.HOME"; 5385 /** 5386 * This is the home activity that is displayed when the device is finished setting up and ready 5387 * for use. 5388 * @hide 5389 */ 5390 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5391 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; 5392 /** 5393 * The home activity shown on secondary displays that support showing home activities. 5394 */ 5395 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5396 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME"; 5397 /** 5398 * This is the setup wizard activity, that is the first activity that is displayed 5399 * when the user sets up the device for the first time. 5400 * @hide 5401 */ 5402 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5403 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; 5404 /** 5405 * This is the home activity, that is the activity that serves as the launcher app 5406 * from there the user can start other apps. Often components with lower/higher 5407 * priority intent filters handle the home intent, for example SetupWizard, to 5408 * setup the device and we need to be able to distinguish the home app from these 5409 * setup helpers. 5410 * @hide 5411 */ 5412 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5413 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP"; 5414 /** 5415 * This activity is a preference panel. 5416 */ 5417 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5418 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; 5419 /** 5420 * This activity is a development preference panel. 5421 */ 5422 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5423 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; 5424 /** 5425 * Capable of running inside a parent activity container. 5426 */ 5427 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5428 public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; 5429 /** 5430 * This activity allows the user to browse and download new applications. 5431 */ 5432 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5433 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; 5434 /** 5435 * This activity may be exercised by the monkey or other automated test tools. 5436 */ 5437 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5438 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; 5439 /** 5440 * To be used as a test (not part of the normal user experience). 5441 */ 5442 public static final String CATEGORY_TEST = "android.intent.category.TEST"; 5443 /** 5444 * To be used as a unit test (run through the Test Harness). 5445 */ 5446 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; 5447 /** 5448 * To be used as a sample code example (not part of the normal user 5449 * experience). 5450 */ 5451 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; 5452 5453 /** 5454 * Used to indicate that an intent only wants URIs that can be opened with 5455 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs 5456 * must support at least the columns defined in {@link OpenableColumns} when 5457 * queried. 5458 * 5459 * @see #ACTION_GET_CONTENT 5460 * @see #ACTION_OPEN_DOCUMENT 5461 * @see #ACTION_CREATE_DOCUMENT 5462 */ 5463 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5464 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; 5465 5466 /** 5467 * Used to indicate that an intent filter can accept files which are not necessarily 5468 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but 5469 * at least streamable via 5470 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} 5471 * using one of the stream types exposed via 5472 * {@link ContentResolver#getStreamTypes(Uri, String)}. 5473 * 5474 * @see #ACTION_SEND 5475 * @see #ACTION_SEND_MULTIPLE 5476 */ 5477 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5478 public static final String CATEGORY_TYPED_OPENABLE = 5479 "android.intent.category.TYPED_OPENABLE"; 5480 5481 /** 5482 * To be used as code under test for framework instrumentation tests. 5483 */ 5484 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = 5485 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; 5486 /** 5487 * An activity to run when device is inserted into a car dock. 5488 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5489 * information, see {@link android.app.UiModeManager}. 5490 */ 5491 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5492 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; 5493 /** 5494 * An activity to run when device is inserted into a desk dock. 5495 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5496 * information, see {@link android.app.UiModeManager}. 5497 */ 5498 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5499 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; 5500 /** 5501 * An activity to run when device is inserted into a analog (low end) dock. 5502 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5503 * information, see {@link android.app.UiModeManager}. 5504 */ 5505 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5506 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; 5507 5508 /** 5509 * An activity to run when device is inserted into a digital (high end) dock. 5510 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5511 * information, see {@link android.app.UiModeManager}. 5512 */ 5513 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5514 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK"; 5515 5516 /** 5517 * Used to indicate that the activity can be used in a car environment. 5518 */ 5519 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5520 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; 5521 5522 /** 5523 * An activity to use for the launcher when the device is placed in a VR Headset viewer. 5524 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5525 * information, see {@link android.app.UiModeManager}. 5526 */ 5527 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5528 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; 5529 5530 /** 5531 * The accessibility shortcut is a global gesture for users with disabilities to trigger an 5532 * important for them accessibility feature to help developers determine whether they want to 5533 * make their activity a shortcut target. 5534 * <p> 5535 * An activity of interest to users with accessibility needs may request to be the target of 5536 * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category, 5537 * which will be dispatched by the system when the user activates the shortcut when it is 5538 * configured to point at this target. 5539 * </p> 5540 * <p> 5541 * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must 5542 * also do two things: 5543 * <ul> 5544 * <ol> 5545 * Specify that it handles the <code>android.intent.action.MAIN</code> 5546 * {@link android.content.Intent} 5547 * with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>. 5548 * </ol> 5549 * <ol> 5550 * Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the 5551 * manifest when declaring the activity. 5552 * </ol> 5553 * </ul> 5554 * If either of these items is missing, the system will ignore the accessibility shortcut 5555 * target. Following is an example declaration: 5556 * </p> 5557 * <pre> 5558 * <activity android:name=".MainActivity" 5559 * . . . 5560 * <intent-filter> 5561 * <action android:name="android.intent.action.MAIN" /> 5562 * <category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /> 5563 * </intent-filter> 5564 * <meta-data android:name="android.accessibilityshortcut.target" 5565 * android:resource="@xml/accessibilityshortcut" /> 5566 * </activity> 5567 * </pre> 5568 * <p> This is a sample XML file configuring a accessibility shortcut target: </p> 5569 * <pre> 5570 * <accessibility-shortcut-target 5571 * android:description="@string/shortcut_target_description" 5572 * android:summary="@string/shortcut_target_summary" 5573 * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" 5574 * android:htmlDescription="@string/shortcut_target_html_description" 5575 * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /> 5576 * </pre> 5577 * <p> 5578 * Both description and summary are necessary. The system will ignore the accessibility 5579 * shortcut target if they are missing. The animated image and html description are supported 5580 * to help users understand how to use the shortcut target. The settings activity is a 5581 * component name that allows the user to modify the settings for this accessibility shortcut 5582 * target. 5583 * </p> 5584 */ 5585 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5586 public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET = 5587 "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET"; 5588 // --------------------------------------------------------------------- 5589 // --------------------------------------------------------------------- 5590 // Application launch intent categories (see addCategory()). 5591 5592 /** 5593 * Used with {@link #ACTION_MAIN} to launch the browser application. 5594 * The activity should be able to browse the Internet. 5595 * <p>NOTE: This should not be used as the primary key of an Intent, 5596 * since it will not result in the app launching with the correct 5597 * action and category. Instead, use this with 5598 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5599 * Intent with this category in the selector.</p> 5600 */ 5601 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5602 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; 5603 5604 /** 5605 * Used with {@link #ACTION_MAIN} to launch the calculator application. 5606 * The activity should be able to perform standard arithmetic operations. 5607 * <p>NOTE: This should not be used as the primary key of an Intent, 5608 * since it will not result in the app launching with the correct 5609 * action and category. Instead, use this with 5610 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5611 * Intent with this category in the selector.</p> 5612 */ 5613 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5614 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; 5615 5616 /** 5617 * Used with {@link #ACTION_MAIN} to launch the calendar application. 5618 * The activity should be able to view and manipulate calendar entries. 5619 * <p>NOTE: This should not be used as the primary key of an Intent, 5620 * since it will not result in the app launching with the correct 5621 * action and category. Instead, use this with 5622 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5623 * Intent with this category in the selector.</p> 5624 */ 5625 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5626 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; 5627 5628 /** 5629 * Used with {@link #ACTION_MAIN} to launch the contacts application. 5630 * The activity should be able to view and manipulate address book entries. 5631 * <p>NOTE: This should not be used as the primary key of an Intent, 5632 * since it will not result in the app launching with the correct 5633 * action and category. Instead, use this with 5634 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5635 * Intent with this category in the selector.</p> 5636 */ 5637 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5638 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; 5639 5640 /** 5641 * Used with {@link #ACTION_MAIN} to launch the email application. 5642 * The activity should be able to send and receive email. 5643 * <p>NOTE: This should not be used as the primary key of an Intent, 5644 * since it will not result in the app launching with the correct 5645 * action and category. Instead, use this with 5646 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5647 * Intent with this category in the selector.</p> 5648 */ 5649 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5650 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; 5651 5652 /** 5653 * Used with {@link #ACTION_MAIN} to launch the gallery application. 5654 * The activity should be able to view and manipulate image and video files 5655 * stored on the device. 5656 * <p>NOTE: This should not be used as the primary key of an Intent, 5657 * since it will not result in the app launching with the correct 5658 * action and category. Instead, use this with 5659 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5660 * Intent with this category in the selector.</p> 5661 */ 5662 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5663 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; 5664 5665 /** 5666 * Used with {@link #ACTION_MAIN} to launch the maps application. 5667 * The activity should be able to show the user's current location and surroundings. 5668 * <p>NOTE: This should not be used as the primary key of an Intent, 5669 * since it will not result in the app launching with the correct 5670 * action and category. Instead, use this with 5671 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5672 * Intent with this category in the selector.</p> 5673 */ 5674 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5675 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; 5676 5677 /** 5678 * Used with {@link #ACTION_MAIN} to launch the messaging application. 5679 * The activity should be able to send and receive text messages. 5680 * <p>NOTE: This should not be used as the primary key of an Intent, 5681 * since it will not result in the app launching with the correct 5682 * action and category. Instead, use this with 5683 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5684 * Intent with this category in the selector.</p> 5685 */ 5686 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5687 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; 5688 5689 /** 5690 * Used with {@link #ACTION_MAIN} to launch the music application. 5691 * The activity should be able to play, browse, or manipulate music files 5692 * stored on the device. 5693 * <p>NOTE: This should not be used as the primary key of an Intent, 5694 * since it will not result in the app launching with the correct 5695 * action and category. Instead, use this with 5696 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5697 * Intent with this category in the selector.</p> 5698 */ 5699 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5700 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; 5701 5702 /** 5703 * Used with {@link #ACTION_MAIN} to launch the files application. 5704 * The activity should be able to browse and manage files stored on the device. 5705 * <p>NOTE: This should not be used as the primary key of an Intent, 5706 * since it will not result in the app launching with the correct 5707 * action and category. Instead, use this with 5708 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5709 * Intent with this category in the selector.</p> 5710 */ 5711 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5712 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES"; 5713 5714 /** 5715 * Used with {@link #ACTION_MAIN} to launch the weather application. 5716 * The activity should be able to give the user information about the weather 5717 * <p>NOTE: This should not be used as the primary key of an Intent, 5718 * since it will not result in the app launching with the correct 5719 * action and category. Instead, use this with 5720 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5721 * Intent with this category in the selector.</p> 5722 */ 5723 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5724 public static final String CATEGORY_APP_WEATHER = "android.intent.category.APP_WEATHER"; 5725 5726 /** 5727 * Used with {@link #ACTION_MAIN} to launch the fitness application. 5728 * The activity should be able to give the user fitness information and manage workouts 5729 * <p>NOTE: This should not be used as the primary key of an Intent, 5730 * since it will not result in the app launching with the correct 5731 * action and category. Instead, use this with 5732 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5733 * Intent with this category in the selector.</p> 5734 */ 5735 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5736 public static final String CATEGORY_APP_FITNESS = "android.intent.category.APP_FITNESS"; 5737 5738 // --------------------------------------------------------------------- 5739 // --------------------------------------------------------------------- 5740 // Standard extra data keys. 5741 5742 /** 5743 * The initial data to place in a newly created record. Use with 5744 * {@link #ACTION_INSERT}. The data here is a Map containing the same 5745 * fields as would be given to the underlying ContentProvider.insert() 5746 * call. 5747 */ 5748 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; 5749 5750 /** 5751 * A constant CharSequence that is associated with the Intent, used with 5752 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that 5753 * this may be a styled CharSequence, so you must use 5754 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to 5755 * retrieve it. 5756 */ 5757 public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; 5758 5759 /** 5760 * A constant String that is associated with the Intent, used with 5761 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} 5762 * as HTML formatted text. Note that you <em>must</em> also supply 5763 * {@link #EXTRA_TEXT}. 5764 */ 5765 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; 5766 5767 /** 5768 * A content: URI holding a stream of data associated with the Intent, 5769 * used with {@link #ACTION_SEND} to supply the data being sent. 5770 */ 5771 public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; 5772 5773 /** 5774 * A String[] holding e-mail addresses that should be delivered to. 5775 */ 5776 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; 5777 5778 /** 5779 * A String[] holding e-mail addresses that should be carbon copied. 5780 */ 5781 public static final String EXTRA_CC = "android.intent.extra.CC"; 5782 5783 /** 5784 * A String[] holding e-mail addresses that should be blind carbon copied. 5785 */ 5786 public static final String EXTRA_BCC = "android.intent.extra.BCC"; 5787 5788 /** 5789 * A constant string holding the desired subject line of a message. 5790 */ 5791 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; 5792 5793 /** 5794 * An Intent describing the choices you would like shown with 5795 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. 5796 */ 5797 public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; 5798 5799 /** 5800 * An int representing the user ID to be used. 5801 * 5802 * @hide 5803 */ 5804 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; 5805 5806 /** 5807 * An int representing the task id to be retrieved. This is used when a launch from recents is 5808 * intercepted by another action such as credentials confirmation to remember which task should 5809 * be resumed when complete. 5810 * 5811 * @hide 5812 */ 5813 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; 5814 5815 /** 5816 * A String[] holding attribution tags when used with 5817 * {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5818 * and ACTION_MANAGE_PERMISSION_USAGE 5819 * 5820 * E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc. 5821 */ 5822 public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS"; 5823 5824 /** 5825 * A long representing the start timestamp (epoch time in millis) of the permission usage 5826 * when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5827 * and ACTION_MANAGE_PERMISSION_USAGE 5828 */ 5829 public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME"; 5830 5831 /** 5832 * A long representing the end timestamp (epoch time in millis) of the permission usage when 5833 * used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5834 * and ACTION_MANAGE_PERMISSION_USAGE 5835 */ 5836 public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME"; 5837 5838 /** 5839 * A boolean extra, when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5840 * and {@link #ACTION_MANAGE_PERMISSION_USAGE}, 5841 * that specifies whether the permission usage system UI is showing attribution information 5842 * for the chosen entry. 5843 * 5844 * <p> The extra can only be true if application has specified attributionsAreUserVisible 5845 * in its manifest. </p> 5846 * 5847 * <p> Applications can use this extra to improve their permission usage explanation 5848 * experience. </p> 5849 * @hide 5850 */ 5851 @SystemApi 5852 public static final String EXTRA_SHOWING_ATTRIBUTION = 5853 "android.intent.extra.SHOWING_ATTRIBUTION"; 5854 5855 /** 5856 * An Intent[] describing additional, alternate choices you would like shown with 5857 * {@link #ACTION_CHOOSER}. 5858 * 5859 * <p>An app may be capable of providing several different payload types to complete a 5860 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos 5861 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer 5862 * several different supported sending mechanisms for sharing, such as the actual "image/*" 5863 * photo data or a hosted link where the photos can be viewed.</p> 5864 * 5865 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the 5866 * first/primary/preferred intent in the set. Additional intents specified in 5867 * this extra are ordered; by default intents that appear earlier in the array will be 5868 * preferred over intents that appear later in the array as matches for the same 5869 * target component. To alter this preference, a calling app may also supply 5870 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> 5871 */ 5872 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; 5873 5874 /** 5875 * A {@link ComponentName ComponentName[]} describing components that should be filtered out 5876 * and omitted from a list of components presented to the user. 5877 * 5878 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components 5879 * in this array if it otherwise would have shown them. Useful for omitting specific targets 5880 * from your own package or other apps from your organization if the idea of sending to those 5881 * targets would be redundant with other app functionality. Filtered components will not 5882 * be able to present targets from an associated <code>ChooserTargetService</code>.</p> 5883 */ 5884 public static final String EXTRA_EXCLUDE_COMPONENTS 5885 = "android.intent.extra.EXCLUDE_COMPONENTS"; 5886 5887 /** 5888 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} 5889 * describing additional high-priority deep-link targets for the chooser to present to the user. 5890 * 5891 * <p>Targets provided in this way will be presented inline with all other targets provided 5892 * by services from other apps. They will be prioritized before other service targets, but 5893 * after those targets provided by sources that the user has manually pinned to the front. 5894 * You can provide up to two targets on this extra (the limit of two targets 5895 * starts in Android 10).</p> 5896 * 5897 * @see #ACTION_CHOOSER 5898 */ 5899 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; 5900 5901 /** 5902 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection 5903 * from the chooser activity presented by {@link #ACTION_CHOOSER}. 5904 * 5905 * <p>An app preparing an action for another app to complete may wish to allow the user to 5906 * disambiguate between several options for completing the action based on the chosen target 5907 * or otherwise refine the action before it is invoked. 5908 * </p> 5909 * 5910 * <p>When sent, this IntentSender may be filled in with the following extras:</p> 5911 * <ul> 5912 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> 5913 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's 5914 * chosen target beyond the first</li> 5915 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity 5916 * should fill in and send once the disambiguation is complete</li> 5917 * </ul> 5918 */ 5919 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER 5920 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; 5921 5922 /** 5923 * A Parcelable[] of {@link ChooserAction} objects to provide the Android Sharesheet with 5924 * app-specific actions to be presented to the user when invoking {@link #ACTION_CHOOSER}. 5925 * You can provide as many as five custom actions. 5926 */ 5927 public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS = 5928 "android.intent.extra.CHOOSER_CUSTOM_ACTIONS"; 5929 5930 /** 5931 * Optional argument to be used with {@link #ACTION_CHOOSER}. 5932 * A {@link ChooserAction} to allow the user to modify what is being shared in some way. This 5933 * may be integrated into the content preview on sharesheets that have a preview UI. 5934 */ 5935 public static final String EXTRA_CHOOSER_MODIFY_SHARE_ACTION = 5936 "android.intent.extra.CHOOSER_MODIFY_SHARE_ACTION"; 5937 5938 /** 5939 * An {@code ArrayList} of {@code String} annotations describing content for 5940 * {@link #ACTION_CHOOSER}. 5941 * 5942 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a 5943 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> 5944 * 5945 * <p>Annotations should describe the major components or topics of the content. It is up to 5946 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be 5947 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to 5948 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon 5949 * character. Performance on customized annotations can suffer, if they are rarely used for 5950 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the 5951 * following annotations when applicable.</p> 5952 * <ul> 5953 * <li>"product" represents that the topic of the content is mainly about products, e.g., 5954 * health & beauty, and office supplies.</li> 5955 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g., 5956 * happy, and sad.</li> 5957 * <li>"person" represents that the topic of the content is mainly about persons, e.g., 5958 * face, finger, standing, and walking.</li> 5959 * <li>"child" represents that the topic of the content is mainly about children, e.g., 5960 * child, and baby.</li> 5961 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li> 5962 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li> 5963 * <li>"party" represents that the topic of the content is mainly about parties.</li> 5964 * <li>"animal" represent that the topic of the content is mainly about animals.</li> 5965 * <li>"plant" represents that the topic of the content is mainly about plants, e.g., 5966 * flowers.</li> 5967 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li> 5968 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g. 5969 * sunglasses, jewelry, handbags and clothing.</li> 5970 * <li>"material" represents that the topic of the content is mainly about materials, e.g., 5971 * paper, and silk.</li> 5972 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like 5973 * cars, and boats.</li> 5974 * <li>"document" represents that the topic of the content is mainly about documents, e.g. 5975 * posters.</li> 5976 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts 5977 * and designs of houses.</li> 5978 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g., 5979 * Christmas and Thanksgiving.</li> 5980 * </ul> 5981 */ 5982 public static final String EXTRA_CONTENT_ANNOTATIONS 5983 = "android.intent.extra.CONTENT_ANNOTATIONS"; 5984 5985 /** 5986 * A {@link ResultReceiver} used to return data back to the sender. 5987 * 5988 * <p>Used to complete an app-specific 5989 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> 5990 * 5991 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent 5992 * used to start a {@link #ACTION_CHOOSER} activity this extra will be 5993 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent 5994 * when the user selects a target component from the chooser. It is up to the recipient 5995 * to send a result to this ResultReceiver to signal that disambiguation is complete 5996 * and that the chooser should invoke the user's choice.</p> 5997 * 5998 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent 5999 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser 6000 * to match and fill in the final Intent or ChooserTarget before starting it. 6001 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from 6002 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to 6003 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> 6004 * 6005 * <p>The result code passed to the ResultReceiver should be 6006 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's 6007 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if 6008 * the chooser should finish without starting a target.</p> 6009 */ 6010 public static final String EXTRA_RESULT_RECEIVER 6011 = "android.intent.extra.RESULT_RECEIVER"; 6012 6013 /** 6014 * A CharSequence dialog title to provide to the user when used with a 6015 * {@link #ACTION_CHOOSER}. 6016 */ 6017 public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; 6018 6019 /** 6020 * A Parcelable[] of {@link Intent} or 6021 * {@link android.content.pm.LabeledIntent} objects as set with 6022 * {@link #putExtra(String, Parcelable[])} to place 6023 * at the front of the list of choices, when shown to the user with an 6024 * {@link #ACTION_CHOOSER}. You can choose up to two additional activities 6025 * to show before the app suggestions (the limit of two additional activities starts in 6026 * Android 10). 6027 */ 6028 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; 6029 6030 /** 6031 * A {@link IntentSender} to start after instant app installation success. 6032 * @hide 6033 */ 6034 @SystemApi 6035 public static final String EXTRA_INSTANT_APP_SUCCESS = 6036 "android.intent.extra.INSTANT_APP_SUCCESS"; 6037 6038 /** 6039 * A {@link IntentSender} to start after instant app installation failure. 6040 * @hide 6041 */ 6042 @SystemApi 6043 public static final String EXTRA_INSTANT_APP_FAILURE = 6044 "android.intent.extra.INSTANT_APP_FAILURE"; 6045 6046 /** 6047 * The host name that triggered an instant app resolution. 6048 * @hide 6049 */ 6050 @SystemApi 6051 public static final String EXTRA_INSTANT_APP_HOSTNAME = 6052 "android.intent.extra.INSTANT_APP_HOSTNAME"; 6053 6054 /** 6055 * An opaque token to track instant app resolution. 6056 * @hide 6057 */ 6058 @SystemApi 6059 public static final String EXTRA_INSTANT_APP_TOKEN = 6060 "android.intent.extra.INSTANT_APP_TOKEN"; 6061 6062 /** 6063 * The action that triggered an instant application resolution. 6064 * @hide 6065 */ 6066 @SystemApi 6067 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION"; 6068 6069 /** 6070 * An array of {@link Bundle}s containing details about resolved instant apps.. 6071 * @hide 6072 */ 6073 @SystemApi 6074 public static final String EXTRA_INSTANT_APP_BUNDLES = 6075 "android.intent.extra.INSTANT_APP_BUNDLES"; 6076 6077 /** 6078 * A {@link Bundle} of metadata that describes the instant application that needs to be 6079 * installed. This data is populated from the response to 6080 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered 6081 * instant application resolver. 6082 * @hide 6083 */ 6084 @SystemApi 6085 public static final String EXTRA_INSTANT_APP_EXTRAS = 6086 "android.intent.extra.INSTANT_APP_EXTRAS"; 6087 6088 /** 6089 * A boolean value indicating that the instant app resolver was unable to state with certainty 6090 * that it did or did not have an app for the sanitized {@link Intent} defined at 6091 * {@link #EXTRA_INTENT}. 6092 * @hide 6093 */ 6094 @SystemApi 6095 public static final String EXTRA_UNKNOWN_INSTANT_APP = 6096 "android.intent.extra.UNKNOWN_INSTANT_APP"; 6097 6098 /** 6099 * The version code of the app to install components from. 6100 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE). 6101 * @hide 6102 */ 6103 @Deprecated 6104 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; 6105 6106 /** 6107 * The version code of the app to install components from. 6108 * @hide 6109 */ 6110 @SystemApi 6111 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE"; 6112 6113 /** 6114 * The app that triggered the instant app installation. 6115 * @hide 6116 */ 6117 @SystemApi 6118 public static final String EXTRA_CALLING_PACKAGE 6119 = "android.intent.extra.CALLING_PACKAGE"; 6120 6121 /** 6122 * Optional calling app provided bundle containing additional launch information the 6123 * installer may use. 6124 * @hide 6125 */ 6126 @SystemApi 6127 public static final String EXTRA_VERIFICATION_BUNDLE 6128 = "android.intent.extra.VERIFICATION_BUNDLE"; 6129 6130 /** 6131 * A Bundle forming a mapping of potential target package names to different extras Bundles 6132 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with 6133 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not 6134 * be currently installed on the device. 6135 * 6136 * <p>An application may choose to provide alternate extras for the case where a user 6137 * selects an activity from a predetermined set of target packages. If the activity 6138 * the user selects from the chooser belongs to a package with its package name as 6139 * a key in this bundle, the corresponding extras for that package will be merged with 6140 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement 6141 * extra has the same key as an extra already present in the intent it will overwrite 6142 * the extra from the intent.</p> 6143 * 6144 * <p><em>Examples:</em> 6145 * <ul> 6146 * <li>An application may offer different {@link #EXTRA_TEXT} to an application 6147 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query 6148 * parameters for that target.</li> 6149 * <li>An application may offer additional metadata for known targets of a given intent 6150 * to pass along information only relevant to that target such as account or content 6151 * identifiers already known to that application.</li> 6152 * </ul></p> 6153 */ 6154 public static final String EXTRA_REPLACEMENT_EXTRAS = 6155 "android.intent.extra.REPLACEMENT_EXTRAS"; 6156 6157 /** 6158 * An {@link IntentSender} that will be notified if a user successfully chooses a target 6159 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender 6160 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the 6161 * {@link ComponentName} of the chosen component. 6162 * 6163 * <p>In some situations this callback may never come, for example if the user abandons 6164 * the chooser, switches to another task or any number of other reasons. Apps should not 6165 * be written assuming that this callback will always occur.</p> 6166 */ 6167 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = 6168 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; 6169 6170 /** 6171 * The {@link ComponentName} chosen by the user to complete an action. 6172 * 6173 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER 6174 */ 6175 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; 6176 6177 /** 6178 * A {@link android.view.KeyEvent} object containing the event that 6179 * triggered the creation of the Intent it is in. 6180 */ 6181 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; 6182 6183 /** 6184 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user 6185 * before shutting down. 6186 * 6187 * {@hide} 6188 */ 6189 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; 6190 6191 /** 6192 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is 6193 * requested by the user. 6194 * 6195 * {@hide} 6196 */ 6197 public static final String EXTRA_USER_REQUESTED_SHUTDOWN = 6198 "android.intent.extra.USER_REQUESTED_SHUTDOWN"; 6199 6200 /** 6201 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 6202 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action 6203 * of restarting the application. 6204 */ 6205 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; 6206 6207 /** 6208 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6209 * intents to signal that the application was removed with the user-initiated action. 6210 */ 6211 public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED"; 6212 6213 /** 6214 * A String holding the phone number originally entered in 6215 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual 6216 * number to call in a {@link android.content.Intent#ACTION_CALL}. 6217 */ 6218 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; 6219 6220 /** 6221 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} 6222 * intents to supply the uid the package had been assigned. Also an optional 6223 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 6224 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same 6225 * purpose. 6226 */ 6227 public static final String EXTRA_UID = "android.intent.extra.UID"; 6228 6229 /** 6230 * String array of package names. 6231 */ 6232 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; 6233 6234 /** 6235 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6236 * intents to indicate whether this represents a full uninstall (removing 6237 * both the code and its data) or a partial uninstall (leaving its data, 6238 * implying that this is an update). 6239 */ 6240 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; 6241 6242 /** 6243 * @hide 6244 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6245 * intents to indicate that at this point the package has been removed for 6246 * all users on the device. 6247 */ 6248 public static final String EXTRA_REMOVED_FOR_ALL_USERS 6249 = "android.intent.extra.REMOVED_FOR_ALL_USERS"; 6250 6251 /** 6252 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6253 * intents to indicate that this is a replacement of the package, so this 6254 * broadcast will immediately be followed by an add broadcast for a 6255 * different version of the same package. 6256 */ 6257 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING"; 6258 6259 /** 6260 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6261 * intents to indicate that this is a system update uninstall. 6262 * @hide 6263 */ 6264 public static final String EXTRA_SYSTEM_UPDATE_UNINSTALL = 6265 "android.intent.extra.SYSTEM_UPDATE_UNINSTALL"; 6266 6267 /** 6268 * Used as an int extra field in {@link android.app.AlarmManager} pending intents 6269 * to tell the application being invoked how many pending alarms are being 6270 * delivered with the intent. For one-shot alarms this will always be 1. 6271 * For recurring alarms, this might be greater than 1 if the device was 6272 * asleep or powered off at the time an earlier alarm would have been 6273 * delivered. 6274 * 6275 * <p>Note: You must supply a <b>mutable</b> {@link android.app.PendingIntent} to 6276 * {@code AlarmManager} while setting your alarms to be able to read this value on receiving 6277 * them. <em>Mutability of pending intents must be explicitly specified by apps targeting 6278 * {@link Build.VERSION_CODES#S} or higher</em>. 6279 * 6280 * @see android.app.PendingIntent#FLAG_MUTABLE 6281 * 6282 */ 6283 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; 6284 6285 /** 6286 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} 6287 * intents to request the dock state. Possible values are 6288 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, 6289 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or 6290 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or 6291 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or 6292 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. 6293 */ 6294 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; 6295 6296 /** 6297 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6298 * to represent that the phone is not in any dock. 6299 */ 6300 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; 6301 6302 /** 6303 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6304 * to represent that the phone is in a desk dock. 6305 */ 6306 public static final int EXTRA_DOCK_STATE_DESK = 1; 6307 6308 /** 6309 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6310 * to represent that the phone is in a car dock. 6311 */ 6312 public static final int EXTRA_DOCK_STATE_CAR = 2; 6313 6314 /** 6315 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6316 * to represent that the phone is in a analog (low end) dock. 6317 */ 6318 public static final int EXTRA_DOCK_STATE_LE_DESK = 3; 6319 6320 /** 6321 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6322 * to represent that the phone is in a digital (high end) dock. 6323 */ 6324 public static final int EXTRA_DOCK_STATE_HE_DESK = 4; 6325 6326 /** 6327 * Boolean that can be supplied as meta-data with a dock activity, to 6328 * indicate that the dock should take over the home key when it is active. 6329 */ 6330 public static final String METADATA_DOCK_HOME = "android.dock_home"; 6331 6332 /** 6333 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing 6334 * the bug report. 6335 */ 6336 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; 6337 6338 /** 6339 * Used in the extra field in the remote intent. It's a string token passed with the 6340 * remote intent. 6341 */ 6342 public static final String EXTRA_REMOTE_INTENT_TOKEN = 6343 "android.intent.extra.remote_intent_token"; 6344 6345 /** 6346 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field 6347 * will contain only the first name in the list. 6348 */ 6349 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = 6350 "android.intent.extra.changed_component_name"; 6351 6352 /** 6353 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, 6354 * and contains a string array of all of the components that have changed. If 6355 * the state of the overall package has changed, then it will contain an entry 6356 * with the package name itself. 6357 */ 6358 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = 6359 "android.intent.extra.changed_component_name_list"; 6360 6361 /** 6362 * This field is part of 6363 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 6364 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, 6365 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, 6366 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} 6367 * and contains a string array of all of the components that have changed. 6368 */ 6369 public static final String EXTRA_CHANGED_PACKAGE_LIST = 6370 "android.intent.extra.changed_package_list"; 6371 6372 /** 6373 * This field is part of 6374 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 6375 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 6376 * and contains an integer array of uids of all of the components 6377 * that have changed. 6378 */ 6379 public static final String EXTRA_CHANGED_UID_LIST = 6380 "android.intent.extra.changed_uid_list"; 6381 6382 /** 6383 * An integer denoting a bitwise combination of restrictions set on distracting packages via 6384 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)} 6385 * 6386 * @hide 6387 * @see PackageManager.DistractionRestriction 6388 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 6389 */ 6390 public static final String EXTRA_DISTRACTION_RESTRICTIONS = 6391 "android.intent.extra.distraction_restrictions"; 6392 6393 /** 6394 * @hide 6395 * Magic extra system code can use when binding, to give a label for 6396 * who it is that has bound to a service. This is an integer giving 6397 * a framework string resource that can be displayed to the user. 6398 */ 6399 public static final String EXTRA_CLIENT_LABEL = 6400 "android.intent.extra.client_label"; 6401 6402 /** 6403 * @hide 6404 * Magic extra system code can use when binding, to give a PendingIntent object 6405 * that can be launched for the user to disable the system's use of this 6406 * service. 6407 */ 6408 public static final String EXTRA_CLIENT_INTENT = 6409 "android.intent.extra.client_intent"; 6410 6411 /** 6412 * Extra used to indicate that an intent should only return data that is on 6413 * the local device. This is a boolean extra; the default is false. If true, 6414 * an implementation should only allow the user to select data that is 6415 * already on the device, not requiring it be downloaded from a remote 6416 * service when opened. 6417 * 6418 * @see #ACTION_GET_CONTENT 6419 * @see #ACTION_OPEN_DOCUMENT 6420 * @see #ACTION_OPEN_DOCUMENT_TREE 6421 * @see #ACTION_CREATE_DOCUMENT 6422 */ 6423 public static final String EXTRA_LOCAL_ONLY = 6424 "android.intent.extra.LOCAL_ONLY"; 6425 6426 /** 6427 * Extra used to indicate that an intent can allow the user to select and 6428 * return multiple items. This is a boolean extra; the default is false. If 6429 * true, an implementation is allowed to present the user with a UI where 6430 * they can pick multiple items that are all returned to the caller. When 6431 * this happens, they should be returned as the {@link #getClipData()} part 6432 * of the result Intent. 6433 * 6434 * @see #ACTION_GET_CONTENT 6435 * @see #ACTION_OPEN_DOCUMENT 6436 */ 6437 public static final String EXTRA_ALLOW_MULTIPLE = 6438 "android.intent.extra.ALLOW_MULTIPLE"; 6439 6440 /** 6441 * The user ID integer carried with broadcast intents related to addition, 6442 * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED}, 6443 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. 6444 * 6445 * @hide 6446 */ 6447 @SystemApi 6448 @SuppressLint("ActionValue") 6449 public static final String EXTRA_USER_HANDLE = 6450 "android.intent.extra.user_handle"; 6451 6452 /** 6453 * The {@link UserHandle} carried with intents. 6454 */ 6455 public static final String EXTRA_USER = 6456 "android.intent.extra.USER"; 6457 6458 /** 6459 * Extra used in the response from a BroadcastReceiver that handles 6460 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is 6461 * <code>ArrayList<RestrictionEntry></code>. 6462 */ 6463 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; 6464 6465 /** 6466 * Extra sent in the intent to the BroadcastReceiver that handles 6467 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing 6468 * the restrictions as key/value pairs. 6469 */ 6470 public static final String EXTRA_RESTRICTIONS_BUNDLE = 6471 "android.intent.extra.restrictions_bundle"; 6472 6473 /** 6474 * Extra used in the response from a BroadcastReceiver that handles 6475 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. 6476 */ 6477 public static final String EXTRA_RESTRICTIONS_INTENT = 6478 "android.intent.extra.restrictions_intent"; 6479 6480 /** 6481 * Extra used to communicate a set of acceptable MIME types. The type of the 6482 * extra is {@code String[]}. Values may be a combination of concrete MIME 6483 * types (such as "image/png") and/or partial MIME types (such as 6484 * "audio/*"). 6485 * 6486 * @see #ACTION_GET_CONTENT 6487 * @see #ACTION_OPEN_DOCUMENT 6488 */ 6489 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; 6490 6491 /** 6492 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that 6493 * this shutdown is only for the user space of the system, not a complete shutdown. 6494 * When this is true, hardware devices can use this information to determine that 6495 * they shouldn't do a complete shutdown of their device since this is not a 6496 * complete shutdown down to the kernel, but only user space restarting. 6497 * The default if not supplied is false. 6498 */ 6499 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY 6500 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; 6501 6502 /** 6503 * Optional extra specifying a time in milliseconds since the Epoch. The value must be 6504 * non-negative. 6505 * <p> 6506 * Type: long 6507 * </p> 6508 */ 6509 public static final String EXTRA_TIME = "android.intent.extra.TIME"; 6510 6511 /** 6512 * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device. 6513 * 6514 * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones. 6515 */ 6516 @SuppressLint("ActionValue") 6517 public static final String EXTRA_TIMEZONE = "time-zone"; 6518 6519 /** 6520 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the 6521 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, 6522 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and 6523 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative. 6524 * 6525 * @hide for internal use only. 6526 */ 6527 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = 6528 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; 6529 /** @hide */ 6530 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; 6531 /** @hide */ 6532 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; 6533 /** @hide */ 6534 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; 6535 6536 /** 6537 * Intent extra: the reason that the operation associated with this intent is being performed. 6538 * 6539 * <p>Type: String 6540 * @hide 6541 */ 6542 @SystemApi 6543 public static final String EXTRA_REASON = "android.intent.extra.REASON"; 6544 6545 /** 6546 * {@hide} 6547 * This extra will be send together with {@link #ACTION_FACTORY_RESET} 6548 */ 6549 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; 6550 6551 /** 6552 * {@hide} 6553 * This extra will be set to true when the user choose to wipe the data on eSIM during factory 6554 * reset for the device with eSIM. This extra will be sent together with 6555 * {@link #ACTION_FACTORY_RESET} 6556 */ 6557 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; 6558 6559 /** 6560 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM 6561 * activation request. 6562 * TODO: Add information about the structure and response data used with the pending intent. 6563 * @hide 6564 */ 6565 public static final String EXTRA_SIM_ACTIVATION_RESPONSE = 6566 "android.intent.extra.SIM_ACTIVATION_RESPONSE"; 6567 6568 /** 6569 * Optional index with semantics depending on the intent action. 6570 * 6571 * <p>The value must be an integer greater or equal to 0. 6572 * @see #ACTION_QUICK_VIEW 6573 */ 6574 public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; 6575 6576 /** 6577 * Tells the quick viewer to show additional UI actions suitable for the passed Uris, 6578 * such as opening in other apps, sharing, opening, editing, printing, deleting, 6579 * casting, etc. 6580 * 6581 * <p>The value is boolean. By default false. 6582 * @see #ACTION_QUICK_VIEW 6583 * @removed 6584 */ 6585 @Deprecated 6586 public static final String EXTRA_QUICK_VIEW_ADVANCED = 6587 "android.intent.extra.QUICK_VIEW_ADVANCED"; 6588 6589 /** 6590 * An optional extra of {@code String[]} indicating which quick view features should be made 6591 * available to the user in the quick view UI while handing a 6592 * {@link Intent#ACTION_QUICK_VIEW} intent. 6593 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer. 6594 * Quick viewer can implement features not listed below. 6595 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW}, 6596 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE}, 6597 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND}, 6598 * {@link QuickViewConstants#FEATURE_PRINT}. 6599 * <p> 6600 * Requirements: 6601 * <li>Quick viewer shouldn't show a feature if the feature is absent in 6602 * {@link #EXTRA_QUICK_VIEW_FEATURES}. 6603 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow 6604 * internal policies. 6605 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a 6606 * requirement that the feature be shown. Quick viewer may, according to its own policies, 6607 * disable or hide features. 6608 * 6609 * @see #ACTION_QUICK_VIEW 6610 */ 6611 public static final String EXTRA_QUICK_VIEW_FEATURES = 6612 "android.intent.extra.QUICK_VIEW_FEATURES"; 6613 6614 /** 6615 * Optional boolean extra indicating whether quiet mode has been switched on or off. 6616 * When a profile goes into quiet mode, all apps in the profile are killed and the 6617 * profile user is stopped. Widgets originating from the profile are masked, and app 6618 * launcher icons are grayed out. 6619 */ 6620 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; 6621 6622 /** 6623 * Optional CharSequence extra to provide a search query. 6624 * The format of this query is dependent on the receiving application. 6625 * 6626 * <p>Applicable to {@link Intent} with actions: 6627 * <ul> 6628 * <li>{@link Intent#ACTION_GET_CONTENT}</li> 6629 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li> 6630 * </ul> 6631 */ 6632 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY"; 6633 6634 /** 6635 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} 6636 * intents to specify the resource type granted. Possible values are 6637 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or 6638 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. 6639 * 6640 * @hide 6641 */ 6642 public static final String EXTRA_MEDIA_RESOURCE_TYPE = 6643 "android.intent.extra.MEDIA_RESOURCE_TYPE"; 6644 6645 /** 6646 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify 6647 * whether to show the chooser or not when there is only one application available 6648 * to choose from. 6649 */ 6650 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = 6651 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; 6652 6653 /** 6654 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6655 * to represent that a video codec is allowed to use. 6656 * 6657 * @hide 6658 */ 6659 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; 6660 6661 /** 6662 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6663 * to represent that a audio codec is allowed to use. 6664 * 6665 * @hide 6666 */ 6667 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; 6668 6669 /** 6670 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}. 6671 * 6672 * <p> 6673 * Type: {@link LocusId} 6674 * </p> 6675 */ 6676 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID"; 6677 6678 /** 6679 * Used as an int array extra field in 6680 * {@link android.content.Intent#ACTION_PACKAGE_REMOVED_INTERNAL} 6681 * intents to indicate that visibility allow list of this removed package. 6682 * 6683 * @hide 6684 */ 6685 public static final String EXTRA_VISIBILITY_ALLOW_LIST = 6686 "android.intent.extra.VISIBILITY_ALLOW_LIST"; 6687 6688 /** 6689 * A boolean extra used with {@link #ACTION_PACKAGE_DATA_CLEARED} which indicates if the intent 6690 * is broadcast as part of a restore operation. 6691 * 6692 * @hide 6693 */ 6694 public static final String EXTRA_IS_RESTORE = 6695 "android.intent.extra.IS_RESTORE"; 6696 6697 // --------------------------------------------------------------------- 6698 // --------------------------------------------------------------------- 6699 // Intent flags (see mFlags variable). 6700 6701 /** @hide */ 6702 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6703 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, 6704 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) 6705 @Retention(RetentionPolicy.SOURCE) 6706 public @interface GrantUriMode {} 6707 6708 /** @hide */ 6709 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6710 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) 6711 @Retention(RetentionPolicy.SOURCE) 6712 public @interface AccessUriMode {} 6713 6714 /** 6715 * Test if given mode flags specify an access mode, which must be at least 6716 * read and/or write. 6717 * 6718 * @hide 6719 */ isAccessUriMode(int modeFlags)6720 public static boolean isAccessUriMode(int modeFlags) { 6721 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION 6722 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; 6723 } 6724 6725 /** @hide */ 6726 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 6727 FLAG_GRANT_READ_URI_PERMISSION, 6728 FLAG_GRANT_WRITE_URI_PERMISSION, 6729 FLAG_FROM_BACKGROUND, 6730 FLAG_DEBUG_LOG_RESOLUTION, 6731 FLAG_EXCLUDE_STOPPED_PACKAGES, 6732 FLAG_INCLUDE_STOPPED_PACKAGES, 6733 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, 6734 FLAG_GRANT_PREFIX_URI_PERMISSION, 6735 FLAG_DEBUG_TRIAGED_MISSING, 6736 FLAG_IGNORE_EPHEMERAL, 6737 FLAG_ACTIVITY_MATCH_EXTERNAL, 6738 FLAG_ACTIVITY_NO_HISTORY, 6739 FLAG_ACTIVITY_SINGLE_TOP, 6740 FLAG_ACTIVITY_NEW_TASK, 6741 FLAG_ACTIVITY_MULTIPLE_TASK, 6742 FLAG_ACTIVITY_CLEAR_TOP, 6743 FLAG_ACTIVITY_FORWARD_RESULT, 6744 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 6745 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 6746 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 6747 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 6748 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 6749 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6750 FLAG_ACTIVITY_NEW_DOCUMENT, 6751 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6752 FLAG_ACTIVITY_NO_USER_ACTION, 6753 FLAG_ACTIVITY_REORDER_TO_FRONT, 6754 FLAG_ACTIVITY_NO_ANIMATION, 6755 FLAG_ACTIVITY_CLEAR_TASK, 6756 FLAG_ACTIVITY_TASK_ON_HOME, 6757 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 6758 FLAG_ACTIVITY_LAUNCH_ADJACENT, 6759 FLAG_ACTIVITY_REQUIRE_NON_BROWSER, 6760 FLAG_ACTIVITY_REQUIRE_DEFAULT, 6761 FLAG_RECEIVER_REGISTERED_ONLY, 6762 FLAG_RECEIVER_REPLACE_PENDING, 6763 FLAG_RECEIVER_FOREGROUND, 6764 FLAG_RECEIVER_NO_ABORT, 6765 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 6766 FLAG_RECEIVER_BOOT_UPGRADE, 6767 FLAG_RECEIVER_INCLUDE_BACKGROUND, 6768 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 6769 FLAG_RECEIVER_FROM_SHELL, 6770 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 6771 FLAG_RECEIVER_OFFLOAD, 6772 FLAG_RECEIVER_OFFLOAD_FOREGROUND, 6773 }) 6774 @Retention(RetentionPolicy.SOURCE) 6775 public @interface Flags {} 6776 6777 /** @hide */ 6778 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 6779 FLAG_FROM_BACKGROUND, 6780 FLAG_DEBUG_LOG_RESOLUTION, 6781 FLAG_EXCLUDE_STOPPED_PACKAGES, 6782 FLAG_INCLUDE_STOPPED_PACKAGES, 6783 FLAG_DEBUG_TRIAGED_MISSING, 6784 FLAG_IGNORE_EPHEMERAL, 6785 FLAG_ACTIVITY_MATCH_EXTERNAL, 6786 FLAG_ACTIVITY_NO_HISTORY, 6787 FLAG_ACTIVITY_SINGLE_TOP, 6788 FLAG_ACTIVITY_NEW_TASK, 6789 FLAG_ACTIVITY_MULTIPLE_TASK, 6790 FLAG_ACTIVITY_CLEAR_TOP, 6791 FLAG_ACTIVITY_FORWARD_RESULT, 6792 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 6793 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 6794 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 6795 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 6796 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 6797 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6798 FLAG_ACTIVITY_NEW_DOCUMENT, 6799 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6800 FLAG_ACTIVITY_NO_USER_ACTION, 6801 FLAG_ACTIVITY_REORDER_TO_FRONT, 6802 FLAG_ACTIVITY_NO_ANIMATION, 6803 FLAG_ACTIVITY_CLEAR_TASK, 6804 FLAG_ACTIVITY_TASK_ON_HOME, 6805 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 6806 FLAG_ACTIVITY_LAUNCH_ADJACENT, 6807 FLAG_RECEIVER_REGISTERED_ONLY, 6808 FLAG_RECEIVER_REPLACE_PENDING, 6809 FLAG_RECEIVER_FOREGROUND, 6810 FLAG_RECEIVER_NO_ABORT, 6811 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 6812 FLAG_RECEIVER_BOOT_UPGRADE, 6813 FLAG_RECEIVER_INCLUDE_BACKGROUND, 6814 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 6815 FLAG_RECEIVER_FROM_SHELL, 6816 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 6817 FLAG_RECEIVER_OFFLOAD, 6818 FLAG_RECEIVER_OFFLOAD_FOREGROUND, 6819 }) 6820 @Retention(RetentionPolicy.SOURCE) 6821 public @interface MutableFlags {} 6822 6823 /** 6824 * If set, the recipient of this Intent will be granted permission to 6825 * perform read operations on the URI in the Intent's data and any URIs 6826 * specified in its ClipData. When applying to an Intent's ClipData, 6827 * all URIs as well as recursive traversals through data or other ClipData 6828 * in Intent items will be granted; only the grant flags of the top-level 6829 * Intent are used. 6830 */ 6831 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; 6832 /** 6833 * If set, the recipient of this Intent will be granted permission to 6834 * perform write operations on the URI in the Intent's data and any URIs 6835 * specified in its ClipData. When applying to an Intent's ClipData, 6836 * all URIs as well as recursive traversals through data or other ClipData 6837 * in Intent items will be granted; only the grant flags of the top-level 6838 * Intent are used. 6839 */ 6840 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; 6841 /** 6842 * Can be set by the caller to indicate that this Intent is coming from 6843 * a background operation, not from direct user interaction. 6844 */ 6845 public static final int FLAG_FROM_BACKGROUND = 0x00000004; 6846 /** 6847 * A flag you can enable for debugging: when set, log messages will be 6848 * printed during the resolution of this intent to show you what has 6849 * been found to create the final resolved list. 6850 */ 6851 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; 6852 /** 6853 * If set, this intent will not match any components in packages that 6854 * are currently stopped. If this is not set, then the default behavior 6855 * is to include such applications in the result. 6856 */ 6857 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; 6858 /** 6859 * If set, this intent will always match any components in packages that 6860 * are currently stopped. This is the default behavior when 6861 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these 6862 * flags are set, this one wins (it allows overriding of exclude for 6863 * places where the framework may automatically set the exclude flag). 6864 */ 6865 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; 6866 6867 /** 6868 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 6869 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be 6870 * persisted across device reboots until explicitly revoked with 6871 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the 6872 * grant for possible persisting; the receiving application must call 6873 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to 6874 * actually persist. 6875 * 6876 * @see ContentResolver#takePersistableUriPermission(Uri, int) 6877 * @see ContentResolver#releasePersistableUriPermission(Uri, int) 6878 * @see ContentResolver#getPersistedUriPermissions() 6879 * @see ContentResolver#getOutgoingPersistedUriPermissions() 6880 */ 6881 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; 6882 6883 /** 6884 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 6885 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant 6886 * applies to any URI that is a prefix match against the original granted 6887 * URI. (Without this flag, the URI must match exactly for access to be 6888 * granted.) Another URI is considered a prefix match only when scheme, 6889 * authority, and all path segments defined by the prefix are an exact 6890 * match. 6891 */ 6892 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; 6893 6894 /** 6895 * Flag used to automatically match intents based on their Direct Boot 6896 * awareness and the current user state. 6897 * <p> 6898 * Since the default behavior is to automatically apply the current user 6899 * state, this is effectively a sentinel value that doesn't change the 6900 * output of any queries based on its presence or absence. 6901 * <p> 6902 * Instead, this value can be useful in conjunction with 6903 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()} 6904 * to detect when a caller is relying on implicit automatic matching, 6905 * instead of confirming the explicit behavior they want. 6906 */ 6907 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100; 6908 6909 /** {@hide} */ 6910 @Deprecated 6911 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO; 6912 6913 /** 6914 * Internal flag used to indicate ephemeral applications should not be 6915 * considered when resolving the intent. 6916 * 6917 * @hide 6918 */ 6919 public static final int FLAG_IGNORE_EPHEMERAL = 0x80000000; 6920 6921 /** 6922 * If set, the new activity is not kept in the history stack. As soon as 6923 * the user navigates away from it, the activity is finished. This may also 6924 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory 6925 * noHistory} attribute. 6926 * 6927 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} 6928 * is never invoked when the current activity starts a new activity which 6929 * sets a result and finishes. 6930 */ 6931 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; 6932 /** 6933 * If set, the activity will not be launched if it is already running 6934 * at the top of the history stack. See 6935 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes"> 6936 * Tasks and Back Stack</a> for more information. 6937 */ 6938 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; 6939 /** 6940 * If set, this activity will become the start of a new task on this 6941 * history stack. A task (from the activity that started it to the 6942 * next task activity) defines an atomic group of activities that the 6943 * user can move to. Tasks can be moved to the foreground and background; 6944 * all of the activities inside of a particular task always remain in 6945 * the same order. See 6946 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6947 * Stack</a> for more information about tasks. 6948 * 6949 * <p>This flag is generally used by activities that want 6950 * to present a "launcher" style behavior: they give the user a list of 6951 * separate things that can be done, which otherwise run completely 6952 * independently of the activity launching them. 6953 * 6954 * <p>When using this flag, if a task is already running for the activity 6955 * you are now starting, then a new activity will not be started; instead, 6956 * the current task will simply be brought to the front of the screen with 6957 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag 6958 * to disable this behavior. 6959 * 6960 * <p>This flag can not be used when the caller is requesting a result from 6961 * the activity being launched. 6962 */ 6963 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; 6964 /** 6965 * This flag is used to create a new task and launch an activity into it. 6966 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} 6967 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would 6968 * search through existing tasks for ones matching this Intent. Only if no such 6969 * task is found would a new task be created. When paired with 6970 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip 6971 * the search for a matching task and unconditionally start a new task. 6972 * 6973 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this 6974 * flag unless you are implementing your own 6975 * top-level application launcher.</strong> Used in conjunction with 6976 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the 6977 * behavior of bringing an existing task to the foreground. When set, 6978 * a new task is <em>always</em> started to host the Activity for the 6979 * Intent, regardless of whether there is already an existing task running 6980 * the same thing. 6981 * 6982 * <p><strong>Because the default system does not include graphical task management, 6983 * you should not use this flag unless you provide some way for a user to 6984 * return back to the tasks you have launched.</strong> 6985 * 6986 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for 6987 * creating new document tasks. 6988 * 6989 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or 6990 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. 6991 * 6992 * <p>See 6993 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6994 * Stack</a> for more information about tasks. 6995 * 6996 * @see #FLAG_ACTIVITY_NEW_DOCUMENT 6997 * @see #FLAG_ACTIVITY_NEW_TASK 6998 */ 6999 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; 7000 /** 7001 * If set, and the activity being launched is already running in the 7002 * current task, then instead of launching a new instance of that activity, 7003 * all of the other activities on top of it will be closed and this Intent 7004 * will be delivered to the (now on top) old activity as a new Intent. 7005 * 7006 * <p>For example, consider a task consisting of the activities: A, B, C, D. 7007 * If D calls startActivity() with an Intent that resolves to the component 7008 * of activity B, then C and D will be finished and B receive the given 7009 * Intent, resulting in the stack now being: A, B. 7010 * 7011 * <p>The currently running instance of activity B in the above example will 7012 * either receive the new intent you are starting here in its 7013 * onNewIntent() method, or be itself finished and restarted with the 7014 * new intent. If it has declared its launch mode to be "multiple" (the 7015 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in 7016 * the same intent, then it will be finished and re-created; for all other 7017 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this 7018 * Intent will be delivered to the current instance's onNewIntent(). 7019 * 7020 * <p>This launch mode can also be used to good effect in conjunction with 7021 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity 7022 * of a task, it will bring any currently running instance of that task 7023 * to the foreground, and then clear it to its root state. This is 7024 * especially useful, for example, when launching an activity from the 7025 * notification manager. 7026 * 7027 * <p>See 7028 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 7029 * Stack</a> for more information about tasks. 7030 */ 7031 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; 7032 /** 7033 * If set and this intent is being used to launch a new activity from an 7034 * existing one, then the reply target of the existing activity will be 7035 * transferred to the new activity. This way, the new activity can call 7036 * {@link android.app.Activity#setResult} and have that result sent back to 7037 * the reply target of the original activity. 7038 */ 7039 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; 7040 /** 7041 * If set and this intent is being used to launch a new activity from an 7042 * existing one, the current activity will not be counted as the top 7043 * activity for deciding whether the new intent should be delivered to 7044 * the top instead of starting a new one. The previous activity will 7045 * be used as the top, with the assumption being that the current activity 7046 * will finish itself immediately. 7047 */ 7048 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; 7049 /** 7050 * If set, the new activity is not kept in the list of recently launched 7051 * activities. 7052 */ 7053 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; 7054 /** 7055 * This flag is not normally set by application code, but set for you by 7056 * the system as described in the 7057 * {@link android.R.styleable#AndroidManifestActivity_launchMode 7058 * launchMode} documentation for the singleTask mode. 7059 */ 7060 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; 7061 /** 7062 * If set, and this activity is either being started in a new task or 7063 * bringing to the top an existing task, then it will be launched as 7064 * the front door of the task. This will result in the application of 7065 * any affinities needed to have that task in the proper state (either 7066 * moving activities to or from it), or simply resetting that task to 7067 * its initial state if needed. 7068 * 7069 * @see android.R.attr#allowTaskReparenting 7070 * @see android.R.attr#clearTaskOnLaunch 7071 * @see android.R.attr#finishOnTaskLaunch 7072 */ 7073 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; 7074 /** 7075 * This flag is not normally set by application code, but set for you by 7076 * the system if this activity is being launched from history. 7077 */ 7078 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; 7079 /** 7080 * @deprecated As of API 21 this performs identically to 7081 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. 7082 */ 7083 @Deprecated 7084 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; 7085 /** 7086 * This flag is used to open a document into a new task rooted at the activity launched 7087 * by this Intent. Through the use of this flag, or its equivalent attribute, 7088 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity 7089 * containing different documents will appear in the recent tasks list. 7090 * 7091 * <p>The use of the activity attribute form of this, 7092 * {@link android.R.attr#documentLaunchMode}, is 7093 * preferred over the Intent flag described here. The attribute form allows the 7094 * Activity to specify multiple document behavior for all launchers of the Activity 7095 * whereas using this flag requires each Intent that launches the Activity to specify it. 7096 * 7097 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for 7098 * it is kept after the activity is finished is different than the use of 7099 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if 7100 * this flag is being used to create a new recents entry, then by default that entry 7101 * will be removed once the activity is finished. You can modify this behavior with 7102 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. 7103 * 7104 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link 7105 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the 7106 * equivalent of the Activity manifest specifying {@link 7107 * android.R.attr#documentLaunchMode}="intoExisting". When used with 7108 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying 7109 * {@link android.R.attr#documentLaunchMode}="always". The flag is ignored even in 7110 * conjunction with {@link #FLAG_ACTIVITY_MULTIPLE_TASK} when the Activity manifest specifies 7111 * {@link android.R.attr#documentLaunchMode}="never". 7112 * 7113 * Refer to {@link android.R.attr#documentLaunchMode} for more information. 7114 * 7115 * @see android.R.attr#documentLaunchMode 7116 * @see #FLAG_ACTIVITY_MULTIPLE_TASK 7117 */ 7118 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; 7119 /** 7120 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} 7121 * callback from occurring on the current frontmost activity before it is 7122 * paused as the newly-started activity is brought to the front. 7123 * 7124 * <p>Typically, an activity can rely on that callback to indicate that an 7125 * explicit user action has caused their activity to be moved out of the 7126 * foreground. The callback marks an appropriate point in the activity's 7127 * lifecycle for it to dismiss any notifications that it intends to display 7128 * "until the user has seen them," such as a blinking LED. 7129 * 7130 * <p>If an activity is ever started via any non-user-driven events such as 7131 * phone-call receipt or an alarm handler, this flag should be passed to {@link 7132 * Context#startActivity Context.startActivity}, ensuring that the pausing 7133 * activity does not think the user has acknowledged its notification. 7134 */ 7135 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; 7136 /** 7137 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7138 * this flag will cause the launched activity to be brought to the front of its 7139 * task's history stack if it is already running. 7140 * 7141 * <p>For example, consider a task consisting of four activities: A, B, C, D. 7142 * If D calls startActivity() with an Intent that resolves to the component 7143 * of activity B, then B will be brought to the front of the history stack, 7144 * with this resulting order: A, C, D, B. 7145 * 7146 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also 7147 * specified. 7148 */ 7149 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; 7150 /** 7151 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7152 * this flag will prevent the system from applying an activity transition 7153 * animation to go to the next activity state. This doesn't mean an 7154 * animation will never run -- if another activity change happens that doesn't 7155 * specify this flag before the activity started here is displayed, then 7156 * that transition will be used. This flag can be put to good use 7157 * when you are going to do a series of activity operations but the 7158 * animation seen by the user shouldn't be driven by the first activity 7159 * change but rather a later one. 7160 */ 7161 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; 7162 /** 7163 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7164 * this flag will cause any existing task that would be associated with the 7165 * activity to be cleared before the activity is started. That is, the activity 7166 * becomes the new root of an otherwise empty task, and any old activities 7167 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 7168 */ 7169 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; 7170 /** 7171 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7172 * this flag will cause a newly launching task to be placed on top of the current 7173 * home activity task (if there is one). That is, pressing back from the task 7174 * will always return the user to home even if that was not the last activity they 7175 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 7176 */ 7177 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; 7178 /** 7179 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will 7180 * have its entry in recent tasks removed when the user closes it (with back 7181 * or however else it may finish()). If you would like to instead allow the 7182 * document to be kept in recents so that it can be re-launched, you can use 7183 * this flag. When set and the task's activity is finished, the recents 7184 * entry will remain in the interface for the user to re-launch it, like a 7185 * recents entry for a top-level application. 7186 * <p> 7187 * The receiving activity can override this request with 7188 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling 7189 * {@link android.app.Activity#finishAndRemoveTask() 7190 * Activity.finishAndRemoveTask()}. 7191 */ 7192 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; 7193 7194 /** 7195 * This flag is only used for split-screen multi-window mode. The new activity will be displayed 7196 * adjacent to the one launching it. This can only be used in conjunction with 7197 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is 7198 * required if you want a new instance of an existing activity to be created. 7199 */ 7200 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; 7201 7202 7203 /** 7204 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7205 * this flag will attempt to launch an instant app if no full app on the device can already 7206 * handle the intent. 7207 * <p> 7208 * When attempting to resolve instant apps externally, the following {@link Intent} properties 7209 * are supported: 7210 * <ul> 7211 * <li>{@link Intent#setAction(String)}</li> 7212 * <li>{@link Intent#addCategory(String)}</li> 7213 * <li>{@link Intent#setData(Uri)}</li> 7214 * <li>{@link Intent#setType(String)}</li> 7215 * <li>{@link Intent#setPackage(String)}</li> 7216 * <li>{@link Intent#addFlags(int)}</li> 7217 * </ul> 7218 * <p> 7219 * In the case that no instant app can be found, the installer will be launched to notify the 7220 * user that the intent could not be resolved. On devices that do not support instant apps, 7221 * the flag will be ignored. 7222 */ 7223 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800; 7224 7225 /** 7226 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 7227 * flag will only launch the intent if it resolves to a result that is not a browser. If no such 7228 * result exists, an {@link ActivityNotFoundException} will be thrown. 7229 */ 7230 public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400; 7231 7232 /** 7233 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 7234 * flag will only launch the intent if it resolves to a single result. If no such result exists 7235 * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException} 7236 * will be thrown. 7237 */ 7238 public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200; 7239 7240 /** 7241 * If set, when sending a broadcast only registered receivers will be 7242 * called -- no BroadcastReceiver components will be launched. 7243 */ 7244 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 7245 /** 7246 * If set, when sending a broadcast the new broadcast will replace 7247 * any existing pending broadcast that matches it. Matching is defined 7248 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning 7249 * true for the intents of the two broadcasts. When a match is found, 7250 * the new broadcast (and receivers associated with it) will replace the 7251 * existing one in the pending broadcast list, remaining at the same 7252 * position in the list. 7253 * 7254 * <p>This flag is most typically used with sticky broadcasts, which 7255 * only care about delivering the most recent values of the broadcast 7256 * to their receivers. 7257 */ 7258 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; 7259 /** 7260 * If set, when sending a broadcast the recipient is allowed to run at 7261 * foreground priority, with a shorter timeout interval. During normal 7262 * broadcasts the receivers are not automatically hoisted out of the 7263 * background priority class. 7264 */ 7265 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; 7266 /** 7267 * If set, when sending a broadcast the recipient will be run on the offload queue. 7268 * 7269 * @hide 7270 */ 7271 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000; 7272 /** 7273 * If set, when sending a broadcast the recipient will run on the system dedicated queue. 7274 * 7275 * @hide 7276 */ 7277 public static final int FLAG_RECEIVER_OFFLOAD_FOREGROUND = 0x00000800; 7278 7279 /** 7280 * If this is an ordered broadcast, don't allow receivers to abort the broadcast. 7281 * They can still propagate results through to later receivers, but they can not prevent 7282 * later receivers from seeing the broadcast. 7283 */ 7284 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; 7285 /** 7286 * If set, when sending a broadcast <i>before the system has fully booted up 7287 * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only 7288 * registered receivers will be called -- no BroadcastReceiver components 7289 * will be launched. Sticky intent state will be recorded properly even 7290 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} 7291 * is specified in the broadcast intent, this flag is unnecessary. 7292 * 7293 * <p>This flag is only for use by system services (even services from mainline modules) as a 7294 * convenience to avoid having to implement a more complex mechanism around detection 7295 * of boot completion. 7296 * 7297 * <p>This is useful to system server mainline modules 7298 * 7299 * @hide 7300 */ 7301 @SystemApi 7302 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; 7303 /** 7304 * Set when this broadcast is for a boot upgrade, a special mode that 7305 * allows the broadcast to be sent before the system is ready and launches 7306 * the app process with no providers running in it. 7307 * @hide 7308 */ 7309 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; 7310 /** 7311 * If set, the broadcast will always go to manifest receivers in background (cached 7312 * or not running) apps, regardless of whether that would be done by default. By 7313 * default they will only receive broadcasts if the broadcast has specified an 7314 * explicit component or package name. 7315 * 7316 * NOTE: dumpstate uses this flag numerically, so when its value is changed 7317 * the broadcast code there must also be changed to match. 7318 * 7319 * @hide 7320 */ 7321 @SystemApi 7322 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; 7323 /** 7324 * If set, the broadcast will never go to manifest receivers in background (cached 7325 * or not running) apps, regardless of whether that would be done by default. By 7326 * default they will receive broadcasts if the broadcast has specified an 7327 * explicit component or package name. 7328 * @hide 7329 */ 7330 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; 7331 /** 7332 * If set, this broadcast is being sent from the shell. 7333 * @hide 7334 */ 7335 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; 7336 7337 /** 7338 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps 7339 * will not receive broadcasts. 7340 * 7341 * <em>This flag has no effect when used by an Instant App.</em> 7342 */ 7343 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000; 7344 7345 /** 7346 * @hide Flags that can't be changed with PendingIntent. 7347 */ 7348 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION 7349 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 7350 | FLAG_GRANT_PREFIX_URI_PERMISSION; 7351 7352 /** 7353 * Local flag indicating this instance was created by copy constructor. 7354 */ 7355 private static final int LOCAL_FLAG_FROM_COPY = 1 << 0; 7356 7357 /** 7358 * Local flag indicating this instance was created from a {@link Parcel}. 7359 */ 7360 private static final int LOCAL_FLAG_FROM_PARCEL = 1 << 1; 7361 7362 /** 7363 * Local flag indicating this instance was delivered through a protected 7364 * component, such as an activity that requires a signature permission, or a 7365 * protected broadcast. Note that this flag <em>cannot</em> be recursively 7366 * applied to any contained instances, since a malicious app may have 7367 * controlled them via {@link #fillIn(Intent, int)}. 7368 */ 7369 private static final int LOCAL_FLAG_FROM_PROTECTED_COMPONENT = 1 << 2; 7370 7371 /** 7372 * Local flag indicating this instance had unfiltered extras copied into it. This could be 7373 * from either {@link #putExtras(Intent)} when an unparceled Intent is provided or {@link 7374 * #putExtras(Bundle)} when the provided Bundle has not been unparceled. 7375 */ 7376 private static final int LOCAL_FLAG_UNFILTERED_EXTRAS = 1 << 3; 7377 7378 /** 7379 * Local flag indicating this instance was created from a {@link Uri}. 7380 */ 7381 private static final int LOCAL_FLAG_FROM_URI = 1 << 4; 7382 7383 /** 7384 * Local flag indicating this instance was created by the system. 7385 */ 7386 /** @hide */ 7387 public static final int LOCAL_FLAG_FROM_SYSTEM = 1 << 5; 7388 7389 // --------------------------------------------------------------------- 7390 // --------------------------------------------------------------------- 7391 // toUri() and parseUri() options. 7392 7393 /** @hide */ 7394 @IntDef(flag = true, prefix = {"URI_"}, value = { 7395 URI_ALLOW_UNSAFE, 7396 URI_ANDROID_APP_SCHEME, 7397 URI_INTENT_SCHEME, 7398 }) 7399 @Retention(RetentionPolicy.SOURCE) 7400 public @interface UriFlags {} 7401 7402 /** 7403 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 7404 * always has the "intent:" scheme. This syntax can be used when you want 7405 * to later disambiguate between URIs that are intended to describe an 7406 * Intent vs. all others that should be treated as raw URIs. When used 7407 * with {@link #parseUri}, any other scheme will result in a generic 7408 * VIEW action for that raw URI. 7409 */ 7410 public static final int URI_INTENT_SCHEME = 1<<0; 7411 7412 /** 7413 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 7414 * always has the "android-app:" scheme. This is a variation of 7415 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an 7416 * http/https URI being delivered to a specific package name. The format 7417 * is: 7418 * 7419 * <pre class="prettyprint"> 7420 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> 7421 * 7422 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, 7423 * you must also include a scheme; including a path also requires both a host and a scheme. 7424 * The final #Intent; fragment can be used without a scheme, host, or path. 7425 * Note that this can not be 7426 * used with intents that have a {@link #setSelector}, since the base intent 7427 * will always have an explicit package name.</p> 7428 * 7429 * <p>Some examples of how this scheme maps to Intent objects:</p> 7430 * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> 7431 * <colgroup align="left" /> 7432 * <colgroup align="left" /> 7433 * <thead> 7434 * <tr><th>URI</th> <th>Intent</th></tr> 7435 * </thead> 7436 * 7437 * <tbody> 7438 * <tr><td><code>android-app://com.example.app</code></td> 7439 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7440 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> 7441 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7442 * </table></td> 7443 * </tr> 7444 * <tr><td><code>android-app://com.example.app/http/example.com</code></td> 7445 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7446 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 7447 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> 7448 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7449 * </table></td> 7450 * </tr> 7451 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> 7452 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7453 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 7454 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 7455 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7456 * </table></td> 7457 * </tr> 7458 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> 7459 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7460 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7461 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7462 * </table></td> 7463 * </tr> 7464 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> 7465 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7466 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7467 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 7468 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7469 * </table></td> 7470 * </tr> 7471 * <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> 7472 * <td><table border="" style="margin:0" > 7473 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7474 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7475 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> 7476 * </table></td> 7477 * </tr> 7478 * </tbody> 7479 * </table> 7480 */ 7481 public static final int URI_ANDROID_APP_SCHEME = 1<<1; 7482 7483 /** 7484 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing 7485 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, 7486 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, 7487 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the 7488 * generated Intent can not cause unexpected data access to happen. 7489 * 7490 * <p>If you do not trust the source of the URI being parsed, you should still do further 7491 * processing to protect yourself from it. In particular, when using it to start an 7492 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities 7493 * that can handle it.</p> 7494 */ 7495 public static final int URI_ALLOW_UNSAFE = 1<<2; 7496 7497 // --------------------------------------------------------------------- 7498 7499 private String mAction; 7500 private Uri mData; 7501 private String mType; 7502 private String mIdentifier; 7503 private String mPackage; 7504 private ComponentName mComponent; 7505 private int mFlags; 7506 /** Set of in-process flags which are never parceled */ 7507 private int mLocalFlags; 7508 private ArraySet<String> mCategories; 7509 @UnsupportedAppUsage 7510 private Bundle mExtras; 7511 private Rect mSourceBounds; 7512 private Intent mSelector; 7513 private ClipData mClipData; 7514 private int mContentUserHint = UserHandle.USER_CURRENT; 7515 /** Token to track instant app launches. Local only; do not copy cross-process. */ 7516 private String mLaunchToken; 7517 private Intent mOriginalIntent; // Used for the experimental "component alias" feature. 7518 7519 // --------------------------------------------------------------------- 7520 7521 private static final int COPY_MODE_ALL = 0; 7522 private static final int COPY_MODE_FILTER = 1; 7523 private static final int COPY_MODE_HISTORY = 2; 7524 7525 /** @hide */ 7526 @IntDef(prefix = { "COPY_MODE_" }, value = { 7527 COPY_MODE_ALL, 7528 COPY_MODE_FILTER, 7529 COPY_MODE_HISTORY 7530 }) 7531 @Retention(RetentionPolicy.SOURCE) 7532 public @interface CopyMode {} 7533 7534 /** 7535 * Create an empty intent. 7536 */ Intent()7537 public Intent() { 7538 } 7539 7540 /** 7541 * Copy constructor. 7542 */ Intent(Intent o)7543 public Intent(Intent o) { 7544 this(o, COPY_MODE_ALL); 7545 } 7546 Intent(Intent o, @CopyMode int copyMode)7547 private Intent(Intent o, @CopyMode int copyMode) { 7548 this.mAction = o.mAction; 7549 this.mData = o.mData; 7550 this.mType = o.mType; 7551 this.mIdentifier = o.mIdentifier; 7552 this.mPackage = o.mPackage; 7553 this.mComponent = o.mComponent; 7554 this.mOriginalIntent = o.mOriginalIntent; 7555 7556 if (o.mCategories != null) { 7557 this.mCategories = new ArraySet<>(o.mCategories); 7558 } 7559 7560 // Inherit flags from the original, plus mark that we were 7561 // created by this copy constructor 7562 this.mLocalFlags = o.mLocalFlags; 7563 this.mLocalFlags |= LOCAL_FLAG_FROM_COPY; 7564 7565 if (copyMode != COPY_MODE_FILTER) { 7566 this.mFlags = o.mFlags; 7567 this.mContentUserHint = o.mContentUserHint; 7568 this.mLaunchToken = o.mLaunchToken; 7569 if (o.mSourceBounds != null) { 7570 this.mSourceBounds = new Rect(o.mSourceBounds); 7571 } 7572 if (o.mSelector != null) { 7573 this.mSelector = new Intent(o.mSelector); 7574 } 7575 7576 if (copyMode != COPY_MODE_HISTORY) { 7577 if (o.mExtras != null) { 7578 this.mExtras = new Bundle(o.mExtras); 7579 } 7580 if (o.mClipData != null) { 7581 this.mClipData = new ClipData(o.mClipData); 7582 } 7583 } else { 7584 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) { 7585 this.mExtras = Bundle.STRIPPED; 7586 } 7587 7588 // Also set "stripped" clip data when we ever log mClipData in the (broadcast) 7589 // history. 7590 } 7591 } 7592 } 7593 7594 @Override clone()7595 public Object clone() { 7596 return new Intent(this); 7597 } 7598 7599 /** 7600 * Make a clone of only the parts of the Intent that are relevant for 7601 * filter matching: the action, data, type, component, and categories. 7602 */ cloneFilter()7603 public @NonNull Intent cloneFilter() { 7604 return new Intent(this, COPY_MODE_FILTER); 7605 } 7606 7607 /** 7608 * Create an intent with a given action. All other fields (data, type, 7609 * class) are null. Note that the action <em>must</em> be in a 7610 * namespace because Intents are used globally in the system -- for 7611 * example the system VIEW action is android.intent.action.VIEW; an 7612 * application's custom action would be something like 7613 * com.google.app.myapp.CUSTOM_ACTION. 7614 * 7615 * @param action The Intent action, such as ACTION_VIEW. 7616 */ Intent(String action)7617 public Intent(String action) { 7618 setAction(action); 7619 } 7620 7621 /** 7622 * Create an intent with a given action and for a given data url. Note 7623 * that the action <em>must</em> be in a namespace because Intents are 7624 * used globally in the system -- for example the system VIEW action is 7625 * android.intent.action.VIEW; an application's custom action would be 7626 * something like com.google.app.myapp.CUSTOM_ACTION. 7627 * 7628 * <p><em>Note: scheme and host name matching in the Android framework is 7629 * case-sensitive, unlike the formal RFC. As a result, 7630 * you should always ensure that you write your Uri with these elements 7631 * using lower case letters, and normalize any Uris you receive from 7632 * outside of Android to ensure the scheme and host is lower case.</em></p> 7633 * 7634 * @param action The Intent action, such as ACTION_VIEW. 7635 * @param uri The Intent data URI. 7636 */ Intent(String action, Uri uri)7637 public Intent(String action, Uri uri) { 7638 setAction(action); 7639 mData = uri; 7640 } 7641 7642 /** 7643 * Create an intent for a specific component. All other fields (action, data, 7644 * type, class) are null, though they can be modified later with explicit 7645 * calls. This provides a convenient way to create an intent that is 7646 * intended to execute a hard-coded class name, rather than relying on the 7647 * system to find an appropriate class for you; see {@link #setComponent} 7648 * for more information on the repercussions of this. 7649 * 7650 * @param packageContext A Context of the application package implementing 7651 * this class. 7652 * @param cls The component class that is to be used for the intent. 7653 * 7654 * @see #setClass 7655 * @see #setComponent 7656 * @see #Intent(String, android.net.Uri , Context, Class) 7657 */ Intent(Context packageContext, Class<?> cls)7658 public Intent(Context packageContext, Class<?> cls) { 7659 mComponent = new ComponentName(packageContext, cls); 7660 } 7661 7662 /** 7663 * Create an intent for a specific component with a specified action and data. 7664 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to 7665 * construct the Intent and then calling {@link #setClass} to set its 7666 * class. 7667 * 7668 * <p><em>Note: scheme and host name matching in the Android framework is 7669 * case-sensitive, unlike the formal RFC. As a result, 7670 * you should always ensure that you write your Uri with these elements 7671 * using lower case letters, and normalize any Uris you receive from 7672 * outside of Android to ensure the scheme and host is lower case.</em></p> 7673 * 7674 * @param action The Intent action, such as ACTION_VIEW. 7675 * @param uri The Intent data URI. 7676 * @param packageContext A Context of the application package implementing 7677 * this class. 7678 * @param cls The component class that is to be used for the intent. 7679 * 7680 * @see #Intent(String, android.net.Uri) 7681 * @see #Intent(Context, Class) 7682 * @see #setClass 7683 * @see #setComponent 7684 */ Intent(String action, Uri uri, Context packageContext, Class<?> cls)7685 public Intent(String action, Uri uri, 7686 Context packageContext, Class<?> cls) { 7687 setAction(action); 7688 mData = uri; 7689 mComponent = new ComponentName(packageContext, cls); 7690 } 7691 7692 /** 7693 * Create an intent to launch the main (root) activity of a task. This 7694 * is the Intent that is started when the application's is launched from 7695 * Home. For anything else that wants to launch an application in the 7696 * same way, it is important that they use an Intent structured the same 7697 * way, and can use this function to ensure this is the case. 7698 * 7699 * <p>The returned Intent has the given Activity component as its explicit 7700 * component, {@link #ACTION_MAIN} as its action, and includes the 7701 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 7702 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 7703 * to do that through {@link #addFlags(int)} on the returned Intent. 7704 * 7705 * @param mainActivity The main activity component that this Intent will 7706 * launch. 7707 * @return Returns a newly created Intent that can be used to launch the 7708 * activity as a main application entry. 7709 * 7710 * @see #setClass 7711 * @see #setComponent 7712 */ makeMainActivity(ComponentName mainActivity)7713 public static Intent makeMainActivity(ComponentName mainActivity) { 7714 Intent intent = new Intent(ACTION_MAIN); 7715 intent.setComponent(mainActivity); 7716 intent.addCategory(CATEGORY_LAUNCHER); 7717 return intent; 7718 } 7719 7720 /** 7721 * Make an Intent for the main activity of an application, without 7722 * specifying a specific activity to run but giving a selector to find 7723 * the activity. This results in a final Intent that is structured 7724 * the same as when the application is launched from 7725 * Home. For anything else that wants to launch an application in the 7726 * same way, it is important that they use an Intent structured the same 7727 * way, and can use this function to ensure this is the case. 7728 * 7729 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the 7730 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 7731 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 7732 * to do that through {@link #addFlags(int)} on the returned Intent. 7733 * 7734 * @param selectorAction The action name of the Intent's selector. 7735 * @param selectorCategory The name of a category to add to the Intent's 7736 * selector. 7737 * @return Returns a newly created Intent that can be used to launch the 7738 * activity as a main application entry. 7739 * 7740 * @see #setSelector(Intent) 7741 */ makeMainSelectorActivity(String selectorAction, String selectorCategory)7742 public static Intent makeMainSelectorActivity(String selectorAction, 7743 String selectorCategory) { 7744 Intent intent = new Intent(ACTION_MAIN); 7745 intent.addCategory(CATEGORY_LAUNCHER); 7746 Intent selector = new Intent(); 7747 selector.setAction(selectorAction); 7748 selector.addCategory(selectorCategory); 7749 intent.setSelector(selector); 7750 return intent; 7751 } 7752 7753 /** 7754 * Make an Intent that can be used to re-launch an application's task 7755 * in its base state. This is like {@link #makeMainActivity(ComponentName)}, 7756 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and 7757 * {@link #FLAG_ACTIVITY_CLEAR_TASK}. 7758 * 7759 * @param mainActivity The activity component that is the root of the 7760 * task; this is the activity that has been published in the application's 7761 * manifest as the main launcher icon. 7762 * 7763 * @return Returns a newly created Intent that can be used to relaunch the 7764 * activity's task in its root state. 7765 */ makeRestartActivityTask(ComponentName mainActivity)7766 public static Intent makeRestartActivityTask(ComponentName mainActivity) { 7767 Intent intent = makeMainActivity(mainActivity); 7768 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 7769 | Intent.FLAG_ACTIVITY_CLEAR_TASK); 7770 return intent; 7771 } 7772 7773 /** 7774 * Call {@link #parseUri} with 0 flags. 7775 * @deprecated Use {@link #parseUri} instead. 7776 */ 7777 @Deprecated getIntent(String uri)7778 public static Intent getIntent(String uri) throws URISyntaxException { 7779 return parseUri(uri, 0); 7780 } 7781 7782 /** 7783 * Create an intent from a URI. This URI may encode the action, 7784 * category, and other intent fields, if it was returned by 7785 * {@link #toUri}. If the Intent was not generate by toUri(), its data 7786 * will be the entire URI and its action will be ACTION_VIEW. 7787 * 7788 * <p>The URI given here must not be relative -- that is, it must include 7789 * the scheme and full path. 7790 * 7791 * @param uri The URI to turn into an Intent. 7792 * @param flags Additional processing flags. 7793 * 7794 * @return Intent The newly created Intent object. 7795 * 7796 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax 7797 * it bad (as parsed by the Uri class) or the Intent data within the 7798 * URI is invalid. 7799 * 7800 * @see #toUri 7801 */ parseUri(String uri, @UriFlags int flags)7802 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException { 7803 Intent intent = parseUriInternal(uri, flags); 7804 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 7805 return intent; 7806 } 7807 7808 /** 7809 * @see #parseUri(String, int) 7810 */ parseUriInternal(String uri, @UriFlags int flags)7811 private static Intent parseUriInternal(String uri, @UriFlags int flags) 7812 throws URISyntaxException { 7813 int i = 0; 7814 try { 7815 final boolean androidApp = uri.startsWith("android-app:"); 7816 7817 // Validate intent scheme if requested. 7818 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { 7819 if (!uri.startsWith("intent:") && !androidApp) { 7820 Intent intent = new Intent(ACTION_VIEW); 7821 try { 7822 intent.setData(Uri.parse(uri)); 7823 } catch (IllegalArgumentException e) { 7824 throw new URISyntaxException(uri, e.getMessage()); 7825 } 7826 return intent; 7827 } 7828 } 7829 7830 i = uri.lastIndexOf("#"); 7831 // simple case 7832 if (i == -1) { 7833 if (!androidApp) { 7834 return new Intent(ACTION_VIEW, Uri.parse(uri)); 7835 } 7836 7837 // old format Intent URI 7838 } else if (!uri.startsWith("#Intent;", i)) { 7839 if (!androidApp) { 7840 return getIntentOld(uri, flags); 7841 } else { 7842 i = -1; 7843 } 7844 } 7845 7846 // new format 7847 Intent intent = new Intent(ACTION_VIEW); 7848 Intent baseIntent = intent; 7849 boolean explicitAction = false; 7850 boolean inSelector = false; 7851 7852 // fetch data part, if present 7853 String scheme = null; 7854 String data; 7855 if (i >= 0) { 7856 data = uri.substring(0, i); 7857 i += 8; // length of "#Intent;" 7858 } else { 7859 data = uri; 7860 } 7861 7862 // loop over contents of Intent, all name=value; 7863 while (i >= 0 && !uri.startsWith("end", i)) { 7864 int eq = uri.indexOf('=', i); 7865 if (eq < 0) eq = i-1; 7866 int semi = uri.indexOf(';', i); 7867 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : ""; 7868 7869 // action 7870 if (uri.startsWith("action=", i)) { 7871 intent.setAction(value); 7872 if (!inSelector) { 7873 explicitAction = true; 7874 } 7875 } 7876 7877 // categories 7878 else if (uri.startsWith("category=", i)) { 7879 intent.addCategory(value); 7880 } 7881 7882 // type 7883 else if (uri.startsWith("type=", i)) { 7884 intent.mType = value; 7885 } 7886 7887 // identifier 7888 else if (uri.startsWith("identifier=", i)) { 7889 intent.mIdentifier = value; 7890 } 7891 7892 // launch flags 7893 else if (uri.startsWith("launchFlags=", i)) { 7894 intent.mFlags = Integer.decode(value).intValue(); 7895 if ((flags& URI_ALLOW_UNSAFE) == 0) { 7896 intent.mFlags &= ~IMMUTABLE_FLAGS; 7897 } 7898 } 7899 7900 // package 7901 else if (uri.startsWith("package=", i)) { 7902 intent.mPackage = value; 7903 } 7904 7905 // component 7906 else if (uri.startsWith("component=", i)) { 7907 intent.mComponent = ComponentName.unflattenFromString(value); 7908 } 7909 7910 // scheme 7911 else if (uri.startsWith("scheme=", i)) { 7912 if (inSelector) { 7913 intent.mData = Uri.parse(value + ":"); 7914 } else { 7915 scheme = value; 7916 } 7917 } 7918 7919 // source bounds 7920 else if (uri.startsWith("sourceBounds=", i)) { 7921 intent.mSourceBounds = Rect.unflattenFromString(value); 7922 } 7923 7924 // selector 7925 else if (semi == (i+3) && uri.startsWith("SEL", i)) { 7926 intent = new Intent(); 7927 inSelector = true; 7928 } 7929 7930 // extra 7931 else { 7932 String key = Uri.decode(uri.substring(i + 2, eq)); 7933 // create Bundle if it doesn't already exist 7934 if (intent.mExtras == null) intent.mExtras = new Bundle(); 7935 Bundle b = intent.mExtras; 7936 // add EXTRA 7937 if (uri.startsWith("S.", i)) b.putString(key, value); 7938 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); 7939 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); 7940 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); 7941 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); 7942 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); 7943 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); 7944 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); 7945 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); 7946 else throw new URISyntaxException(uri, "unknown EXTRA type", i); 7947 } 7948 7949 // move to the next item 7950 i = semi + 1; 7951 } 7952 7953 if (inSelector) { 7954 // The Intent had a selector; fix it up. 7955 if (baseIntent.mPackage == null) { 7956 baseIntent.setSelector(intent); 7957 } 7958 intent = baseIntent; 7959 } 7960 7961 if (data != null) { 7962 if (data.startsWith("intent:")) { 7963 data = data.substring(7); 7964 if (scheme != null) { 7965 data = scheme + ':' + data; 7966 } 7967 } else if (data.startsWith("android-app:")) { 7968 if (data.charAt(12) == '/' && data.charAt(13) == '/') { 7969 // Correctly formed android-app, first part is package name. 7970 int end = data.indexOf('/', 14); 7971 if (end < 0) { 7972 // All we have is a package name. 7973 intent.mPackage = data.substring(14); 7974 if (!explicitAction) { 7975 intent.setAction(ACTION_MAIN); 7976 } 7977 data = ""; 7978 } else { 7979 // Target the Intent at the given package name always. 7980 String authority = null; 7981 intent.mPackage = data.substring(14, end); 7982 int newEnd; 7983 if ((end+1) < data.length()) { 7984 if ((newEnd=data.indexOf('/', end+1)) >= 0) { 7985 // Found a scheme, remember it. 7986 scheme = data.substring(end+1, newEnd); 7987 end = newEnd; 7988 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { 7989 // Found a authority, remember it. 7990 authority = data.substring(end+1, newEnd); 7991 end = newEnd; 7992 } 7993 } else { 7994 // All we have is a scheme. 7995 scheme = data.substring(end+1); 7996 } 7997 } 7998 if (scheme == null) { 7999 // If there was no scheme, then this just targets the package. 8000 if (!explicitAction) { 8001 intent.setAction(ACTION_MAIN); 8002 } 8003 data = ""; 8004 } else if (authority == null) { 8005 data = scheme + ":"; 8006 } else { 8007 data = scheme + "://" + authority + data.substring(end); 8008 } 8009 } 8010 } else { 8011 data = ""; 8012 } 8013 } 8014 8015 if (data.length() > 0) { 8016 try { 8017 intent.mData = Uri.parse(data); 8018 } catch (IllegalArgumentException e) { 8019 throw new URISyntaxException(uri, e.getMessage()); 8020 } 8021 } 8022 } 8023 8024 return intent; 8025 8026 } catch (IndexOutOfBoundsException e) { 8027 throw new URISyntaxException(uri, "illegal Intent URI format", i); 8028 } 8029 } 8030 8031 public static Intent getIntentOld(String uri) throws URISyntaxException { 8032 Intent intent = getIntentOld(uri, 0); 8033 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 8034 return intent; 8035 } 8036 8037 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException { 8038 Intent intent; 8039 8040 int i = uri.lastIndexOf('#'); 8041 if (i >= 0) { 8042 String action = null; 8043 final int intentFragmentStart = i; 8044 boolean isIntentFragment = false; 8045 8046 i++; 8047 8048 if (uri.regionMatches(i, "action(", 0, 7)) { 8049 isIntentFragment = true; 8050 i += 7; 8051 int j = uri.indexOf(')', i); 8052 action = uri.substring(i, j); 8053 i = j + 1; 8054 } 8055 8056 intent = new Intent(action); 8057 8058 if (uri.regionMatches(i, "categories(", 0, 11)) { 8059 isIntentFragment = true; 8060 i += 11; 8061 int j = uri.indexOf(')', i); 8062 while (i < j) { 8063 int sep = uri.indexOf('!', i); 8064 if (sep < 0 || sep > j) sep = j; 8065 if (i < sep) { 8066 intent.addCategory(uri.substring(i, sep)); 8067 } 8068 i = sep + 1; 8069 } 8070 i = j + 1; 8071 } 8072 8073 if (uri.regionMatches(i, "type(", 0, 5)) { 8074 isIntentFragment = true; 8075 i += 5; 8076 int j = uri.indexOf(')', i); 8077 intent.mType = uri.substring(i, j); 8078 i = j + 1; 8079 } 8080 8081 if (uri.regionMatches(i, "launchFlags(", 0, 12)) { 8082 isIntentFragment = true; 8083 i += 12; 8084 int j = uri.indexOf(')', i); 8085 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); 8086 if ((flags& URI_ALLOW_UNSAFE) == 0) { 8087 intent.mFlags &= ~IMMUTABLE_FLAGS; 8088 } 8089 i = j + 1; 8090 } 8091 8092 if (uri.regionMatches(i, "component(", 0, 10)) { 8093 isIntentFragment = true; 8094 i += 10; 8095 int j = uri.indexOf(')', i); 8096 int sep = uri.indexOf('!', i); 8097 if (sep >= 0 && sep < j) { 8098 String pkg = uri.substring(i, sep); 8099 String cls = uri.substring(sep + 1, j); 8100 intent.mComponent = new ComponentName(pkg, cls); 8101 } 8102 i = j + 1; 8103 } 8104 8105 if (uri.regionMatches(i, "extras(", 0, 7)) { 8106 isIntentFragment = true; 8107 i += 7; 8108 8109 final int closeParen = uri.indexOf(')', i); 8110 if (closeParen == -1) throw new URISyntaxException(uri, 8111 "EXTRA missing trailing ')'", i); 8112 8113 while (i < closeParen) { 8114 // fetch the key value 8115 int j = uri.indexOf('=', i); 8116 if (j <= i + 1 || i >= closeParen) { 8117 throw new URISyntaxException(uri, "EXTRA missing '='", i); 8118 } 8119 char type = uri.charAt(i); 8120 i++; 8121 String key = uri.substring(i, j); 8122 i = j + 1; 8123 8124 // get type-value 8125 j = uri.indexOf('!', i); 8126 if (j == -1 || j >= closeParen) j = closeParen; 8127 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); 8128 String value = uri.substring(i, j); 8129 i = j; 8130 8131 // create Bundle if it doesn't already exist 8132 if (intent.mExtras == null) intent.mExtras = new Bundle(); 8133 8134 // add item to bundle 8135 try { 8136 switch (type) { 8137 case 'S': 8138 intent.mExtras.putString(key, Uri.decode(value)); 8139 break; 8140 case 'B': 8141 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); 8142 break; 8143 case 'b': 8144 intent.mExtras.putByte(key, Byte.parseByte(value)); 8145 break; 8146 case 'c': 8147 intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); 8148 break; 8149 case 'd': 8150 intent.mExtras.putDouble(key, Double.parseDouble(value)); 8151 break; 8152 case 'f': 8153 intent.mExtras.putFloat(key, Float.parseFloat(value)); 8154 break; 8155 case 'i': 8156 intent.mExtras.putInt(key, Integer.parseInt(value)); 8157 break; 8158 case 'l': 8159 intent.mExtras.putLong(key, Long.parseLong(value)); 8160 break; 8161 case 's': 8162 intent.mExtras.putShort(key, Short.parseShort(value)); 8163 break; 8164 default: 8165 throw new URISyntaxException(uri, "EXTRA has unknown type", i); 8166 } 8167 } catch (NumberFormatException e) { 8168 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); 8169 } 8170 8171 char ch = uri.charAt(i); 8172 if (ch == ')') break; 8173 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); 8174 i++; 8175 } 8176 } 8177 8178 if (isIntentFragment) { 8179 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); 8180 } else { 8181 intent.mData = Uri.parse(uri); 8182 } 8183 8184 if (intent.mAction == null) { 8185 // By default, if no action is specified, then use VIEW. 8186 intent.mAction = ACTION_VIEW; 8187 } 8188 8189 } else { 8190 intent = new Intent(ACTION_VIEW, Uri.parse(uri)); 8191 } 8192 8193 return intent; 8194 } 8195 8196 /** @hide */ 8197 public interface CommandOptionHandler { 8198 boolean handleOption(String opt, ShellCommand cmd); 8199 } 8200 8201 /** @hide */ 8202 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 8203 @SuppressWarnings("AndroidFrameworkEfficientCollections") parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)8204 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) 8205 throws URISyntaxException { 8206 Intent intent = new Intent(); 8207 Intent baseIntent = intent; 8208 boolean hasIntentInfo = false; 8209 8210 Uri data = null; 8211 String type = null; 8212 8213 String opt; 8214 while ((opt=cmd.getNextOption()) != null) { 8215 switch (opt) { 8216 case "-a": 8217 intent.setAction(cmd.getNextArgRequired()); 8218 if (intent == baseIntent) { 8219 hasIntentInfo = true; 8220 } 8221 break; 8222 case "-d": 8223 data = Uri.parse(cmd.getNextArgRequired()); 8224 if (intent == baseIntent) { 8225 hasIntentInfo = true; 8226 } 8227 break; 8228 case "-t": 8229 type = cmd.getNextArgRequired(); 8230 if (intent == baseIntent) { 8231 hasIntentInfo = true; 8232 } 8233 break; 8234 case "-i": 8235 intent.setIdentifier(cmd.getNextArgRequired()); 8236 if (intent == baseIntent) { 8237 hasIntentInfo = true; 8238 } 8239 break; 8240 case "-c": 8241 intent.addCategory(cmd.getNextArgRequired()); 8242 if (intent == baseIntent) { 8243 hasIntentInfo = true; 8244 } 8245 break; 8246 case "-e": 8247 case "--es": { 8248 String key = cmd.getNextArgRequired(); 8249 String value = cmd.getNextArgRequired(); 8250 intent.putExtra(key, value); 8251 } 8252 break; 8253 case "--esn": { 8254 String key = cmd.getNextArgRequired(); 8255 intent.putExtra(key, (String) null); 8256 } 8257 break; 8258 case "--ei": { 8259 String key = cmd.getNextArgRequired(); 8260 String value = cmd.getNextArgRequired(); 8261 intent.putExtra(key, Integer.decode(value)); 8262 } 8263 break; 8264 case "--eu": { 8265 String key = cmd.getNextArgRequired(); 8266 String value = cmd.getNextArgRequired(); 8267 intent.putExtra(key, Uri.parse(value)); 8268 } 8269 break; 8270 case "--ecn": { 8271 String key = cmd.getNextArgRequired(); 8272 String value = cmd.getNextArgRequired(); 8273 ComponentName cn = ComponentName.unflattenFromString(value); 8274 if (cn == null) 8275 throw new IllegalArgumentException("Bad component name: " + value); 8276 intent.putExtra(key, cn); 8277 } 8278 break; 8279 case "--eia": { 8280 String key = cmd.getNextArgRequired(); 8281 String value = cmd.getNextArgRequired(); 8282 String[] strings = value.split(","); 8283 int[] list = new int[strings.length]; 8284 for (int i = 0; i < strings.length; i++) { 8285 list[i] = Integer.decode(strings[i]); 8286 } 8287 intent.putExtra(key, list); 8288 } 8289 break; 8290 case "--eial": { 8291 String key = cmd.getNextArgRequired(); 8292 String value = cmd.getNextArgRequired(); 8293 String[] strings = value.split(","); 8294 ArrayList<Integer> list = new ArrayList<>(strings.length); 8295 for (int i = 0; i < strings.length; i++) { 8296 list.add(Integer.decode(strings[i])); 8297 } 8298 intent.putExtra(key, list); 8299 } 8300 break; 8301 case "--el": { 8302 String key = cmd.getNextArgRequired(); 8303 String value = cmd.getNextArgRequired(); 8304 intent.putExtra(key, Long.valueOf(value)); 8305 } 8306 break; 8307 case "--ela": { 8308 String key = cmd.getNextArgRequired(); 8309 String value = cmd.getNextArgRequired(); 8310 String[] strings = value.split(","); 8311 long[] list = new long[strings.length]; 8312 for (int i = 0; i < strings.length; i++) { 8313 list[i] = Long.valueOf(strings[i]); 8314 } 8315 intent.putExtra(key, list); 8316 hasIntentInfo = true; 8317 } 8318 break; 8319 case "--elal": { 8320 String key = cmd.getNextArgRequired(); 8321 String value = cmd.getNextArgRequired(); 8322 String[] strings = value.split(","); 8323 ArrayList<Long> list = new ArrayList<>(strings.length); 8324 for (int i = 0; i < strings.length; i++) { 8325 list.add(Long.valueOf(strings[i])); 8326 } 8327 intent.putExtra(key, list); 8328 hasIntentInfo = true; 8329 } 8330 break; 8331 case "--ef": { 8332 String key = cmd.getNextArgRequired(); 8333 String value = cmd.getNextArgRequired(); 8334 intent.putExtra(key, Float.valueOf(value)); 8335 hasIntentInfo = true; 8336 } 8337 break; 8338 case "--efa": { 8339 String key = cmd.getNextArgRequired(); 8340 String value = cmd.getNextArgRequired(); 8341 String[] strings = value.split(","); 8342 float[] list = new float[strings.length]; 8343 for (int i = 0; i < strings.length; i++) { 8344 list[i] = Float.valueOf(strings[i]); 8345 } 8346 intent.putExtra(key, list); 8347 hasIntentInfo = true; 8348 } 8349 break; 8350 case "--efal": { 8351 String key = cmd.getNextArgRequired(); 8352 String value = cmd.getNextArgRequired(); 8353 String[] strings = value.split(","); 8354 ArrayList<Float> list = new ArrayList<>(strings.length); 8355 for (int i = 0; i < strings.length; i++) { 8356 list.add(Float.valueOf(strings[i])); 8357 } 8358 intent.putExtra(key, list); 8359 hasIntentInfo = true; 8360 } 8361 break; 8362 case "--ed": { 8363 String key = cmd.getNextArgRequired(); 8364 String value = cmd.getNextArgRequired(); 8365 intent.putExtra(key, Double.valueOf(value)); 8366 hasIntentInfo = true; 8367 } 8368 break; 8369 case "--eda": { 8370 String key = cmd.getNextArgRequired(); 8371 String value = cmd.getNextArgRequired(); 8372 String[] strings = value.split(","); 8373 double[] list = new double[strings.length]; 8374 for (int i = 0; i < strings.length; i++) { 8375 list[i] = Double.valueOf(strings[i]); 8376 } 8377 intent.putExtra(key, list); 8378 hasIntentInfo = true; 8379 } 8380 break; 8381 case "--edal": { 8382 String key = cmd.getNextArgRequired(); 8383 String value = cmd.getNextArgRequired(); 8384 String[] strings = value.split(","); 8385 ArrayList<Double> list = new ArrayList<>(strings.length); 8386 for (int i = 0; i < strings.length; i++) { 8387 list.add(Double.valueOf(strings[i])); 8388 } 8389 intent.putExtra(key, list); 8390 hasIntentInfo = true; 8391 } 8392 break; 8393 case "--esa": { 8394 String key = cmd.getNextArgRequired(); 8395 String value = cmd.getNextArgRequired(); 8396 // Split on commas unless they are preceeded by an escape. 8397 // The escape character must be escaped for the string and 8398 // again for the regex, thus four escape characters become one. 8399 String[] strings = value.split("(?<!\\\\),"); 8400 intent.putExtra(key, strings); 8401 hasIntentInfo = true; 8402 } 8403 break; 8404 case "--esal": { 8405 String key = cmd.getNextArgRequired(); 8406 String value = cmd.getNextArgRequired(); 8407 // Split on commas unless they are preceeded by an escape. 8408 // The escape character must be escaped for the string and 8409 // again for the regex, thus four escape characters become one. 8410 String[] strings = value.split("(?<!\\\\),"); 8411 ArrayList<String> list = new ArrayList<>(strings.length); 8412 for (int i = 0; i < strings.length; i++) { 8413 list.add(strings[i]); 8414 } 8415 intent.putExtra(key, list); 8416 hasIntentInfo = true; 8417 } 8418 break; 8419 case "--ez": { 8420 String key = cmd.getNextArgRequired(); 8421 String value = cmd.getNextArgRequired().toLowerCase(); 8422 // Boolean.valueOf() results in false for anything that is not "true", which is 8423 // error-prone in shell commands 8424 boolean arg; 8425 if ("true".equals(value) || "t".equals(value)) { 8426 arg = true; 8427 } else if ("false".equals(value) || "f".equals(value)) { 8428 arg = false; 8429 } else { 8430 try { 8431 arg = Integer.decode(value) != 0; 8432 } catch (NumberFormatException ex) { 8433 throw new IllegalArgumentException("Invalid boolean value: " + value); 8434 } 8435 } 8436 8437 intent.putExtra(key, arg); 8438 } 8439 break; 8440 case "-n": { 8441 String str = cmd.getNextArgRequired(); 8442 ComponentName cn = ComponentName.unflattenFromString(str); 8443 if (cn == null) 8444 throw new IllegalArgumentException("Bad component name: " + str); 8445 intent.setComponent(cn); 8446 if (intent == baseIntent) { 8447 hasIntentInfo = true; 8448 } 8449 } 8450 break; 8451 case "-p": { 8452 String str = cmd.getNextArgRequired(); 8453 intent.setPackage(str); 8454 if (intent == baseIntent) { 8455 hasIntentInfo = true; 8456 } 8457 } 8458 break; 8459 case "-f": 8460 String str = cmd.getNextArgRequired(); 8461 intent.setFlags(Integer.decode(str).intValue()); 8462 break; 8463 case "--grant-read-uri-permission": 8464 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 8465 break; 8466 case "--grant-write-uri-permission": 8467 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 8468 break; 8469 case "--grant-persistable-uri-permission": 8470 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); 8471 break; 8472 case "--grant-prefix-uri-permission": 8473 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); 8474 break; 8475 case "--exclude-stopped-packages": 8476 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); 8477 break; 8478 case "--include-stopped-packages": 8479 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); 8480 break; 8481 case "--debug-log-resolution": 8482 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); 8483 break; 8484 case "--activity-brought-to-front": 8485 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); 8486 break; 8487 case "--activity-clear-top": 8488 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 8489 break; 8490 case "--activity-clear-when-task-reset": 8491 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 8492 break; 8493 case "--activity-exclude-from-recents": 8494 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 8495 break; 8496 case "--activity-launched-from-history": 8497 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); 8498 break; 8499 case "--activity-multiple-task": 8500 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 8501 break; 8502 case "--activity-no-animation": 8503 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 8504 break; 8505 case "--activity-no-history": 8506 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 8507 break; 8508 case "--activity-no-user-action": 8509 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); 8510 break; 8511 case "--activity-previous-is-top": 8512 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); 8513 break; 8514 case "--activity-reorder-to-front": 8515 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 8516 break; 8517 case "--activity-reset-task-if-needed": 8518 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 8519 break; 8520 case "--activity-single-top": 8521 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 8522 break; 8523 case "--activity-clear-task": 8524 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 8525 break; 8526 case "--activity-task-on-home": 8527 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); 8528 break; 8529 case "--activity-match-external": 8530 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL); 8531 break; 8532 case "--receiver-registered-only": 8533 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); 8534 break; 8535 case "--receiver-replace-pending": 8536 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); 8537 break; 8538 case "--receiver-foreground": 8539 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 8540 break; 8541 case "--receiver-no-abort": 8542 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); 8543 break; 8544 case "--receiver-include-background": 8545 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 8546 break; 8547 case "--selector": 8548 intent.setDataAndType(data, type); 8549 intent = new Intent(); 8550 break; 8551 default: 8552 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { 8553 // Okay, caller handled this option. 8554 } else { 8555 throw new IllegalArgumentException("Unknown option: " + opt); 8556 } 8557 break; 8558 } 8559 } 8560 intent.setDataAndType(data, type); 8561 8562 final boolean hasSelector = intent != baseIntent; 8563 if (hasSelector) { 8564 // A selector was specified; fix up. 8565 baseIntent.setSelector(intent); 8566 intent = baseIntent; 8567 } 8568 8569 String arg = cmd.getNextArg(); 8570 baseIntent = null; 8571 if (arg == null) { 8572 if (hasSelector) { 8573 // If a selector has been specified, and no arguments 8574 // have been supplied for the main Intent, then we can 8575 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't 8576 // need to have a component name specified yet, the 8577 // selector will take care of that. 8578 baseIntent = new Intent(Intent.ACTION_MAIN); 8579 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8580 } 8581 } else if (arg.indexOf(':') >= 0) { 8582 // The argument is a URI. Fully parse it, and use that result 8583 // to fill in any data not specified so far. 8584 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME 8585 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); 8586 } else if (arg.indexOf('/') >= 0) { 8587 // The argument is a component name. Build an Intent to launch 8588 // it. 8589 baseIntent = new Intent(Intent.ACTION_MAIN); 8590 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8591 baseIntent.setComponent(ComponentName.unflattenFromString(arg)); 8592 } else { 8593 // Assume the argument is a package name. 8594 baseIntent = new Intent(Intent.ACTION_MAIN); 8595 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8596 baseIntent.setPackage(arg); 8597 } 8598 if (baseIntent != null) { 8599 Bundle extras = intent.getExtras(); 8600 intent.replaceExtras((Bundle)null); 8601 Bundle uriExtras = baseIntent.getExtras(); 8602 baseIntent.replaceExtras((Bundle)null); 8603 if (intent.getAction() != null && baseIntent.getCategories() != null) { 8604 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); 8605 for (String c : cats) { 8606 baseIntent.removeCategory(c); 8607 } 8608 } 8609 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); 8610 if (extras == null) { 8611 extras = uriExtras; 8612 } else if (uriExtras != null) { 8613 uriExtras.putAll(extras); 8614 extras = uriExtras; 8615 } 8616 intent.replaceExtras(extras); 8617 hasIntentInfo = true; 8618 } 8619 8620 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); 8621 return intent; 8622 } 8623 8624 /** @hide */ 8625 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) printIntentArgsHelp(PrintWriter pw, String prefix)8626 public static void printIntentArgsHelp(PrintWriter pw, String prefix) { 8627 final String[] lines = new String[] { 8628 "<INTENT> specifications include these flags and arguments:", 8629 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]", 8630 " [-c <CATEGORY> [-c <CATEGORY>] ...]", 8631 " [-n <COMPONENT_NAME>]", 8632 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", 8633 " [--esn <EXTRA_KEY> ...]", 8634 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", 8635 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", 8636 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", 8637 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", 8638 " [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]", 8639 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", 8640 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", 8641 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8642 " (multiple extras passed as Integer[])", 8643 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8644 " (multiple extras passed as List<Integer>)", 8645 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8646 " (multiple extras passed as Long[])", 8647 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8648 " (multiple extras passed as List<Long>)", 8649 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8650 " (multiple extras passed as Float[])", 8651 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8652 " (multiple extras passed as List<Float>)", 8653 " [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]", 8654 " (multiple extras passed as Double[])", 8655 " [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]", 8656 " (multiple extras passed as List<Double>)", 8657 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8658 " (multiple extras passed as String[]; to embed a comma into a string,", 8659 " escape it using \"\\,\")", 8660 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8661 " (multiple extras passed as List<String>; to embed a comma into a string,", 8662 " escape it using \"\\,\")", 8663 " [-f <FLAG>]", 8664 " [--grant-read-uri-permission] [--grant-write-uri-permission]", 8665 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", 8666 " [--debug-log-resolution] [--exclude-stopped-packages]", 8667 " [--include-stopped-packages]", 8668 " [--activity-brought-to-front] [--activity-clear-top]", 8669 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", 8670 " [--activity-launched-from-history] [--activity-multiple-task]", 8671 " [--activity-no-animation] [--activity-no-history]", 8672 " [--activity-no-user-action] [--activity-previous-is-top]", 8673 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", 8674 " [--activity-single-top] [--activity-clear-task]", 8675 " [--activity-task-on-home] [--activity-match-external]", 8676 " [--receiver-registered-only] [--receiver-replace-pending]", 8677 " [--receiver-foreground] [--receiver-no-abort]", 8678 " [--receiver-include-background]", 8679 " [--selector]", 8680 " [<URI> | <PACKAGE> | <COMPONENT>]" 8681 }; 8682 for (String line : lines) { 8683 pw.print(prefix); 8684 pw.println(line); 8685 } 8686 } 8687 8688 /** 8689 * Retrieve the general action to be performed, such as 8690 * {@link #ACTION_VIEW}. The action describes the general way the rest of 8691 * the information in the intent should be interpreted -- most importantly, 8692 * what to do with the data returned by {@link #getData}. 8693 * 8694 * @return The action of this intent or null if none is specified. 8695 * 8696 * @see #setAction 8697 */ getAction()8698 public @Nullable String getAction() { 8699 return mAction; 8700 } 8701 8702 /** 8703 * Retrieve data this intent is operating on. This URI specifies the name 8704 * of the data; often it uses the content: scheme, specifying data in a 8705 * content provider. Other schemes may be handled by specific activities, 8706 * such as http: by the web browser. 8707 * 8708 * @return The URI of the data this intent is targeting or null. 8709 * 8710 * @see #getScheme 8711 * @see #setData 8712 */ getData()8713 public @Nullable Uri getData() { 8714 return mData; 8715 } 8716 8717 /** 8718 * The same as {@link #getData()}, but returns the URI as an encoded 8719 * String. 8720 */ getDataString()8721 public @Nullable String getDataString() { 8722 return mData != null ? mData.toString() : null; 8723 } 8724 8725 /** 8726 * Return the scheme portion of the intent's data. If the data is null or 8727 * does not include a scheme, null is returned. Otherwise, the scheme 8728 * prefix without the final ':' is returned, i.e. "http". 8729 * 8730 * <p>This is the same as calling getData().getScheme() (and checking for 8731 * null data). 8732 * 8733 * @return The scheme of this intent. 8734 * 8735 * @see #getData 8736 */ getScheme()8737 public @Nullable String getScheme() { 8738 return mData != null ? mData.getScheme() : null; 8739 } 8740 8741 /** 8742 * Retrieve any explicit MIME type included in the intent. This is usually 8743 * null, as the type is determined by the intent data. 8744 * 8745 * @return If a type was manually set, it is returned; else null is 8746 * returned. 8747 * 8748 * @see #resolveType(ContentResolver) 8749 * @see #setType 8750 */ getType()8751 public @Nullable String getType() { 8752 return mType; 8753 } 8754 8755 8756 /** 8757 * @hide For the experimental component alias feature. Do not use, unless you know what it is. 8758 */ 8759 @Nullable getOriginalIntent()8760 public Intent getOriginalIntent() { 8761 return mOriginalIntent; 8762 } 8763 8764 /** 8765 * @hide For the experimental component alias feature. Do not use, unless you know what it is. 8766 */ setOriginalIntent(@ullable Intent originalIntent)8767 public void setOriginalIntent(@Nullable Intent originalIntent) { 8768 mOriginalIntent = originalIntent; 8769 } 8770 8771 /** 8772 * Return the MIME data type of this intent. If the type field is 8773 * explicitly set, that is simply returned. Otherwise, if the data is set, 8774 * the type of that data is returned. If neither fields are set, a null is 8775 * returned. 8776 * 8777 * @return The MIME type of this intent. 8778 * 8779 * @see #getType 8780 * @see #resolveType(ContentResolver) 8781 */ resolveType(@onNull Context context)8782 public @Nullable String resolveType(@NonNull Context context) { 8783 return resolveType(context.getContentResolver()); 8784 } 8785 8786 /** 8787 * Return the MIME data type of this intent. If the type field is 8788 * explicitly set, that is simply returned. Otherwise, if the data is set, 8789 * the type of that data is returned. If neither fields are set, a null is 8790 * returned. 8791 * 8792 * @param resolver A ContentResolver that can be used to determine the MIME 8793 * type of the intent's data. 8794 * 8795 * @return The MIME type of this intent. 8796 * 8797 * @see #getType 8798 * @see #resolveType(Context) 8799 */ resolveType(@onNull ContentResolver resolver)8800 public @Nullable String resolveType(@NonNull ContentResolver resolver) { 8801 if (mType != null) { 8802 return mType; 8803 } 8804 if (mData != null) { 8805 if ("content".equals(mData.getScheme())) { 8806 return resolver.getType(mData); 8807 } 8808 } 8809 return null; 8810 } 8811 8812 /** 8813 * Return the MIME data type of this intent, only if it will be needed for 8814 * intent resolution. This is not generally useful for application code; 8815 * it is used by the frameworks for communicating with back-end system 8816 * services. 8817 * 8818 * @param resolver A ContentResolver that can be used to determine the MIME 8819 * type of the intent's data. 8820 * 8821 * @return The MIME type of this intent, or null if it is unknown or not 8822 * needed. 8823 */ resolveTypeIfNeeded(@onNull ContentResolver resolver)8824 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) { 8825 // Match logic in PackageManagerService#applyEnforceIntentFilterMatching(...) 8826 if (mComponent != null && (Process.myUid() == Process.ROOT_UID 8827 || Process.myUid() == Process.SYSTEM_UID 8828 || mComponent.getPackageName().equals(ActivityThread.currentPackageName()))) { 8829 return mType; 8830 } 8831 return resolveType(resolver); 8832 } 8833 8834 /** 8835 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity 8836 * of the Intent to distinguish it from other Intents. 8837 * 8838 * @return The identifier of this intent or null if none is specified. 8839 * 8840 * @see #setIdentifier 8841 */ getIdentifier()8842 public @Nullable String getIdentifier() { 8843 return mIdentifier; 8844 } 8845 8846 /** 8847 * Check if a category exists in the intent. 8848 * 8849 * @param category The category to check. 8850 * 8851 * @return boolean True if the intent contains the category, else false. 8852 * 8853 * @see #getCategories 8854 * @see #addCategory 8855 */ hasCategory(String category)8856 public boolean hasCategory(String category) { 8857 return mCategories != null && mCategories.contains(category); 8858 } 8859 8860 /** 8861 * Return the set of all categories in the intent. If there are no categories, 8862 * returns NULL. 8863 * 8864 * @return The set of categories you can examine. Do not modify! 8865 * 8866 * @see #hasCategory 8867 * @see #addCategory 8868 */ getCategories()8869 public Set<String> getCategories() { 8870 return mCategories; 8871 } 8872 8873 /** 8874 * Return the specific selector associated with this Intent. If there is 8875 * none, returns null. See {@link #setSelector} for more information. 8876 * 8877 * @see #setSelector 8878 */ getSelector()8879 public @Nullable Intent getSelector() { 8880 return mSelector; 8881 } 8882 8883 /** 8884 * Return the {@link ClipData} associated with this Intent. If there is 8885 * none, returns null. See {@link #setClipData} for more information. 8886 * 8887 * @see #setClipData 8888 */ getClipData()8889 public @Nullable ClipData getClipData() { 8890 return mClipData; 8891 } 8892 8893 /** @hide */ getContentUserHint()8894 public int getContentUserHint() { 8895 return mContentUserHint; 8896 } 8897 8898 /** @hide */ getLaunchToken()8899 public String getLaunchToken() { 8900 return mLaunchToken; 8901 } 8902 8903 /** @hide */ setLaunchToken(String launchToken)8904 public void setLaunchToken(String launchToken) { 8905 mLaunchToken = launchToken; 8906 } 8907 8908 /** 8909 * Sets the ClassLoader that will be used when unmarshalling 8910 * any Parcelable values from the extras of this Intent. 8911 * 8912 * @param loader a ClassLoader, or null to use the default loader 8913 * at the time of unmarshalling. 8914 */ setExtrasClassLoader(@ullable ClassLoader loader)8915 public void setExtrasClassLoader(@Nullable ClassLoader loader) { 8916 if (mExtras != null) { 8917 mExtras.setClassLoader(loader); 8918 } 8919 } 8920 8921 /** 8922 * Returns true if an extra value is associated with the given name. 8923 * @param name the extra's name 8924 * @return true if the given extra is present. 8925 */ hasExtra(String name)8926 public boolean hasExtra(String name) { 8927 return mExtras != null && mExtras.containsKey(name); 8928 } 8929 8930 /** 8931 * Returns true if the Intent's extras contain a parcelled file descriptor. 8932 * @return true if the Intent contains a parcelled file descriptor. 8933 */ hasFileDescriptors()8934 public boolean hasFileDescriptors() { 8935 return mExtras != null && mExtras.hasFileDescriptors(); 8936 } 8937 8938 /** {@hide} */ 8939 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) setAllowFds(boolean allowFds)8940 public void setAllowFds(boolean allowFds) { 8941 if (mExtras != null) { 8942 mExtras.setAllowFds(allowFds); 8943 } 8944 } 8945 8946 /** {@hide} */ setDefusable(boolean defusable)8947 public void setDefusable(boolean defusable) { 8948 if (mExtras != null) { 8949 mExtras.setDefusable(defusable); 8950 } 8951 } 8952 8953 /** 8954 * Retrieve extended data from the intent. 8955 * 8956 * @param name The name of the desired item. 8957 * 8958 * @return the value of an item previously added with putExtra(), 8959 * or null if none was found. 8960 * 8961 * @deprecated 8962 * @hide 8963 */ 8964 @Deprecated 8965 @UnsupportedAppUsage getExtra(String name)8966 public Object getExtra(String name) { 8967 return getExtra(name, null); 8968 } 8969 8970 /** 8971 * Retrieve extended data from the intent. 8972 * 8973 * @param name The name of the desired item. 8974 * @param defaultValue the value to be returned if no value of the desired 8975 * type is stored with the given name. 8976 * 8977 * @return the value of an item previously added with putExtra(), 8978 * or the default value if none was found. 8979 * 8980 * @see #putExtra(String, boolean) 8981 */ getBooleanExtra(String name, boolean defaultValue)8982 public boolean getBooleanExtra(String name, boolean defaultValue) { 8983 return mExtras == null ? defaultValue : 8984 mExtras.getBoolean(name, defaultValue); 8985 } 8986 8987 /** 8988 * Retrieve extended data from the intent. 8989 * 8990 * @param name The name of the desired item. 8991 * @param defaultValue the value to be returned if no value of the desired 8992 * type is stored with the given name. 8993 * 8994 * @return the value of an item previously added with putExtra(), 8995 * or the default value if none was found. 8996 * 8997 * @see #putExtra(String, byte) 8998 */ getByteExtra(String name, byte defaultValue)8999 public byte getByteExtra(String name, byte defaultValue) { 9000 return mExtras == null ? defaultValue : 9001 mExtras.getByte(name, defaultValue); 9002 } 9003 9004 /** 9005 * Retrieve extended data from the intent. 9006 * 9007 * @param name The name of the desired item. 9008 * @param defaultValue the value to be returned if no value of the desired 9009 * type is stored with the given name. 9010 * 9011 * @return the value of an item previously added with putExtra(), 9012 * or the default value if none was found. 9013 * 9014 * @see #putExtra(String, short) 9015 */ getShortExtra(String name, short defaultValue)9016 public short getShortExtra(String name, short defaultValue) { 9017 return mExtras == null ? defaultValue : 9018 mExtras.getShort(name, defaultValue); 9019 } 9020 9021 /** 9022 * Retrieve extended data from the intent. 9023 * 9024 * @param name The name of the desired item. 9025 * @param defaultValue the value to be returned if no value of the desired 9026 * type is stored with the given name. 9027 * 9028 * @return the value of an item previously added with putExtra(), 9029 * or the default value if none was found. 9030 * 9031 * @see #putExtra(String, char) 9032 */ getCharExtra(String name, char defaultValue)9033 public char getCharExtra(String name, char defaultValue) { 9034 return mExtras == null ? defaultValue : 9035 mExtras.getChar(name, defaultValue); 9036 } 9037 9038 /** 9039 * Retrieve extended data from the intent. 9040 * 9041 * @param name The name of the desired item. 9042 * @param defaultValue the value to be returned if no value of the desired 9043 * type is stored with the given name. 9044 * 9045 * @return the value of an item previously added with putExtra(), 9046 * or the default value if none was found. 9047 * 9048 * @see #putExtra(String, int) 9049 */ getIntExtra(String name, int defaultValue)9050 public int getIntExtra(String name, int defaultValue) { 9051 return mExtras == null ? defaultValue : 9052 mExtras.getInt(name, defaultValue); 9053 } 9054 9055 /** 9056 * Retrieve extended data from the intent. 9057 * 9058 * @param name The name of the desired item. 9059 * @param defaultValue the value to be returned if no value of the desired 9060 * type is stored with the given name. 9061 * 9062 * @return the value of an item previously added with putExtra(), 9063 * or the default value if none was found. 9064 * 9065 * @see #putExtra(String, long) 9066 */ getLongExtra(String name, long defaultValue)9067 public long getLongExtra(String name, long defaultValue) { 9068 return mExtras == null ? defaultValue : 9069 mExtras.getLong(name, defaultValue); 9070 } 9071 9072 /** 9073 * Retrieve extended data from the intent. 9074 * 9075 * @param name The name of the desired item. 9076 * @param defaultValue the value to be returned if no value of the desired 9077 * type is stored with the given name. 9078 * 9079 * @return the value of an item previously added with putExtra(), 9080 * or the default value if no such item is present 9081 * 9082 * @see #putExtra(String, float) 9083 */ getFloatExtra(String name, float defaultValue)9084 public float getFloatExtra(String name, float defaultValue) { 9085 return mExtras == null ? defaultValue : 9086 mExtras.getFloat(name, defaultValue); 9087 } 9088 9089 /** 9090 * Retrieve extended data from the intent. 9091 * 9092 * @param name The name of the desired item. 9093 * @param defaultValue the value to be returned if no value of the desired 9094 * type is stored with the given name. 9095 * 9096 * @return the value of an item previously added with putExtra(), 9097 * or the default value if none was found. 9098 * 9099 * @see #putExtra(String, double) 9100 */ getDoubleExtra(String name, double defaultValue)9101 public double getDoubleExtra(String name, double defaultValue) { 9102 return mExtras == null ? defaultValue : 9103 mExtras.getDouble(name, defaultValue); 9104 } 9105 9106 /** 9107 * Retrieve extended data from the intent. 9108 * 9109 * @param name The name of the desired item. 9110 * 9111 * @return the value of an item previously added with putExtra(), 9112 * or null if no String value was found. 9113 * 9114 * @see #putExtra(String, String) 9115 */ getStringExtra(String name)9116 public @Nullable String getStringExtra(String name) { 9117 return mExtras == null ? null : mExtras.getString(name); 9118 } 9119 9120 /** 9121 * Retrieve extended data from the intent. 9122 * 9123 * @param name The name of the desired item. 9124 * 9125 * @return the value of an item previously added with putExtra(), 9126 * or null if no CharSequence value was found. 9127 * 9128 * @see #putExtra(String, CharSequence) 9129 */ getCharSequenceExtra(String name)9130 public @Nullable CharSequence getCharSequenceExtra(String name) { 9131 return mExtras == null ? null : mExtras.getCharSequence(name); 9132 } 9133 9134 /** 9135 * Retrieve extended data from the intent. 9136 * 9137 * @param name The name of the desired item. 9138 * 9139 * @return the value of an item previously added with putExtra(), 9140 * or null if no Parcelable value was found. 9141 * 9142 * @deprecated Use the type-safer {@link #getParcelableExtra(String, Class)} starting from 9143 * Android {@link Build.VERSION_CODES#TIRAMISU}. 9144 * 9145 * @see #putExtra(String, Parcelable) 9146 */ 9147 @Deprecated getParcelableExtra(String name)9148 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) { 9149 return mExtras == null ? null : mExtras.<T>getParcelable(name); 9150 } 9151 9152 /** 9153 * Retrieve extended data from the intent. 9154 * 9155 * @param name The name of the desired item. 9156 * @param clazz The type of the object expected. 9157 * 9158 * @return the value of an item previously added with putExtra(), 9159 * or null if no Parcelable value was found. 9160 * 9161 * @see #putExtra(String, Parcelable) 9162 */ getParcelableExtra(@ullable String name, @NonNull Class<T> clazz)9163 public @Nullable <T> T getParcelableExtra(@Nullable String name, @NonNull Class<T> clazz) { 9164 return mExtras == null ? null : mExtras.getParcelable(name, clazz); 9165 } 9166 9167 /** 9168 * Retrieve extended data from the intent. 9169 * 9170 * @param name The name of the desired item. 9171 * 9172 * @return the value of an item previously added with putExtra(), 9173 * or null if no Parcelable[] value was found. 9174 * 9175 * @deprecated Use the type-safer {@link #getParcelableArrayExtra(String, Class)} starting from 9176 * Android {@link Build.VERSION_CODES#TIRAMISU}. 9177 * 9178 * @see #putExtra(String, Parcelable[]) 9179 */ 9180 @Deprecated getParcelableArrayExtra(String name)9181 public @Nullable Parcelable[] getParcelableArrayExtra(String name) { 9182 return mExtras == null ? null : mExtras.getParcelableArray(name); 9183 } 9184 9185 /** 9186 * Retrieve extended data from the intent. 9187 * 9188 * @param name The name of the desired item. 9189 * @param clazz The type of the items inside the array. This is only verified when unparceling. 9190 * 9191 * @return the value of an item previously added with putExtra(), 9192 * or null if no Parcelable[] value was found. 9193 * 9194 * @see #putExtra(String, Parcelable[]) 9195 */ 9196 @SuppressLint({"ArrayReturn", "NullableCollection"}) getParcelableArrayExtra(@ullable String name, @NonNull Class<T> clazz)9197 public @Nullable <T> T[] getParcelableArrayExtra(@Nullable String name, 9198 @NonNull Class<T> clazz) { 9199 return mExtras == null ? null : mExtras.getParcelableArray(name, clazz); 9200 } 9201 9202 /** 9203 * Retrieve extended data from the intent. 9204 * 9205 * @param name The name of the desired item. 9206 * 9207 * @return the value of an item previously added with 9208 * putParcelableArrayListExtra(), or null if no 9209 * ArrayList<Parcelable> value was found. 9210 * 9211 * @deprecated Use the type-safer {@link #getParcelableArrayListExtra(String, Class)} starting 9212 * from Android {@link Build.VERSION_CODES#TIRAMISU}. 9213 * 9214 * @see #putParcelableArrayListExtra(String, ArrayList) 9215 */ 9216 @Deprecated getParcelableArrayListExtra(String name)9217 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { 9218 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); 9219 } 9220 9221 /** 9222 * Retrieve extended data from the intent. 9223 * 9224 * @param name The name of the desired item. 9225 * @param clazz The type of the items inside the array list. This is only verified when 9226 * unparceling. 9227 * 9228 * @return the value of an item previously added with 9229 * putParcelableArrayListExtra(), or null if no 9230 * ArrayList<Parcelable> value was found. 9231 * 9232 * @see #putParcelableArrayListExtra(String, ArrayList) 9233 */ 9234 @SuppressLint({"ConcreteCollection", "NullableCollection"}) getParcelableArrayListExtra(@ullable String name, @NonNull Class<? extends T> clazz)9235 public @Nullable <T> ArrayList<T> getParcelableArrayListExtra(@Nullable String name, 9236 @NonNull Class<? extends T> clazz) { 9237 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name, clazz); 9238 } 9239 9240 /** 9241 * Retrieve extended data from the intent. 9242 * 9243 * @param name The name of the desired item. 9244 * 9245 * @return the value of an item previously added with putExtra(), 9246 * or null if no Serializable value was found. 9247 * 9248 * @deprecated Use the type-safer {@link #getSerializableExtra(String, Class)} starting from 9249 * Android {@link Build.VERSION_CODES#TIRAMISU}. 9250 * 9251 * @see #putExtra(String, Serializable) 9252 */ getSerializableExtra(String name)9253 public @Nullable Serializable getSerializableExtra(String name) { 9254 return mExtras == null ? null : mExtras.getSerializable(name); 9255 } 9256 9257 /** 9258 * Retrieve extended data from the intent. 9259 * 9260 * @param name The name of the desired item. 9261 * @param clazz The type of the object expected. 9262 * 9263 * @return the value of an item previously added with putExtra(), 9264 * or null if no Serializable value was found. 9265 * 9266 * @see #putExtra(String, Serializable) 9267 */ getSerializableExtra(@ullable String name, @NonNull Class<T> clazz)9268 public @Nullable <T extends Serializable> T getSerializableExtra(@Nullable String name, 9269 @NonNull Class<T> clazz) { 9270 return mExtras == null ? null : mExtras.getSerializable(name, clazz); 9271 } 9272 9273 /** 9274 * Retrieve extended data from the intent. 9275 * 9276 * @param name The name of the desired item. 9277 * 9278 * @return the value of an item previously added with 9279 * putIntegerArrayListExtra(), or null if no 9280 * ArrayList<Integer> value was found. 9281 * 9282 * @see #putIntegerArrayListExtra(String, ArrayList) 9283 */ getIntegerArrayListExtra(String name)9284 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) { 9285 return mExtras == null ? null : mExtras.getIntegerArrayList(name); 9286 } 9287 9288 /** 9289 * Retrieve extended data from the intent. 9290 * 9291 * @param name The name of the desired item. 9292 * 9293 * @return the value of an item previously added with 9294 * putStringArrayListExtra(), or null if no 9295 * ArrayList<String> value was found. 9296 * 9297 * @see #putStringArrayListExtra(String, ArrayList) 9298 */ getStringArrayListExtra(String name)9299 public @Nullable ArrayList<String> getStringArrayListExtra(String name) { 9300 return mExtras == null ? null : mExtras.getStringArrayList(name); 9301 } 9302 9303 /** 9304 * Retrieve extended data from the intent. 9305 * 9306 * @param name The name of the desired item. 9307 * 9308 * @return the value of an item previously added with 9309 * putCharSequenceArrayListExtra, or null if no 9310 * ArrayList<CharSequence> value was found. 9311 * 9312 * @see #putCharSequenceArrayListExtra(String, ArrayList) 9313 */ getCharSequenceArrayListExtra(String name)9314 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { 9315 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); 9316 } 9317 9318 /** 9319 * Retrieve extended data from the intent. 9320 * 9321 * @param name The name of the desired item. 9322 * 9323 * @return the value of an item previously added with putExtra(), 9324 * or null if no boolean array value was found. 9325 * 9326 * @see #putExtra(String, boolean[]) 9327 */ getBooleanArrayExtra(String name)9328 public @Nullable boolean[] getBooleanArrayExtra(String name) { 9329 return mExtras == null ? null : mExtras.getBooleanArray(name); 9330 } 9331 9332 /** 9333 * Retrieve extended data from the intent. 9334 * 9335 * @param name The name of the desired item. 9336 * 9337 * @return the value of an item previously added with putExtra(), 9338 * or null if no byte array value was found. 9339 * 9340 * @see #putExtra(String, byte[]) 9341 */ getByteArrayExtra(String name)9342 public @Nullable byte[] getByteArrayExtra(String name) { 9343 return mExtras == null ? null : mExtras.getByteArray(name); 9344 } 9345 9346 /** 9347 * Retrieve extended data from the intent. 9348 * 9349 * @param name The name of the desired item. 9350 * 9351 * @return the value of an item previously added with putExtra(), 9352 * or null if no short array value was found. 9353 * 9354 * @see #putExtra(String, short[]) 9355 */ getShortArrayExtra(String name)9356 public @Nullable short[] getShortArrayExtra(String name) { 9357 return mExtras == null ? null : mExtras.getShortArray(name); 9358 } 9359 9360 /** 9361 * Retrieve extended data from the intent. 9362 * 9363 * @param name The name of the desired item. 9364 * 9365 * @return the value of an item previously added with putExtra(), 9366 * or null if no char array value was found. 9367 * 9368 * @see #putExtra(String, char[]) 9369 */ getCharArrayExtra(String name)9370 public @Nullable char[] getCharArrayExtra(String name) { 9371 return mExtras == null ? null : mExtras.getCharArray(name); 9372 } 9373 9374 /** 9375 * Retrieve extended data from the intent. 9376 * 9377 * @param name The name of the desired item. 9378 * 9379 * @return the value of an item previously added with putExtra(), 9380 * or null if no int array value was found. 9381 * 9382 * @see #putExtra(String, int[]) 9383 */ getIntArrayExtra(String name)9384 public @Nullable int[] getIntArrayExtra(String name) { 9385 return mExtras == null ? null : mExtras.getIntArray(name); 9386 } 9387 9388 /** 9389 * Retrieve extended data from the intent. 9390 * 9391 * @param name The name of the desired item. 9392 * 9393 * @return the value of an item previously added with putExtra(), 9394 * or null if no long array value was found. 9395 * 9396 * @see #putExtra(String, long[]) 9397 */ getLongArrayExtra(String name)9398 public @Nullable long[] getLongArrayExtra(String name) { 9399 return mExtras == null ? null : mExtras.getLongArray(name); 9400 } 9401 9402 /** 9403 * Retrieve extended data from the intent. 9404 * 9405 * @param name The name of the desired item. 9406 * 9407 * @return the value of an item previously added with putExtra(), 9408 * or null if no float array value was found. 9409 * 9410 * @see #putExtra(String, float[]) 9411 */ getFloatArrayExtra(String name)9412 public @Nullable float[] getFloatArrayExtra(String name) { 9413 return mExtras == null ? null : mExtras.getFloatArray(name); 9414 } 9415 9416 /** 9417 * Retrieve extended data from the intent. 9418 * 9419 * @param name The name of the desired item. 9420 * 9421 * @return the value of an item previously added with putExtra(), 9422 * or null if no double array value was found. 9423 * 9424 * @see #putExtra(String, double[]) 9425 */ getDoubleArrayExtra(String name)9426 public @Nullable double[] getDoubleArrayExtra(String name) { 9427 return mExtras == null ? null : mExtras.getDoubleArray(name); 9428 } 9429 9430 /** 9431 * Retrieve extended data from the intent. 9432 * 9433 * @param name The name of the desired item. 9434 * 9435 * @return the value of an item previously added with putExtra(), 9436 * or null if no String array value was found. 9437 * 9438 * @see #putExtra(String, String[]) 9439 */ getStringArrayExtra(String name)9440 public @Nullable String[] getStringArrayExtra(String name) { 9441 return mExtras == null ? null : mExtras.getStringArray(name); 9442 } 9443 9444 /** 9445 * Retrieve extended data from the intent. 9446 * 9447 * @param name The name of the desired item. 9448 * 9449 * @return the value of an item previously added with putExtra(), 9450 * or null if no CharSequence array value was found. 9451 * 9452 * @see #putExtra(String, CharSequence[]) 9453 */ getCharSequenceArrayExtra(String name)9454 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) { 9455 return mExtras == null ? null : mExtras.getCharSequenceArray(name); 9456 } 9457 9458 /** 9459 * Retrieve extended data from the intent. 9460 * 9461 * @param name The name of the desired item. 9462 * 9463 * @return the value of an item previously added with putExtra(), 9464 * or null if no Bundle value was found. 9465 * 9466 * @see #putExtra(String, Bundle) 9467 */ getBundleExtra(String name)9468 public @Nullable Bundle getBundleExtra(String name) { 9469 return mExtras == null ? null : mExtras.getBundle(name); 9470 } 9471 9472 /** 9473 * Retrieve extended data from the intent. 9474 * 9475 * @param name The name of the desired item. 9476 * 9477 * @return the value of an item previously added with putExtra(), 9478 * or null if no IBinder value was found. 9479 * 9480 * @see #putExtra(String, IBinder) 9481 * 9482 * @deprecated 9483 * @hide 9484 */ 9485 @Deprecated 9486 @UnsupportedAppUsage getIBinderExtra(String name)9487 public IBinder getIBinderExtra(String name) { 9488 return mExtras == null ? null : mExtras.getIBinder(name); 9489 } 9490 9491 /** 9492 * Retrieve extended data from the intent. 9493 * 9494 * @param name The name of the desired item. 9495 * @param defaultValue The default value to return in case no item is 9496 * associated with the key 'name' 9497 * 9498 * @return the value of an item previously added with putExtra(), 9499 * or defaultValue if none was found. 9500 * 9501 * @see #putExtra 9502 * 9503 * @deprecated 9504 * @hide 9505 */ 9506 @Deprecated 9507 @UnsupportedAppUsage getExtra(String name, Object defaultValue)9508 public Object getExtra(String name, Object defaultValue) { 9509 Object result = defaultValue; 9510 if (mExtras != null) { 9511 Object result2 = mExtras.get(name); 9512 if (result2 != null) { 9513 result = result2; 9514 } 9515 } 9516 9517 return result; 9518 } 9519 9520 /** 9521 * Retrieves a map of extended data from the intent. 9522 * 9523 * @return the map of all extras previously added with putExtra(), 9524 * or null if none have been added. 9525 */ getExtras()9526 public @Nullable Bundle getExtras() { 9527 return (mExtras != null) 9528 ? new Bundle(mExtras) 9529 : null; 9530 } 9531 9532 /** 9533 * Returns the total size of the extras in bytes, or 0 if no extras are present. 9534 * @hide 9535 */ getExtrasTotalSize()9536 public int getExtrasTotalSize() { 9537 return (mExtras != null) 9538 ? mExtras.getSize() 9539 : 0; 9540 } 9541 9542 /** 9543 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or 9544 * return itself as-is. 9545 * @hide 9546 */ canStripForHistory()9547 public boolean canStripForHistory() { 9548 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null); 9549 } 9550 9551 /** 9552 * Call it when the system needs to keep an intent for logging purposes to remove fields 9553 * that are not needed for logging. 9554 * @hide 9555 */ maybeStripForHistory()9556 public Intent maybeStripForHistory() { 9557 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras? 9558 9559 if (!canStripForHistory()) { 9560 return this; 9561 } 9562 return new Intent(this, COPY_MODE_HISTORY); 9563 } 9564 9565 /** 9566 * Retrieve any special flags associated with this intent. You will 9567 * normally just set them with {@link #setFlags} and let the system 9568 * take the appropriate action with them. 9569 * 9570 * @return The currently set flags. 9571 * @see #setFlags 9572 * @see #addFlags 9573 * @see #removeFlags 9574 */ getFlags()9575 public @Flags int getFlags() { 9576 return mFlags; 9577 } 9578 9579 /** @hide */ 9580 @UnsupportedAppUsage isExcludingStopped()9581 public boolean isExcludingStopped() { 9582 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) 9583 == FLAG_EXCLUDE_STOPPED_PACKAGES; 9584 } 9585 9586 /** 9587 * Retrieve the application package name this Intent is limited to. When 9588 * resolving an Intent, if non-null this limits the resolution to only 9589 * components in the given application package. 9590 * 9591 * @return The name of the application package for the Intent. 9592 * 9593 * @see #resolveActivity 9594 * @see #setPackage 9595 */ getPackage()9596 public @Nullable String getPackage() { 9597 return mPackage; 9598 } 9599 9600 /** 9601 * Retrieve the concrete component associated with the intent. When receiving 9602 * an intent, this is the component that was found to best handle it (that is, 9603 * yourself) and will always be non-null; in all other cases it will be 9604 * null unless explicitly set. 9605 * 9606 * @return The name of the application component to handle the intent. 9607 * 9608 * @see #resolveActivity 9609 * @see #setComponent 9610 */ getComponent()9611 public @Nullable ComponentName getComponent() { 9612 return mComponent; 9613 } 9614 9615 /** 9616 * Get the bounds of the sender of this intent, in screen coordinates. This can be 9617 * used as a hint to the receiver for animations and the like. Null means that there 9618 * is no source bounds. 9619 */ getSourceBounds()9620 public @Nullable Rect getSourceBounds() { 9621 return mSourceBounds; 9622 } 9623 9624 /** 9625 * Return the Activity component that should be used to handle this intent. 9626 * The appropriate component is determined based on the information in the 9627 * intent, evaluated as follows: 9628 * 9629 * <p>If {@link #getComponent} returns an explicit class, that is returned 9630 * without any further consideration. 9631 * 9632 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent 9633 * category to be considered. 9634 * 9635 * <p>If {@link #getAction} is non-NULL, the activity must handle this 9636 * action. 9637 * 9638 * <p>If {@link #resolveType} returns non-NULL, the activity must handle 9639 * this type. 9640 * 9641 * <p>If {@link #addCategory} has added any categories, the activity must 9642 * handle ALL of the categories specified. 9643 * 9644 * <p>If {@link #getPackage} is non-NULL, only activity components in 9645 * that application package will be considered. 9646 * 9647 * <p>If there are no activities that satisfy all of these conditions, a 9648 * null string is returned. 9649 * 9650 * <p>If multiple activities are found to satisfy the intent, the one with 9651 * the highest priority will be used. If there are multiple activities 9652 * with the same priority, the system will either pick the best activity 9653 * based on user preference, or resolve to a system class that will allow 9654 * the user to pick an activity and forward from there. 9655 * 9656 * <p>This method is implemented simply by calling 9657 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter 9658 * true.</p> 9659 * <p> This API is called for you as part of starting an activity from an 9660 * intent. You do not normally need to call it yourself.</p> 9661 * 9662 * @param pm The package manager with which to resolve the Intent. 9663 * 9664 * @return Name of the component implementing an activity that can 9665 * display the intent. 9666 * 9667 * @see #setComponent 9668 * @see #getComponent 9669 * @see #resolveActivityInfo 9670 */ resolveActivity(@onNull PackageManager pm)9671 public ComponentName resolveActivity(@NonNull PackageManager pm) { 9672 if (mComponent != null) { 9673 return mComponent; 9674 } 9675 9676 ResolveInfo info = pm.resolveActivity( 9677 this, PackageManager.MATCH_DEFAULT_ONLY); 9678 if (info != null) { 9679 return new ComponentName( 9680 info.activityInfo.applicationInfo.packageName, 9681 info.activityInfo.name); 9682 } 9683 9684 return null; 9685 } 9686 9687 /** 9688 * Resolve the Intent into an {@link ActivityInfo} 9689 * describing the activity that should execute the intent. Resolution 9690 * follows the same rules as described for {@link #resolveActivity}, but 9691 * you get back the completely information about the resolved activity 9692 * instead of just its class name. 9693 * 9694 * @param pm The package manager with which to resolve the Intent. 9695 * @param flags Addition information to retrieve as per 9696 * {@link PackageManager#getActivityInfo(ComponentName, int) 9697 * PackageManager.getActivityInfo()}. 9698 * 9699 * @return PackageManager.ActivityInfo 9700 * 9701 * @see #resolveActivity 9702 */ resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)9703 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm, 9704 @PackageManager.ComponentInfoFlagsBits int flags) { 9705 ActivityInfo ai = null; 9706 if (mComponent != null) { 9707 try { 9708 ai = pm.getActivityInfo(mComponent, flags); 9709 } catch (PackageManager.NameNotFoundException e) { 9710 // ignore 9711 } 9712 } else { 9713 ResolveInfo info = pm.resolveActivity( 9714 this, PackageManager.MATCH_DEFAULT_ONLY | flags); 9715 if (info != null) { 9716 ai = info.activityInfo; 9717 } 9718 } 9719 9720 return ai; 9721 } 9722 9723 /** 9724 * Special function for use by the system to resolve service 9725 * intents to system apps. Throws an exception if there are 9726 * multiple potential matches to the Intent. Returns null if 9727 * there are no matches. 9728 * @hide 9729 */ 9730 @UnsupportedAppUsage resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)9731 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm, 9732 @PackageManager.ComponentInfoFlagsBits int flags) { 9733 if (mComponent != null) { 9734 return mComponent; 9735 } 9736 9737 List<ResolveInfo> results = pm.queryIntentServices(this, flags); 9738 if (results == null) { 9739 return null; 9740 } 9741 ComponentName comp = null; 9742 for (int i=0; i<results.size(); i++) { 9743 ResolveInfo ri = results.get(i); 9744 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { 9745 continue; 9746 } 9747 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, 9748 ri.serviceInfo.name); 9749 if (comp != null) { 9750 throw new IllegalStateException("Multiple system services handle " + this 9751 + ": " + comp + ", " + foundComp); 9752 } 9753 comp = foundComp; 9754 } 9755 return comp; 9756 } 9757 9758 /** 9759 * Set the general action to be performed. 9760 * 9761 * @param action An action name, such as ACTION_VIEW. Application-specific 9762 * actions should be prefixed with the vendor's package name. 9763 * 9764 * @return Returns the same Intent object, for chaining multiple calls 9765 * into a single statement. 9766 * 9767 * @see #getAction 9768 */ setAction(@ullable String action)9769 public @NonNull Intent setAction(@Nullable String action) { 9770 mAction = action != null ? action.intern() : null; 9771 return this; 9772 } 9773 9774 /** 9775 * Set the data this intent is operating on. This method automatically 9776 * clears any type that was previously set by {@link #setType} or 9777 * {@link #setTypeAndNormalize}. 9778 * 9779 * <p><em>Note: scheme matching in the Android framework is 9780 * case-sensitive, unlike the formal RFC. As a result, 9781 * you should always write your Uri with a lower case scheme, 9782 * or use {@link Uri#normalizeScheme} or 9783 * {@link #setDataAndNormalize} 9784 * to ensure that the scheme is converted to lower case.</em> 9785 * 9786 * @param data The Uri of the data this intent is now targeting. 9787 * 9788 * @return Returns the same Intent object, for chaining multiple calls 9789 * into a single statement. 9790 * 9791 * @see #getData 9792 * @see #setDataAndNormalize 9793 * @see android.net.Uri#normalizeScheme() 9794 */ setData(@ullable Uri data)9795 public @NonNull Intent setData(@Nullable Uri data) { 9796 mData = data; 9797 mType = null; 9798 return this; 9799 } 9800 9801 /** 9802 * Normalize and set the data this intent is operating on. 9803 * 9804 * <p>This method automatically clears any type that was 9805 * previously set (for example, by {@link #setType}). 9806 * 9807 * <p>The data Uri is normalized using 9808 * {@link android.net.Uri#normalizeScheme} before it is set, 9809 * so really this is just a convenience method for 9810 * <pre> 9811 * setData(data.normalize()) 9812 * </pre> 9813 * 9814 * @param data The Uri of the data this intent is now targeting. 9815 * 9816 * @return Returns the same Intent object, for chaining multiple calls 9817 * into a single statement. 9818 * 9819 * @see #getData 9820 * @see #setType 9821 * @see android.net.Uri#normalizeScheme 9822 */ setDataAndNormalize(@onNull Uri data)9823 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) { 9824 return setData(data.normalizeScheme()); 9825 } 9826 9827 /** 9828 * Set an explicit MIME data type. 9829 * 9830 * <p>This is used to create intents that only specify a type and not data, 9831 * for example to indicate the type of data to return. 9832 * 9833 * <p>This method automatically clears any data that was 9834 * previously set (for example by {@link #setData}). 9835 * 9836 * <p><em>Note: MIME type matching in the Android framework is 9837 * case-sensitive, unlike formal RFC MIME types. As a result, 9838 * you should always write your MIME types with lower case letters, 9839 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} 9840 * to ensure that it is converted to lower case.</em> 9841 * 9842 * @param type The MIME type of the data being handled by this intent. 9843 * 9844 * @return Returns the same Intent object, for chaining multiple calls 9845 * into a single statement. 9846 * 9847 * @see #getType 9848 * @see #setTypeAndNormalize 9849 * @see #setDataAndType 9850 * @see #normalizeMimeType 9851 */ setType(@ullable String type)9852 public @NonNull Intent setType(@Nullable String type) { 9853 mData = null; 9854 mType = type; 9855 return this; 9856 } 9857 9858 /** 9859 * Normalize and set an explicit MIME data type. 9860 * 9861 * <p>This is used to create intents that only specify a type and not data, 9862 * for example to indicate the type of data to return. 9863 * 9864 * <p>This method automatically clears any data that was 9865 * previously set (for example by {@link #setData}). 9866 * 9867 * <p>The MIME type is normalized using 9868 * {@link #normalizeMimeType} before it is set, 9869 * so really this is just a convenience method for 9870 * <pre> 9871 * setType(Intent.normalizeMimeType(type)) 9872 * </pre> 9873 * 9874 * @param type The MIME type of the data being handled by this intent. 9875 * 9876 * @return Returns the same Intent object, for chaining multiple calls 9877 * into a single statement. 9878 * 9879 * @see #getType 9880 * @see #setData 9881 * @see #normalizeMimeType 9882 */ setTypeAndNormalize(@ullable String type)9883 public @NonNull Intent setTypeAndNormalize(@Nullable String type) { 9884 return setType(normalizeMimeType(type)); 9885 } 9886 9887 /** 9888 * (Usually optional) Set the data for the intent along with an explicit 9889 * MIME data type. This method should very rarely be used -- it allows you 9890 * to override the MIME type that would ordinarily be inferred from the 9891 * data with your own type given here. 9892 * 9893 * <p><em>Note: MIME type and Uri scheme matching in the 9894 * Android framework is case-sensitive, unlike the formal RFC definitions. 9895 * As a result, you should always write these elements with lower case letters, 9896 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or 9897 * {@link #setDataAndTypeAndNormalize} 9898 * to ensure that they are converted to lower case.</em> 9899 * 9900 * @param data The Uri of the data this intent is now targeting. 9901 * @param type The MIME type of the data being handled by this intent. 9902 * 9903 * @return Returns the same Intent object, for chaining multiple calls 9904 * into a single statement. 9905 * 9906 * @see #setType 9907 * @see #setData 9908 * @see #normalizeMimeType 9909 * @see android.net.Uri#normalizeScheme 9910 * @see #setDataAndTypeAndNormalize 9911 */ setDataAndType(@ullable Uri data, @Nullable String type)9912 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) { 9913 mData = data; 9914 mType = type; 9915 return this; 9916 } 9917 9918 /** 9919 * (Usually optional) Normalize and set both the data Uri and an explicit 9920 * MIME data type. This method should very rarely be used -- it allows you 9921 * to override the MIME type that would ordinarily be inferred from the 9922 * data with your own type given here. 9923 * 9924 * <p>The data Uri and the MIME type are normalize using 9925 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} 9926 * before they are set, so really this is just a convenience method for 9927 * <pre> 9928 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) 9929 * </pre> 9930 * 9931 * @param data The Uri of the data this intent is now targeting. 9932 * @param type The MIME type of the data being handled by this intent. 9933 * 9934 * @return Returns the same Intent object, for chaining multiple calls 9935 * into a single statement. 9936 * 9937 * @see #setType 9938 * @see #setData 9939 * @see #setDataAndType 9940 * @see #normalizeMimeType 9941 * @see android.net.Uri#normalizeScheme 9942 */ setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)9943 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) { 9944 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); 9945 } 9946 9947 /** 9948 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent, 9949 * allowing it to be unique from other Intents that would otherwise look the same. In 9950 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two 9951 * Intents are the same as with other fields like {@link #setAction}. However, unlike those 9952 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter}; 9953 * it is as if the identifier has not been set on the Intent. 9954 * 9955 * <p>This can be used, for example, to make this Intent unique from other Intents that 9956 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware 9957 * however that the receiver of the PendingIntent will see whatever you put in here.) The 9958 * structure of this string is completely undefined by the platform, however if you are going 9959 * to be exposing identifier strings across different applications you may need to define 9960 * your own structure if there is no central party defining the contents of this field.</p> 9961 * 9962 * @param identifier The identifier for this Intent. The contents of the string have no 9963 * meaning to the system, except whether they are exactly the same as 9964 * another identifier. 9965 * 9966 * @return Returns the same Intent object, for chaining multiple calls 9967 * into a single statement. 9968 * 9969 * @see #getIdentifier 9970 */ setIdentifier(@ullable String identifier)9971 public @NonNull Intent setIdentifier(@Nullable String identifier) { 9972 mIdentifier = identifier; 9973 return this; 9974 } 9975 9976 /** 9977 * Add a new category to the intent. Categories provide additional detail 9978 * about the action the intent performs. When resolving an intent, only 9979 * activities that provide <em>all</em> of the requested categories will be 9980 * used. 9981 * 9982 * @param category The desired category. This can be either one of the 9983 * predefined Intent categories, or a custom category in your own 9984 * namespace. 9985 * 9986 * @return Returns the same Intent object, for chaining multiple calls 9987 * into a single statement. 9988 * 9989 * @see #hasCategory 9990 * @see #removeCategory 9991 */ addCategory(String category)9992 public @NonNull Intent addCategory(String category) { 9993 if (mCategories == null) { 9994 mCategories = new ArraySet<String>(); 9995 } 9996 mCategories.add(category.intern()); 9997 return this; 9998 } 9999 10000 /** 10001 * Remove a category from an intent. 10002 * 10003 * @param category The category to remove. 10004 * 10005 * @see #addCategory 10006 */ removeCategory(String category)10007 public void removeCategory(String category) { 10008 if (mCategories != null) { 10009 mCategories.remove(category); 10010 if (mCategories.size() == 0) { 10011 mCategories = null; 10012 } 10013 } 10014 } 10015 10016 /** 10017 * Set a selector for this Intent. This is a modification to the kinds of 10018 * things the Intent will match. If the selector is set, it will be used 10019 * when trying to find entities that can handle the Intent, instead of the 10020 * main contents of the Intent. This allows you build an Intent containing 10021 * a generic protocol while targeting it more specifically. 10022 * 10023 * <p>An example of where this may be used is with things like 10024 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an 10025 * Intent that will launch the Browser application. However, the correct 10026 * main entry point of an application is actually {@link #ACTION_MAIN} 10027 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} 10028 * used to specify the actual Activity to launch. If you launch the browser 10029 * with something different, undesired behavior may happen if the user has 10030 * previously or later launches it the normal way, since they do not match. 10031 * Instead, you can build an Intent with the MAIN action (but no ComponentName 10032 * yet specified) and set a selector with {@link #ACTION_MAIN} and 10033 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. 10034 * 10035 * <p>Setting a selector does not impact the behavior of 10036 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the 10037 * desired behavior of a selector -- it does not impact the base meaning 10038 * of the Intent, just what kinds of things will be matched against it 10039 * when determining who can handle it.</p> 10040 * 10041 * <p>You can not use both a selector and {@link #setPackage(String)} on 10042 * the same base Intent.</p> 10043 * 10044 * @param selector The desired selector Intent; set to null to not use 10045 * a special selector. 10046 */ setSelector(@ullable Intent selector)10047 public void setSelector(@Nullable Intent selector) { 10048 if (selector == this) { 10049 throw new IllegalArgumentException( 10050 "Intent being set as a selector of itself"); 10051 } 10052 if (selector != null && mPackage != null) { 10053 throw new IllegalArgumentException( 10054 "Can't set selector when package name is already set"); 10055 } 10056 mSelector = selector; 10057 } 10058 10059 /** 10060 * Set a {@link ClipData} associated with this Intent. This replaces any 10061 * previously set ClipData. 10062 * 10063 * <p>The ClipData in an intent is not used for Intent matching or other 10064 * such operations. Semantically it is like extras, used to transmit 10065 * additional data with the Intent. The main feature of using this over 10066 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} 10067 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI 10068 * items included in the clip data. This is useful, in particular, if 10069 * you want to transmit an Intent containing multiple <code>content:</code> 10070 * URIs for which the recipient may not have global permission to access the 10071 * content provider. 10072 * 10073 * <p>If the ClipData contains items that are themselves Intents, any 10074 * grant flags in those Intents will be ignored. Only the top-level flags 10075 * of the main Intent are respected, and will be applied to all Uri or 10076 * Intent items in the clip (or sub-items of the clip). 10077 * 10078 * <p>The MIME type, label, and icon in the ClipData object are not 10079 * directly used by Intent. Applications should generally rely on the 10080 * MIME type of the Intent itself, not what it may find in the ClipData. 10081 * A common practice is to construct a ClipData for use with an Intent 10082 * with a MIME type of "*/*". 10083 * 10084 * @param clip The new clip to set. May be null to clear the current clip. 10085 */ setClipData(@ullable ClipData clip)10086 public void setClipData(@Nullable ClipData clip) { 10087 mClipData = clip; 10088 } 10089 10090 /** 10091 * This is NOT a secure mechanism to identify the user who sent the intent. 10092 * When the intent is sent to a different user, it is used to fix uris by adding the user ID 10093 * who sent the intent. 10094 * @hide 10095 */ prepareToLeaveUser(int userId)10096 public void prepareToLeaveUser(int userId) { 10097 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. 10098 // We want mContentUserHint to refer to the original user, so don't do anything. 10099 if (mContentUserHint == UserHandle.USER_CURRENT) { 10100 mContentUserHint = userId; 10101 } 10102 } 10103 10104 /** 10105 * Add extended data to the intent. The name must include a package 10106 * prefix, for example the app com.android.contacts would use names 10107 * like "com.android.contacts.ShowAll". 10108 * 10109 * @param name The name of the extra data, with package prefix. 10110 * @param value The boolean data value. 10111 * 10112 * @return Returns the same Intent object, for chaining multiple calls 10113 * into a single statement. 10114 * 10115 * @see #putExtras 10116 * @see #removeExtra 10117 * @see #getBooleanExtra(String, boolean) 10118 */ putExtra(String name, boolean value)10119 public @NonNull Intent putExtra(String name, boolean value) { 10120 if (mExtras == null) { 10121 mExtras = new Bundle(); 10122 } 10123 mExtras.putBoolean(name, value); 10124 return this; 10125 } 10126 10127 /** 10128 * Add extended data to the intent. The name must include a package 10129 * prefix, for example the app com.android.contacts would use names 10130 * like "com.android.contacts.ShowAll". 10131 * 10132 * @param name The name of the extra data, with package prefix. 10133 * @param value The byte data value. 10134 * 10135 * @return Returns the same Intent object, for chaining multiple calls 10136 * into a single statement. 10137 * 10138 * @see #putExtras 10139 * @see #removeExtra 10140 * @see #getByteExtra(String, byte) 10141 */ putExtra(String name, byte value)10142 public @NonNull Intent putExtra(String name, byte value) { 10143 if (mExtras == null) { 10144 mExtras = new Bundle(); 10145 } 10146 mExtras.putByte(name, value); 10147 return this; 10148 } 10149 10150 /** 10151 * Add extended data to the intent. The name must include a package 10152 * prefix, for example the app com.android.contacts would use names 10153 * like "com.android.contacts.ShowAll". 10154 * 10155 * @param name The name of the extra data, with package prefix. 10156 * @param value The char data value. 10157 * 10158 * @return Returns the same Intent object, for chaining multiple calls 10159 * into a single statement. 10160 * 10161 * @see #putExtras 10162 * @see #removeExtra 10163 * @see #getCharExtra(String, char) 10164 */ putExtra(String name, char value)10165 public @NonNull Intent putExtra(String name, char value) { 10166 if (mExtras == null) { 10167 mExtras = new Bundle(); 10168 } 10169 mExtras.putChar(name, value); 10170 return this; 10171 } 10172 10173 /** 10174 * Add extended data to the intent. The name must include a package 10175 * prefix, for example the app com.android.contacts would use names 10176 * like "com.android.contacts.ShowAll". 10177 * 10178 * @param name The name of the extra data, with package prefix. 10179 * @param value The short data value. 10180 * 10181 * @return Returns the same Intent object, for chaining multiple calls 10182 * into a single statement. 10183 * 10184 * @see #putExtras 10185 * @see #removeExtra 10186 * @see #getShortExtra(String, short) 10187 */ putExtra(String name, short value)10188 public @NonNull Intent putExtra(String name, short value) { 10189 if (mExtras == null) { 10190 mExtras = new Bundle(); 10191 } 10192 mExtras.putShort(name, value); 10193 return this; 10194 } 10195 10196 /** 10197 * Add extended data to the intent. The name must include a package 10198 * prefix, for example the app com.android.contacts would use names 10199 * like "com.android.contacts.ShowAll". 10200 * 10201 * @param name The name of the extra data, with package prefix. 10202 * @param value The integer data value. 10203 * 10204 * @return Returns the same Intent object, for chaining multiple calls 10205 * into a single statement. 10206 * 10207 * @see #putExtras 10208 * @see #removeExtra 10209 * @see #getIntExtra(String, int) 10210 */ putExtra(String name, int value)10211 public @NonNull Intent putExtra(String name, int value) { 10212 if (mExtras == null) { 10213 mExtras = new Bundle(); 10214 } 10215 mExtras.putInt(name, value); 10216 return this; 10217 } 10218 10219 /** 10220 * Add extended data to the intent. The name must include a package 10221 * prefix, for example the app com.android.contacts would use names 10222 * like "com.android.contacts.ShowAll". 10223 * 10224 * @param name The name of the extra data, with package prefix. 10225 * @param value The long data value. 10226 * 10227 * @return Returns the same Intent object, for chaining multiple calls 10228 * into a single statement. 10229 * 10230 * @see #putExtras 10231 * @see #removeExtra 10232 * @see #getLongExtra(String, long) 10233 */ putExtra(String name, long value)10234 public @NonNull Intent putExtra(String name, long value) { 10235 if (mExtras == null) { 10236 mExtras = new Bundle(); 10237 } 10238 mExtras.putLong(name, value); 10239 return this; 10240 } 10241 10242 /** 10243 * Add extended data to the intent. The name must include a package 10244 * prefix, for example the app com.android.contacts would use names 10245 * like "com.android.contacts.ShowAll". 10246 * 10247 * @param name The name of the extra data, with package prefix. 10248 * @param value The float data value. 10249 * 10250 * @return Returns the same Intent object, for chaining multiple calls 10251 * into a single statement. 10252 * 10253 * @see #putExtras 10254 * @see #removeExtra 10255 * @see #getFloatExtra(String, float) 10256 */ putExtra(String name, float value)10257 public @NonNull Intent putExtra(String name, float value) { 10258 if (mExtras == null) { 10259 mExtras = new Bundle(); 10260 } 10261 mExtras.putFloat(name, value); 10262 return this; 10263 } 10264 10265 /** 10266 * Add extended data to the intent. The name must include a package 10267 * prefix, for example the app com.android.contacts would use names 10268 * like "com.android.contacts.ShowAll". 10269 * 10270 * @param name The name of the extra data, with package prefix. 10271 * @param value The double data value. 10272 * 10273 * @return Returns the same Intent object, for chaining multiple calls 10274 * into a single statement. 10275 * 10276 * @see #putExtras 10277 * @see #removeExtra 10278 * @see #getDoubleExtra(String, double) 10279 */ putExtra(String name, double value)10280 public @NonNull Intent putExtra(String name, double value) { 10281 if (mExtras == null) { 10282 mExtras = new Bundle(); 10283 } 10284 mExtras.putDouble(name, value); 10285 return this; 10286 } 10287 10288 /** 10289 * Add extended data to the intent. The name must include a package 10290 * prefix, for example the app com.android.contacts would use names 10291 * like "com.android.contacts.ShowAll". 10292 * 10293 * @param name The name of the extra data, with package prefix. 10294 * @param value The String data value. 10295 * 10296 * @return Returns the same Intent object, for chaining multiple calls 10297 * into a single statement. 10298 * 10299 * @see #putExtras 10300 * @see #removeExtra 10301 * @see #getStringExtra(String) 10302 */ putExtra(String name, @Nullable String value)10303 public @NonNull Intent putExtra(String name, @Nullable String value) { 10304 if (mExtras == null) { 10305 mExtras = new Bundle(); 10306 } 10307 mExtras.putString(name, value); 10308 return this; 10309 } 10310 10311 /** 10312 * Add extended data to the intent. The name must include a package 10313 * prefix, for example the app com.android.contacts would use names 10314 * like "com.android.contacts.ShowAll". 10315 * 10316 * @param name The name of the extra data, with package prefix. 10317 * @param value The CharSequence data value. 10318 * 10319 * @return Returns the same Intent object, for chaining multiple calls 10320 * into a single statement. 10321 * 10322 * @see #putExtras 10323 * @see #removeExtra 10324 * @see #getCharSequenceExtra(String) 10325 */ putExtra(String name, @Nullable CharSequence value)10326 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) { 10327 if (mExtras == null) { 10328 mExtras = new Bundle(); 10329 } 10330 mExtras.putCharSequence(name, value); 10331 return this; 10332 } 10333 10334 /** 10335 * Add extended data to the intent. The name must include a package 10336 * prefix, for example the app com.android.contacts would use names 10337 * like "com.android.contacts.ShowAll". 10338 * 10339 * @param name The name of the extra data, with package prefix. 10340 * @param value The Parcelable data value. 10341 * 10342 * @return Returns the same Intent object, for chaining multiple calls 10343 * into a single statement. 10344 * 10345 * @see #putExtras 10346 * @see #removeExtra 10347 * @see #getParcelableExtra(String) 10348 */ putExtra(String name, @Nullable Parcelable value)10349 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) { 10350 if (mExtras == null) { 10351 mExtras = new Bundle(); 10352 } 10353 mExtras.putParcelable(name, value); 10354 return this; 10355 } 10356 10357 /** 10358 * Add extended data to the intent. The name must include a package 10359 * prefix, for example the app com.android.contacts would use names 10360 * like "com.android.contacts.ShowAll". 10361 * 10362 * @param name The name of the extra data, with package prefix. 10363 * @param value The Parcelable[] data value. 10364 * 10365 * @return Returns the same Intent object, for chaining multiple calls 10366 * into a single statement. 10367 * 10368 * @see #putExtras 10369 * @see #removeExtra 10370 * @see #getParcelableArrayExtra(String) 10371 */ putExtra(String name, @Nullable Parcelable[] value)10372 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) { 10373 if (mExtras == null) { 10374 mExtras = new Bundle(); 10375 } 10376 mExtras.putParcelableArray(name, value); 10377 return this; 10378 } 10379 10380 /** 10381 * Add extended data to the intent. The name must include a package 10382 * prefix, for example the app com.android.contacts would use names 10383 * like "com.android.contacts.ShowAll". 10384 * 10385 * @param name The name of the extra data, with package prefix. 10386 * @param value The ArrayList<Parcelable> data value. 10387 * 10388 * @return Returns the same Intent object, for chaining multiple calls 10389 * into a single statement. 10390 * 10391 * @see #putExtras 10392 * @see #removeExtra 10393 * @see #getParcelableArrayListExtra(String) 10394 */ putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)10395 public @NonNull Intent putParcelableArrayListExtra(String name, 10396 @Nullable ArrayList<? extends Parcelable> value) { 10397 if (mExtras == null) { 10398 mExtras = new Bundle(); 10399 } 10400 mExtras.putParcelableArrayList(name, value); 10401 return this; 10402 } 10403 10404 /** 10405 * Add extended data to the intent. The name must include a package 10406 * prefix, for example the app com.android.contacts would use names 10407 * like "com.android.contacts.ShowAll". 10408 * 10409 * @param name The name of the extra data, with package prefix. 10410 * @param value The ArrayList<Integer> data value. 10411 * 10412 * @return Returns the same Intent object, for chaining multiple calls 10413 * into a single statement. 10414 * 10415 * @see #putExtras 10416 * @see #removeExtra 10417 * @see #getIntegerArrayListExtra(String) 10418 */ putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)10419 public @NonNull Intent putIntegerArrayListExtra(String name, 10420 @Nullable ArrayList<Integer> value) { 10421 if (mExtras == null) { 10422 mExtras = new Bundle(); 10423 } 10424 mExtras.putIntegerArrayList(name, value); 10425 return this; 10426 } 10427 10428 /** 10429 * Add extended data to the intent. The name must include a package 10430 * prefix, for example the app com.android.contacts would use names 10431 * like "com.android.contacts.ShowAll". 10432 * 10433 * @param name The name of the extra data, with package prefix. 10434 * @param value The ArrayList<String> data value. 10435 * 10436 * @return Returns the same Intent object, for chaining multiple calls 10437 * into a single statement. 10438 * 10439 * @see #putExtras 10440 * @see #removeExtra 10441 * @see #getStringArrayListExtra(String) 10442 */ putStringArrayListExtra(String name, @Nullable ArrayList<String> value)10443 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) { 10444 if (mExtras == null) { 10445 mExtras = new Bundle(); 10446 } 10447 mExtras.putStringArrayList(name, value); 10448 return this; 10449 } 10450 10451 /** 10452 * Add extended data to the intent. The name must include a package 10453 * prefix, for example the app com.android.contacts would use names 10454 * like "com.android.contacts.ShowAll". 10455 * 10456 * @param name The name of the extra data, with package prefix. 10457 * @param value The ArrayList<CharSequence> data value. 10458 * 10459 * @return Returns the same Intent object, for chaining multiple calls 10460 * into a single statement. 10461 * 10462 * @see #putExtras 10463 * @see #removeExtra 10464 * @see #getCharSequenceArrayListExtra(String) 10465 */ putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)10466 public @NonNull Intent putCharSequenceArrayListExtra(String name, 10467 @Nullable ArrayList<CharSequence> value) { 10468 if (mExtras == null) { 10469 mExtras = new Bundle(); 10470 } 10471 mExtras.putCharSequenceArrayList(name, value); 10472 return this; 10473 } 10474 10475 /** 10476 * Add extended data to the intent. The name must include a package 10477 * prefix, for example the app com.android.contacts would use names 10478 * like "com.android.contacts.ShowAll". 10479 * 10480 * @param name The name of the extra data, with package prefix. 10481 * @param value The Serializable data value. 10482 * 10483 * @return Returns the same Intent object, for chaining multiple calls 10484 * into a single statement. 10485 * 10486 * @see #putExtras 10487 * @see #removeExtra 10488 * @see #getSerializableExtra(String) 10489 */ putExtra(String name, @Nullable Serializable value)10490 public @NonNull Intent putExtra(String name, @Nullable Serializable value) { 10491 if (mExtras == null) { 10492 mExtras = new Bundle(); 10493 } 10494 mExtras.putSerializable(name, value); 10495 return this; 10496 } 10497 10498 /** 10499 * Add extended data to the intent. The name must include a package 10500 * prefix, for example the app com.android.contacts would use names 10501 * like "com.android.contacts.ShowAll". 10502 * 10503 * @param name The name of the extra data, with package prefix. 10504 * @param value The boolean array data value. 10505 * 10506 * @return Returns the same Intent object, for chaining multiple calls 10507 * into a single statement. 10508 * 10509 * @see #putExtras 10510 * @see #removeExtra 10511 * @see #getBooleanArrayExtra(String) 10512 */ putExtra(String name, @Nullable boolean[] value)10513 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) { 10514 if (mExtras == null) { 10515 mExtras = new Bundle(); 10516 } 10517 mExtras.putBooleanArray(name, value); 10518 return this; 10519 } 10520 10521 /** 10522 * Add extended data to the intent. The name must include a package 10523 * prefix, for example the app com.android.contacts would use names 10524 * like "com.android.contacts.ShowAll". 10525 * 10526 * @param name The name of the extra data, with package prefix. 10527 * @param value The byte array data value. 10528 * 10529 * @return Returns the same Intent object, for chaining multiple calls 10530 * into a single statement. 10531 * 10532 * @see #putExtras 10533 * @see #removeExtra 10534 * @see #getByteArrayExtra(String) 10535 */ putExtra(String name, @Nullable byte[] value)10536 public @NonNull Intent putExtra(String name, @Nullable byte[] value) { 10537 if (mExtras == null) { 10538 mExtras = new Bundle(); 10539 } 10540 mExtras.putByteArray(name, value); 10541 return this; 10542 } 10543 10544 /** 10545 * Add extended data to the intent. The name must include a package 10546 * prefix, for example the app com.android.contacts would use names 10547 * like "com.android.contacts.ShowAll". 10548 * 10549 * @param name The name of the extra data, with package prefix. 10550 * @param value The short array data value. 10551 * 10552 * @return Returns the same Intent object, for chaining multiple calls 10553 * into a single statement. 10554 * 10555 * @see #putExtras 10556 * @see #removeExtra 10557 * @see #getShortArrayExtra(String) 10558 */ putExtra(String name, @Nullable short[] value)10559 public @NonNull Intent putExtra(String name, @Nullable short[] value) { 10560 if (mExtras == null) { 10561 mExtras = new Bundle(); 10562 } 10563 mExtras.putShortArray(name, value); 10564 return this; 10565 } 10566 10567 /** 10568 * Add extended data to the intent. The name must include a package 10569 * prefix, for example the app com.android.contacts would use names 10570 * like "com.android.contacts.ShowAll". 10571 * 10572 * @param name The name of the extra data, with package prefix. 10573 * @param value The char array data value. 10574 * 10575 * @return Returns the same Intent object, for chaining multiple calls 10576 * into a single statement. 10577 * 10578 * @see #putExtras 10579 * @see #removeExtra 10580 * @see #getCharArrayExtra(String) 10581 */ putExtra(String name, @Nullable char[] value)10582 public @NonNull Intent putExtra(String name, @Nullable char[] value) { 10583 if (mExtras == null) { 10584 mExtras = new Bundle(); 10585 } 10586 mExtras.putCharArray(name, value); 10587 return this; 10588 } 10589 10590 /** 10591 * Add extended data to the intent. The name must include a package 10592 * prefix, for example the app com.android.contacts would use names 10593 * like "com.android.contacts.ShowAll". 10594 * 10595 * @param name The name of the extra data, with package prefix. 10596 * @param value The int array data value. 10597 * 10598 * @return Returns the same Intent object, for chaining multiple calls 10599 * into a single statement. 10600 * 10601 * @see #putExtras 10602 * @see #removeExtra 10603 * @see #getIntArrayExtra(String) 10604 */ putExtra(String name, @Nullable int[] value)10605 public @NonNull Intent putExtra(String name, @Nullable int[] value) { 10606 if (mExtras == null) { 10607 mExtras = new Bundle(); 10608 } 10609 mExtras.putIntArray(name, value); 10610 return this; 10611 } 10612 10613 /** 10614 * Add extended data to the intent. The name must include a package 10615 * prefix, for example the app com.android.contacts would use names 10616 * like "com.android.contacts.ShowAll". 10617 * 10618 * @param name The name of the extra data, with package prefix. 10619 * @param value The byte array data value. 10620 * 10621 * @return Returns the same Intent object, for chaining multiple calls 10622 * into a single statement. 10623 * 10624 * @see #putExtras 10625 * @see #removeExtra 10626 * @see #getLongArrayExtra(String) 10627 */ putExtra(String name, @Nullable long[] value)10628 public @NonNull Intent putExtra(String name, @Nullable long[] value) { 10629 if (mExtras == null) { 10630 mExtras = new Bundle(); 10631 } 10632 mExtras.putLongArray(name, value); 10633 return this; 10634 } 10635 10636 /** 10637 * Add extended data to the intent. The name must include a package 10638 * prefix, for example the app com.android.contacts would use names 10639 * like "com.android.contacts.ShowAll". 10640 * 10641 * @param name The name of the extra data, with package prefix. 10642 * @param value The float array data value. 10643 * 10644 * @return Returns the same Intent object, for chaining multiple calls 10645 * into a single statement. 10646 * 10647 * @see #putExtras 10648 * @see #removeExtra 10649 * @see #getFloatArrayExtra(String) 10650 */ putExtra(String name, @Nullable float[] value)10651 public @NonNull Intent putExtra(String name, @Nullable float[] value) { 10652 if (mExtras == null) { 10653 mExtras = new Bundle(); 10654 } 10655 mExtras.putFloatArray(name, value); 10656 return this; 10657 } 10658 10659 /** 10660 * Add extended data to the intent. The name must include a package 10661 * prefix, for example the app com.android.contacts would use names 10662 * like "com.android.contacts.ShowAll". 10663 * 10664 * @param name The name of the extra data, with package prefix. 10665 * @param value The double array data value. 10666 * 10667 * @return Returns the same Intent object, for chaining multiple calls 10668 * into a single statement. 10669 * 10670 * @see #putExtras 10671 * @see #removeExtra 10672 * @see #getDoubleArrayExtra(String) 10673 */ putExtra(String name, @Nullable double[] value)10674 public @NonNull Intent putExtra(String name, @Nullable double[] value) { 10675 if (mExtras == null) { 10676 mExtras = new Bundle(); 10677 } 10678 mExtras.putDoubleArray(name, value); 10679 return this; 10680 } 10681 10682 /** 10683 * Add extended data to the intent. The name must include a package 10684 * prefix, for example the app com.android.contacts would use names 10685 * like "com.android.contacts.ShowAll". 10686 * 10687 * @param name The name of the extra data, with package prefix. 10688 * @param value The String array data value. 10689 * 10690 * @return Returns the same Intent object, for chaining multiple calls 10691 * into a single statement. 10692 * 10693 * @see #putExtras 10694 * @see #removeExtra 10695 * @see #getStringArrayExtra(String) 10696 */ putExtra(String name, @Nullable String[] value)10697 public @NonNull Intent putExtra(String name, @Nullable String[] value) { 10698 if (mExtras == null) { 10699 mExtras = new Bundle(); 10700 } 10701 mExtras.putStringArray(name, value); 10702 return this; 10703 } 10704 10705 /** 10706 * Add extended data to the intent. The name must include a package 10707 * prefix, for example the app com.android.contacts would use names 10708 * like "com.android.contacts.ShowAll". 10709 * 10710 * @param name The name of the extra data, with package prefix. 10711 * @param value The CharSequence array data value. 10712 * 10713 * @return Returns the same Intent object, for chaining multiple calls 10714 * into a single statement. 10715 * 10716 * @see #putExtras 10717 * @see #removeExtra 10718 * @see #getCharSequenceArrayExtra(String) 10719 */ putExtra(String name, @Nullable CharSequence[] value)10720 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) { 10721 if (mExtras == null) { 10722 mExtras = new Bundle(); 10723 } 10724 mExtras.putCharSequenceArray(name, value); 10725 return this; 10726 } 10727 10728 /** 10729 * Add extended data to the intent. The name must include a package 10730 * prefix, for example the app com.android.contacts would use names 10731 * like "com.android.contacts.ShowAll". 10732 * 10733 * @param name The name of the extra data, with package prefix. 10734 * @param value The Bundle data value. 10735 * 10736 * @return Returns the same Intent object, for chaining multiple calls 10737 * into a single statement. 10738 * 10739 * @see #putExtras 10740 * @see #removeExtra 10741 * @see #getBundleExtra(String) 10742 */ putExtra(String name, @Nullable Bundle value)10743 public @NonNull Intent putExtra(String name, @Nullable Bundle value) { 10744 if (mExtras == null) { 10745 mExtras = new Bundle(); 10746 } 10747 mExtras.putBundle(name, value); 10748 return this; 10749 } 10750 10751 /** 10752 * Add extended data to the intent. The name must include a package 10753 * prefix, for example the app com.android.contacts would use names 10754 * like "com.android.contacts.ShowAll". 10755 * 10756 * @param name The name of the extra data, with package prefix. 10757 * @param value The IBinder data value. 10758 * 10759 * @return Returns the same Intent object, for chaining multiple calls 10760 * into a single statement. 10761 * 10762 * @see #putExtras 10763 * @see #removeExtra 10764 * @see #getIBinderExtra(String) 10765 * 10766 * @deprecated 10767 * @hide 10768 */ 10769 @Deprecated 10770 @UnsupportedAppUsage putExtra(String name, IBinder value)10771 public @NonNull Intent putExtra(String name, IBinder value) { 10772 if (mExtras == null) { 10773 mExtras = new Bundle(); 10774 } 10775 mExtras.putIBinder(name, value); 10776 return this; 10777 } 10778 10779 /** 10780 * Copy all extras in 'src' in to this intent. 10781 * 10782 * @param src Contains the extras to copy. 10783 * 10784 * @see #putExtra 10785 */ putExtras(@onNull Intent src)10786 public @NonNull Intent putExtras(@NonNull Intent src) { 10787 if (src.mExtras != null) { 10788 if (mExtras == null) { 10789 mExtras = new Bundle(src.mExtras); 10790 } else { 10791 mExtras.putAll(src.mExtras); 10792 } 10793 } 10794 // If the provided Intent was unparceled and this is not an Intent delivered to a protected 10795 // component then mark the extras as unfiltered. An Intent delivered to a protected 10796 // component had to come from a trusted component, and if unfiltered data was copied to the 10797 // delivered Intent then it would have been reported when that Intent left the sending 10798 // process. 10799 if ((src.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 10800 && (src.mLocalFlags & ( 10801 LOCAL_FLAG_FROM_PROTECTED_COMPONENT 10802 | LOCAL_FLAG_FROM_SYSTEM)) == 0) { 10803 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 10804 } 10805 return this; 10806 } 10807 10808 /** 10809 * Add a set of extended data to the intent. The keys must include a package 10810 * prefix, for example the app com.android.contacts would use names 10811 * like "com.android.contacts.ShowAll". 10812 * 10813 * @param extras The Bundle of extras to add to this intent. 10814 * 10815 * @see #putExtra 10816 * @see #removeExtra 10817 */ putExtras(@onNull Bundle extras)10818 public @NonNull Intent putExtras(@NonNull Bundle extras) { 10819 // If the provided Bundle has not yet been unparceled then treat this as unfiltered extras. 10820 if (extras.isParcelled()) { 10821 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 10822 } 10823 if (mExtras == null) { 10824 mExtras = new Bundle(); 10825 } 10826 mExtras.putAll(extras); 10827 return this; 10828 } 10829 10830 /** 10831 * Completely replace the extras in the Intent with the extras in the 10832 * given Intent. 10833 * 10834 * @param src The exact extras contained in this Intent are copied 10835 * into the target intent, replacing any that were previously there. 10836 */ replaceExtras(@onNull Intent src)10837 public @NonNull Intent replaceExtras(@NonNull Intent src) { 10838 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; 10839 return this; 10840 } 10841 10842 /** 10843 * Completely replace the extras in the Intent with the given Bundle of 10844 * extras. 10845 * 10846 * @param extras The new set of extras in the Intent, or null to erase 10847 * all extras. 10848 */ replaceExtras(@ullable Bundle extras)10849 public @NonNull Intent replaceExtras(@Nullable Bundle extras) { 10850 mExtras = extras != null ? new Bundle(extras) : null; 10851 return this; 10852 } 10853 10854 /** 10855 * Remove extended data from the intent. 10856 * 10857 * @see #putExtra 10858 */ removeExtra(String name)10859 public void removeExtra(String name) { 10860 if (mExtras != null) { 10861 mExtras.remove(name); 10862 if (mExtras.size() == 0) { 10863 mExtras = null; 10864 } 10865 } 10866 } 10867 10868 /** 10869 * Set special flags controlling how this intent is handled. Most values 10870 * here depend on the type of component being executed by the Intent, 10871 * specifically the FLAG_ACTIVITY_* flags are all for use with 10872 * {@link Context#startActivity Context.startActivity()} and the 10873 * FLAG_RECEIVER_* flags are all for use with 10874 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. 10875 * 10876 * <p>See the 10877 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 10878 * Stack</a> documentation for important information on how some of these options impact 10879 * the behavior of your application. 10880 * 10881 * @param flags The desired flags. 10882 * @return Returns the same Intent object, for chaining multiple calls 10883 * into a single statement. 10884 * @see #getFlags 10885 * @see #addFlags 10886 * @see #removeFlags 10887 */ setFlags(@lags int flags)10888 public @NonNull Intent setFlags(@Flags int flags) { 10889 mFlags = flags; 10890 return this; 10891 } 10892 10893 /** 10894 * Add additional flags to the intent (or with existing flags value). 10895 * 10896 * @param flags The new flags to set. 10897 * @return Returns the same Intent object, for chaining multiple calls into 10898 * a single statement. 10899 * @see #setFlags 10900 * @see #getFlags 10901 * @see #removeFlags 10902 */ addFlags(@lags int flags)10903 public @NonNull Intent addFlags(@Flags int flags) { 10904 mFlags |= flags; 10905 return this; 10906 } 10907 10908 /** 10909 * Remove these flags from the intent. 10910 * 10911 * @param flags The flags to remove. 10912 * @see #setFlags 10913 * @see #getFlags 10914 * @see #addFlags 10915 */ removeFlags(@lags int flags)10916 public void removeFlags(@Flags int flags) { 10917 mFlags &= ~flags; 10918 } 10919 10920 /** 10921 * (Usually optional) Set an explicit application package name that limits 10922 * the components this Intent will resolve to. If left to the default 10923 * value of null, all components in all applications will considered. 10924 * If non-null, the Intent can only match the components in the given 10925 * application package. 10926 * 10927 * @param packageName The name of the application package to handle the 10928 * intent, or null to allow any application package. 10929 * 10930 * @return Returns the same Intent object, for chaining multiple calls 10931 * into a single statement. 10932 * 10933 * @see #getPackage 10934 * @see #resolveActivity 10935 */ setPackage(@ullable String packageName)10936 public @NonNull Intent setPackage(@Nullable String packageName) { 10937 if (packageName != null && mSelector != null) { 10938 throw new IllegalArgumentException( 10939 "Can't set package name when selector is already set"); 10940 } 10941 mPackage = packageName; 10942 return this; 10943 } 10944 10945 /** 10946 * (Usually optional) Explicitly set the component to handle the intent. 10947 * If left with the default value of null, the system will determine the 10948 * appropriate class to use based on the other fields (action, data, 10949 * type, categories) in the Intent. If this class is defined, the 10950 * specified class will always be used regardless of the other fields. You 10951 * should only set this value when you know you absolutely want a specific 10952 * class to be used; otherwise it is better to let the system find the 10953 * appropriate class so that you will respect the installed applications 10954 * and user preferences. 10955 * 10956 * @param component The name of the application component to handle the 10957 * intent, or null to let the system find one for you. 10958 * 10959 * @return Returns the same Intent object, for chaining multiple calls 10960 * into a single statement. 10961 * 10962 * @see #setClass 10963 * @see #setClassName(Context, String) 10964 * @see #setClassName(String, String) 10965 * @see #getComponent 10966 * @see #resolveActivity 10967 */ setComponent(@ullable ComponentName component)10968 public @NonNull Intent setComponent(@Nullable ComponentName component) { 10969 mComponent = component; 10970 return this; 10971 } 10972 10973 /** 10974 * Convenience for calling {@link #setComponent} with an 10975 * explicit class name. 10976 * 10977 * @param packageContext A Context of the application package implementing 10978 * this class. 10979 * @param className The name of a class inside of the application package 10980 * that will be used as the component for this Intent. 10981 * 10982 * @return Returns the same Intent object, for chaining multiple calls 10983 * into a single statement. 10984 * 10985 * @see #setComponent 10986 * @see #setClass 10987 */ setClassName(@onNull Context packageContext, @NonNull String className)10988 public @NonNull Intent setClassName(@NonNull Context packageContext, 10989 @NonNull String className) { 10990 mComponent = new ComponentName(packageContext, className); 10991 return this; 10992 } 10993 10994 /** 10995 * Convenience for calling {@link #setComponent} with an 10996 * explicit application package name and class name. 10997 * 10998 * @param packageName The name of the package implementing the desired 10999 * component. 11000 * @param className The name of a class inside of the application package 11001 * that will be used as the component for this Intent. 11002 * 11003 * @return Returns the same Intent object, for chaining multiple calls 11004 * into a single statement. 11005 * 11006 * @see #setComponent 11007 * @see #setClass 11008 */ setClassName(@onNull String packageName, @NonNull String className)11009 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) { 11010 mComponent = new ComponentName(packageName, className); 11011 return this; 11012 } 11013 11014 /** 11015 * Convenience for calling {@link #setComponent(ComponentName)} with the 11016 * name returned by a {@link Class} object. 11017 * 11018 * @param packageContext A Context of the application package implementing 11019 * this class. 11020 * @param cls The class name to set, equivalent to 11021 * <code>setClassName(context, cls.getName())</code>. 11022 * 11023 * @return Returns the same Intent object, for chaining multiple calls 11024 * into a single statement. 11025 * 11026 * @see #setComponent 11027 */ setClass(@onNull Context packageContext, @NonNull Class<?> cls)11028 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) { 11029 mComponent = new ComponentName(packageContext, cls); 11030 return this; 11031 } 11032 11033 /** 11034 * Set the bounds of the sender of this intent, in screen coordinates. This can be 11035 * used as a hint to the receiver for animations and the like. Null means that there 11036 * is no source bounds. 11037 */ setSourceBounds(@ullable Rect r)11038 public void setSourceBounds(@Nullable Rect r) { 11039 if (r != null) { 11040 mSourceBounds = new Rect(r); 11041 } else { 11042 mSourceBounds = null; 11043 } 11044 } 11045 11046 /** @hide */ 11047 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = { 11048 FILL_IN_ACTION, 11049 FILL_IN_DATA, 11050 FILL_IN_CATEGORIES, 11051 FILL_IN_COMPONENT, 11052 FILL_IN_PACKAGE, 11053 FILL_IN_SOURCE_BOUNDS, 11054 FILL_IN_SELECTOR, 11055 FILL_IN_CLIP_DATA 11056 }) 11057 @Retention(RetentionPolicy.SOURCE) 11058 public @interface FillInFlags {} 11059 11060 /** 11061 * Use with {@link #fillIn} to allow the current action value to be 11062 * overwritten, even if it is already set. 11063 */ 11064 public static final int FILL_IN_ACTION = 1<<0; 11065 11066 /** 11067 * Use with {@link #fillIn} to allow the current data or type value 11068 * overwritten, even if it is already set. 11069 */ 11070 public static final int FILL_IN_DATA = 1<<1; 11071 11072 /** 11073 * Use with {@link #fillIn} to allow the current categories to be 11074 * overwritten, even if they are already set. 11075 */ 11076 public static final int FILL_IN_CATEGORIES = 1<<2; 11077 11078 /** 11079 * Use with {@link #fillIn} to allow the current component value to be 11080 * overwritten, even if it is already set. 11081 */ 11082 public static final int FILL_IN_COMPONENT = 1<<3; 11083 11084 /** 11085 * Use with {@link #fillIn} to allow the current package value to be 11086 * overwritten, even if it is already set. 11087 */ 11088 public static final int FILL_IN_PACKAGE = 1<<4; 11089 11090 /** 11091 * Use with {@link #fillIn} to allow the current bounds rectangle to be 11092 * overwritten, even if it is already set. 11093 */ 11094 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; 11095 11096 /** 11097 * Use with {@link #fillIn} to allow the current selector to be 11098 * overwritten, even if it is already set. 11099 */ 11100 public static final int FILL_IN_SELECTOR = 1<<6; 11101 11102 /** 11103 * Use with {@link #fillIn} to allow the current ClipData to be 11104 * overwritten, even if it is already set. 11105 */ 11106 public static final int FILL_IN_CLIP_DATA = 1<<7; 11107 11108 /** 11109 * Use with {@link #fillIn} to allow the current identifier value to be 11110 * overwritten, even if it is already set. 11111 */ 11112 public static final int FILL_IN_IDENTIFIER = 1<<8; 11113 11114 /** 11115 * Copy the contents of <var>other</var> in to this object, but only 11116 * where fields are not defined by this object. For purposes of a field 11117 * being defined, the following pieces of data in the Intent are 11118 * considered to be separate fields: 11119 * 11120 * <ul> 11121 * <li> action, as set by {@link #setAction}. 11122 * <li> data Uri and MIME type, as set by {@link #setData(Uri)}, 11123 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. 11124 * <li> identifier, as set by {@link #setIdentifier}. 11125 * <li> categories, as set by {@link #addCategory}. 11126 * <li> package, as set by {@link #setPackage}. 11127 * <li> component, as set by {@link #setComponent(ComponentName)} or 11128 * related methods. 11129 * <li> source bounds, as set by {@link #setSourceBounds}. 11130 * <li> selector, as set by {@link #setSelector(Intent)}. 11131 * <li> clip data, as set by {@link #setClipData(ClipData)}. 11132 * <li> each top-level name in the associated extras. 11133 * </ul> 11134 * 11135 * <p>In addition, you can use the {@link #FILL_IN_ACTION}, 11136 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES}, 11137 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 11138 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override 11139 * the restriction where the corresponding field will not be replaced if 11140 * it is already set. 11141 * 11142 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} 11143 * is explicitly specified. The selector will only be copied if 11144 * {@link #FILL_IN_SELECTOR} is explicitly specified. 11145 * 11146 * <p>For example, consider Intent A with {data="foo", categories="bar"} 11147 * and Intent B with {action="gotit", data-type="some/thing", 11148 * categories="one","two"}. 11149 * 11150 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now 11151 * containing: {action="gotit", data-type="some/thing", 11152 * categories="bar"}. 11153 * 11154 * @param other Another Intent whose values are to be used to fill in 11155 * the current one. 11156 * @param flags Options to control which fields can be filled in. 11157 * 11158 * @return Returns a bit mask of {@link #FILL_IN_ACTION}, 11159 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 11160 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 11161 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were 11162 * changed. 11163 */ 11164 @FillInFlags fillIn(@onNull Intent other, @FillInFlags int flags)11165 public int fillIn(@NonNull Intent other, @FillInFlags int flags) { 11166 int changes = 0; 11167 boolean mayHaveCopiedUris = false; 11168 if (other.mAction != null 11169 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { 11170 mAction = other.mAction; 11171 changes |= FILL_IN_ACTION; 11172 } 11173 if ((other.mData != null || other.mType != null) 11174 && ((mData == null && mType == null) 11175 || (flags&FILL_IN_DATA) != 0)) { 11176 mData = other.mData; 11177 mType = other.mType; 11178 changes |= FILL_IN_DATA; 11179 mayHaveCopiedUris = true; 11180 } 11181 if (other.mIdentifier != null 11182 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) { 11183 mIdentifier = other.mIdentifier; 11184 changes |= FILL_IN_IDENTIFIER; 11185 } 11186 if (other.mCategories != null 11187 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { 11188 if (other.mCategories != null) { 11189 mCategories = new ArraySet<String>(other.mCategories); 11190 } 11191 changes |= FILL_IN_CATEGORIES; 11192 } 11193 if (other.mPackage != null 11194 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { 11195 // Only do this if mSelector is not set. 11196 if (mSelector == null) { 11197 mPackage = other.mPackage; 11198 changes |= FILL_IN_PACKAGE; 11199 } 11200 } 11201 // Selector is special: it can only be set if explicitly allowed, 11202 // for the same reason as the component name. 11203 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { 11204 if (mPackage == null) { 11205 mSelector = new Intent(other.mSelector); 11206 mPackage = null; 11207 changes |= FILL_IN_SELECTOR; 11208 } 11209 } 11210 if (other.mClipData != null 11211 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { 11212 mClipData = other.mClipData; 11213 changes |= FILL_IN_CLIP_DATA; 11214 mayHaveCopiedUris = true; 11215 } 11216 // Component is special: it can -only- be set if explicitly allowed, 11217 // since otherwise the sender could force the intent somewhere the 11218 // originator didn't intend. 11219 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { 11220 mComponent = other.mComponent; 11221 changes |= FILL_IN_COMPONENT; 11222 } 11223 mFlags |= other.mFlags; 11224 if (other.mSourceBounds != null 11225 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { 11226 mSourceBounds = new Rect(other.mSourceBounds); 11227 changes |= FILL_IN_SOURCE_BOUNDS; 11228 } 11229 if (mExtras == null) { 11230 if (other.mExtras != null) { 11231 mExtras = new Bundle(other.mExtras); 11232 mayHaveCopiedUris = true; 11233 } 11234 } else if (other.mExtras != null) { 11235 try { 11236 Bundle newb = new Bundle(other.mExtras); 11237 newb.putAll(mExtras); 11238 mExtras = newb; 11239 mayHaveCopiedUris = true; 11240 } catch (RuntimeException e) { 11241 // Modifying the extras can cause us to unparcel the contents 11242 // of the bundle, and if we do this in the system process that 11243 // may fail. We really should handle this (i.e., the Bundle 11244 // impl shouldn't be on top of a plain map), but for now just 11245 // ignore it and keep the original contents. :( 11246 Log.w(TAG, "Failure filling in extras", e); 11247 } 11248 } 11249 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT 11250 && other.mContentUserHint != UserHandle.USER_CURRENT) { 11251 mContentUserHint = other.mContentUserHint; 11252 } 11253 return changes; 11254 } 11255 11256 /** 11257 * Merge the extras data in this intent with that of other supplied intent using the 11258 * strategy specified using {@code extrasMerger}. 11259 * 11260 * <p> Note the extras data in this intent is treated as the {@code first} param 11261 * and the extras data in {@code other} intent is treated as the {@code last} param 11262 * when using the passed in {@link BundleMerger} object. 11263 * 11264 * @hide 11265 */ mergeExtras(@onNull Intent other, @NonNull BundleMerger extrasMerger)11266 public void mergeExtras(@NonNull Intent other, @NonNull BundleMerger extrasMerger) { 11267 mExtras = extrasMerger.merge(mExtras, other.mExtras); 11268 } 11269 11270 /** 11271 * Wrapper class holding an Intent and implementing comparisons on it for 11272 * the purpose of filtering. The class implements its 11273 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as 11274 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and 11275 * {@link android.content.Intent#filterHashCode()} filterHashCode()} 11276 * on the wrapped Intent. 11277 */ 11278 public static final class FilterComparison { 11279 private final Intent mIntent; 11280 private final int mHashCode; 11281 FilterComparison(Intent intent)11282 public FilterComparison(Intent intent) { 11283 mIntent = intent; 11284 mHashCode = intent.filterHashCode(); 11285 } 11286 11287 /** 11288 * Return the Intent that this FilterComparison represents. 11289 * @return Returns the Intent held by the FilterComparison. Do 11290 * not modify! 11291 */ getIntent()11292 public Intent getIntent() { 11293 return mIntent; 11294 } 11295 11296 @Override equals(@ullable Object obj)11297 public boolean equals(@Nullable Object obj) { 11298 if (obj instanceof FilterComparison) { 11299 Intent other = ((FilterComparison)obj).mIntent; 11300 return mIntent.filterEquals(other); 11301 } 11302 return false; 11303 } 11304 11305 @Override hashCode()11306 public int hashCode() { 11307 return mHashCode; 11308 } 11309 } 11310 11311 /** 11312 * Determine if two intents are the same for the purposes of intent 11313 * resolution (filtering). That is, if their action, data, type, identity, 11314 * class, and categories are the same. This does <em>not</em> compare 11315 * any extra data included in the intents. Note that technically when actually 11316 * matching against an {@link IntentFilter} the identifier is ignored, while here 11317 * it is directly compared for equality like the other fields. 11318 * 11319 * @param other The other Intent to compare against. 11320 * 11321 * @return Returns true if action, data, type, class, and categories 11322 * are the same. 11323 */ filterEquals(Intent other)11324 public boolean filterEquals(Intent other) { 11325 if (other == null) { 11326 return false; 11327 } 11328 if (!Objects.equals(this.mAction, other.mAction)) return false; 11329 if (!Objects.equals(this.mData, other.mData)) return false; 11330 if (!Objects.equals(this.mType, other.mType)) return false; 11331 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false; 11332 if (!Objects.equals(this.mPackage, other.mPackage)) return false; 11333 if (!Objects.equals(this.mComponent, other.mComponent)) return false; 11334 if (!Objects.equals(this.mCategories, other.mCategories)) return false; 11335 11336 return true; 11337 } 11338 11339 /** 11340 * Generate hash code that matches semantics of filterEquals(). 11341 * 11342 * @return Returns the hash value of the action, data, type, class, and 11343 * categories. 11344 * 11345 * @see #filterEquals 11346 */ filterHashCode()11347 public int filterHashCode() { 11348 int code = 0; 11349 if (mAction != null) { 11350 code += mAction.hashCode(); 11351 } 11352 if (mData != null) { 11353 code += mData.hashCode(); 11354 } 11355 if (mType != null) { 11356 code += mType.hashCode(); 11357 } 11358 if (mIdentifier != null) { 11359 code += mIdentifier.hashCode(); 11360 } 11361 if (mPackage != null) { 11362 code += mPackage.hashCode(); 11363 } 11364 if (mComponent != null) { 11365 code += mComponent.hashCode(); 11366 } 11367 if (mCategories != null) { 11368 code += mCategories.hashCode(); 11369 } 11370 return code; 11371 } 11372 11373 @Override toString()11374 public String toString() { 11375 StringBuilder b = new StringBuilder(128); 11376 toString(b); 11377 return b.toString(); 11378 } 11379 11380 /** @hide */ toString(@onNull StringBuilder b)11381 public void toString(@NonNull StringBuilder b) { 11382 b.append("Intent { "); 11383 toShortString(b, true, true, true, false); 11384 b.append(" }"); 11385 } 11386 11387 /** @hide */ 11388 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) toInsecureString()11389 public String toInsecureString() { 11390 StringBuilder b = new StringBuilder(128); 11391 11392 b.append("Intent { "); 11393 toShortString(b, false, true, true, false); 11394 b.append(" }"); 11395 11396 return b.toString(); 11397 } 11398 11399 /** @hide */ toShortString(boolean secure, boolean comp, boolean extras, boolean clip)11400 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { 11401 StringBuilder b = new StringBuilder(128); 11402 toShortString(b, secure, comp, extras, clip); 11403 return b.toString(); 11404 } 11405 11406 /** @hide */ toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)11407 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, 11408 boolean clip) { 11409 boolean first = true; 11410 if (mAction != null) { 11411 b.append("act=").append(mAction); 11412 first = false; 11413 } 11414 if (mCategories != null) { 11415 if (!first) { 11416 b.append(' '); 11417 } 11418 first = false; 11419 b.append("cat=["); 11420 for (int i=0; i<mCategories.size(); i++) { 11421 if (i > 0) b.append(','); 11422 b.append(mCategories.valueAt(i)); 11423 } 11424 b.append("]"); 11425 } 11426 if (mData != null) { 11427 if (!first) { 11428 b.append(' '); 11429 } 11430 first = false; 11431 b.append("dat="); 11432 if (secure) { 11433 b.append(mData.toSafeString()); 11434 } else { 11435 b.append(mData); 11436 } 11437 } 11438 if (mType != null) { 11439 if (!first) { 11440 b.append(' '); 11441 } 11442 first = false; 11443 b.append("typ=").append(mType); 11444 } 11445 if (mIdentifier != null) { 11446 if (!first) { 11447 b.append(' '); 11448 } 11449 first = false; 11450 b.append("id=").append(mIdentifier); 11451 } 11452 if (mFlags != 0) { 11453 if (!first) { 11454 b.append(' '); 11455 } 11456 first = false; 11457 b.append("flg=0x").append(Integer.toHexString(mFlags)); 11458 } 11459 if (mPackage != null) { 11460 if (!first) { 11461 b.append(' '); 11462 } 11463 first = false; 11464 b.append("pkg=").append(mPackage); 11465 } 11466 if (comp && mComponent != null) { 11467 if (!first) { 11468 b.append(' '); 11469 } 11470 first = false; 11471 b.append("cmp=").append(mComponent.flattenToShortString()); 11472 } 11473 if (mSourceBounds != null) { 11474 if (!first) { 11475 b.append(' '); 11476 } 11477 first = false; 11478 b.append("bnds=").append(mSourceBounds.toShortString()); 11479 } 11480 if (mClipData != null) { 11481 if (!first) { 11482 b.append(' '); 11483 } 11484 b.append("clip={"); 11485 mClipData.toShortString(b, !clip || secure); 11486 first = false; 11487 b.append('}'); 11488 } 11489 if (extras && mExtras != null) { 11490 if (!first) { 11491 b.append(' '); 11492 } 11493 first = false; 11494 b.append("(has extras)"); 11495 } 11496 if (mContentUserHint != UserHandle.USER_CURRENT) { 11497 if (!first) { 11498 b.append(' '); 11499 } 11500 first = false; 11501 b.append("u=").append(mContentUserHint); 11502 } 11503 if (mSelector != null) { 11504 b.append(" sel="); 11505 mSelector.toShortString(b, secure, comp, extras, clip); 11506 b.append("}"); 11507 } 11508 if (mOriginalIntent != null) { 11509 b.append(" org={"); 11510 mOriginalIntent.toShortString(b, secure, comp, extras, clip); 11511 b.append("}"); 11512 } 11513 } 11514 11515 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId)11516 public void dumpDebug(ProtoOutputStream proto, long fieldId) { 11517 // Same input parameters that toString() gives to toShortString(). 11518 dumpDebug(proto, fieldId, true, true, true, false); 11519 } 11520 11521 /** @hide */ dumpDebug(ProtoOutputStream proto)11522 public void dumpDebug(ProtoOutputStream proto) { 11523 // Same input parameters that toString() gives to toShortString(). 11524 dumpDebugWithoutFieldId(proto, true, true, true, false); 11525 } 11526 11527 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)11528 public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, 11529 boolean extras, boolean clip) { 11530 long token = proto.start(fieldId); 11531 dumpDebugWithoutFieldId(proto, secure, comp, extras, clip); 11532 proto.end(token); 11533 } 11534 dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)11535 private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, 11536 boolean extras, boolean clip) { 11537 if (mAction != null) { 11538 proto.write(IntentProto.ACTION, mAction); 11539 } 11540 if (mCategories != null) { 11541 for (String category : mCategories) { 11542 proto.write(IntentProto.CATEGORIES, category); 11543 } 11544 } 11545 if (mData != null) { 11546 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString()); 11547 } 11548 if (mType != null) { 11549 proto.write(IntentProto.TYPE, mType); 11550 } 11551 if (mIdentifier != null) { 11552 proto.write(IntentProto.IDENTIFIER, mIdentifier); 11553 } 11554 if (mFlags != 0) { 11555 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags)); 11556 } 11557 if (mPackage != null) { 11558 proto.write(IntentProto.PACKAGE, mPackage); 11559 } 11560 if (comp && mComponent != null) { 11561 mComponent.dumpDebug(proto, IntentProto.COMPONENT); 11562 } 11563 if (mSourceBounds != null) { 11564 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString()); 11565 } 11566 if (mClipData != null) { 11567 StringBuilder b = new StringBuilder(); 11568 mClipData.toShortString(b, !clip || secure); 11569 proto.write(IntentProto.CLIP_DATA, b.toString()); 11570 } 11571 if (extras && mExtras != null) { 11572 proto.write(IntentProto.EXTRAS, mExtras.toShortString()); 11573 } 11574 if (mContentUserHint != 0) { 11575 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint); 11576 } 11577 if (mSelector != null) { 11578 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip)); 11579 } 11580 } 11581 11582 /** 11583 * Call {@link #toUri} with 0 flags. 11584 * @deprecated Use {@link #toUri} instead. 11585 */ 11586 @Deprecated toURI()11587 public String toURI() { 11588 return toUri(0); 11589 } 11590 11591 /** 11592 * Convert this Intent into a String holding a URI representation of it. 11593 * The returned URI string has been properly URI encoded, so it can be 11594 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the 11595 * Intent's data as the base URI, with an additional fragment describing 11596 * the action, categories, type, flags, package, component, and extras. 11597 * 11598 * <p>You can convert the returned string back to an Intent with 11599 * {@link #getIntent}. 11600 * 11601 * @param flags Additional operating flags. 11602 * 11603 * @return Returns a URI encoding URI string describing the entire contents 11604 * of the Intent. 11605 */ toUri(@riFlags int flags)11606 public String toUri(@UriFlags int flags) { 11607 StringBuilder uri = new StringBuilder(128); 11608 if ((flags&URI_ANDROID_APP_SCHEME) != 0) { 11609 if (mPackage == null) { 11610 throw new IllegalArgumentException( 11611 "Intent must include an explicit package name to build an android-app: " 11612 + this); 11613 } 11614 uri.append("android-app://"); 11615 uri.append(mPackage); 11616 String scheme = null; 11617 if (mData != null) { 11618 scheme = mData.getScheme(); 11619 if (scheme != null) { 11620 uri.append('/'); 11621 uri.append(scheme); 11622 String authority = mData.getEncodedAuthority(); 11623 if (authority != null) { 11624 uri.append('/'); 11625 uri.append(authority); 11626 String path = mData.getEncodedPath(); 11627 if (path != null) { 11628 uri.append(path); 11629 } 11630 String queryParams = mData.getEncodedQuery(); 11631 if (queryParams != null) { 11632 uri.append('?'); 11633 uri.append(queryParams); 11634 } 11635 String fragment = mData.getEncodedFragment(); 11636 if (fragment != null) { 11637 uri.append('#'); 11638 uri.append(fragment); 11639 } 11640 } 11641 } 11642 } 11643 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, 11644 mPackage, flags); 11645 return uri.toString(); 11646 } 11647 String scheme = null; 11648 if (mData != null) { 11649 String data = mData.toString(); 11650 if ((flags&URI_INTENT_SCHEME) != 0) { 11651 final int N = data.length(); 11652 for (int i=0; i<N; i++) { 11653 char c = data.charAt(i); 11654 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 11655 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') { 11656 continue; 11657 } 11658 if (c == ':' && i > 0) { 11659 // Valid scheme. 11660 scheme = data.substring(0, i); 11661 uri.append("intent:"); 11662 data = data.substring(i+1); 11663 break; 11664 } 11665 11666 // No scheme. 11667 break; 11668 } 11669 } 11670 uri.append(data); 11671 11672 } else if ((flags&URI_INTENT_SCHEME) != 0) { 11673 uri.append("intent:"); 11674 } 11675 11676 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); 11677 11678 return uri.toString(); 11679 } 11680 toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)11681 private void toUriFragment(StringBuilder uri, String scheme, String defAction, 11682 String defPackage, int flags) { 11683 StringBuilder frag = new StringBuilder(128); 11684 11685 toUriInner(frag, scheme, defAction, defPackage, flags); 11686 if (mSelector != null) { 11687 frag.append("SEL;"); 11688 // Note that for now we are not going to try to handle the 11689 // data part; not clear how to represent this as a URI, and 11690 // not much utility in it. 11691 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, 11692 null, null, flags); 11693 } 11694 11695 if (frag.length() > 0) { 11696 uri.append("#Intent;"); 11697 uri.append(frag); 11698 uri.append("end"); 11699 } 11700 } 11701 toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)11702 private void toUriInner(StringBuilder uri, String scheme, String defAction, 11703 String defPackage, int flags) { 11704 if (scheme != null) { 11705 uri.append("scheme=").append(Uri.encode(scheme)).append(';'); 11706 } 11707 if (mAction != null && !mAction.equals(defAction)) { 11708 uri.append("action=").append(Uri.encode(mAction)).append(';'); 11709 } 11710 if (mCategories != null) { 11711 for (int i=0; i<mCategories.size(); i++) { 11712 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';'); 11713 } 11714 } 11715 if (mType != null) { 11716 uri.append("type=").append(Uri.encode(mType, "/")).append(';'); 11717 } 11718 if (mIdentifier != null) { 11719 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';'); 11720 } 11721 if (mFlags != 0) { 11722 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); 11723 } 11724 if (mPackage != null && !mPackage.equals(defPackage)) { 11725 uri.append("package=").append(Uri.encode(mPackage)).append(';'); 11726 } 11727 if (mComponent != null) { 11728 uri.append("component=").append(Uri.encode( 11729 mComponent.flattenToShortString(), "/")).append(';'); 11730 } 11731 if (mSourceBounds != null) { 11732 uri.append("sourceBounds=") 11733 .append(Uri.encode(mSourceBounds.flattenToString())) 11734 .append(';'); 11735 } 11736 if (mExtras != null) { 11737 for (String key : mExtras.keySet()) { 11738 final Object value = mExtras.get(key); 11739 char entryType = 11740 value instanceof String ? 'S' : 11741 value instanceof Boolean ? 'B' : 11742 value instanceof Byte ? 'b' : 11743 value instanceof Character ? 'c' : 11744 value instanceof Double ? 'd' : 11745 value instanceof Float ? 'f' : 11746 value instanceof Integer ? 'i' : 11747 value instanceof Long ? 'l' : 11748 value instanceof Short ? 's' : 11749 '\0'; 11750 11751 if (entryType != '\0') { 11752 uri.append(entryType); 11753 uri.append('.'); 11754 uri.append(Uri.encode(key)); 11755 uri.append('='); 11756 uri.append(Uri.encode(value.toString())); 11757 uri.append(';'); 11758 } 11759 } 11760 } 11761 } 11762 describeContents()11763 public int describeContents() { 11764 return (mExtras != null) ? mExtras.describeContents() : 0; 11765 } 11766 writeToParcel(Parcel out, int flags)11767 public void writeToParcel(Parcel out, int flags) { 11768 out.writeString8(mAction); 11769 Uri.writeToParcel(out, mData); 11770 out.writeString8(mType); 11771 out.writeString8(mIdentifier); 11772 out.writeInt(mFlags); 11773 out.writeString8(mPackage); 11774 ComponentName.writeToParcel(mComponent, out); 11775 11776 if (mSourceBounds != null) { 11777 out.writeInt(1); 11778 mSourceBounds.writeToParcel(out, flags); 11779 } else { 11780 out.writeInt(0); 11781 } 11782 11783 if (mCategories != null) { 11784 final int N = mCategories.size(); 11785 out.writeInt(N); 11786 for (int i=0; i<N; i++) { 11787 out.writeString8(mCategories.valueAt(i)); 11788 } 11789 } else { 11790 out.writeInt(0); 11791 } 11792 11793 if (mSelector != null) { 11794 out.writeInt(1); 11795 mSelector.writeToParcel(out, flags); 11796 } else { 11797 out.writeInt(0); 11798 } 11799 11800 if (mClipData != null) { 11801 out.writeInt(1); 11802 mClipData.writeToParcel(out, flags); 11803 } else { 11804 out.writeInt(0); 11805 } 11806 out.writeInt(mContentUserHint); 11807 out.writeBundle(mExtras); 11808 11809 if (mOriginalIntent != null) { 11810 out.writeInt(1); 11811 mOriginalIntent.writeToParcel(out, flags); 11812 } else { 11813 out.writeInt(0); 11814 } 11815 } 11816 11817 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR 11818 = new Parcelable.Creator<Intent>() { 11819 public Intent createFromParcel(Parcel in) { 11820 return new Intent(in); 11821 } 11822 public Intent[] newArray(int size) { 11823 return new Intent[size]; 11824 } 11825 }; 11826 11827 /** @hide */ Intent(Parcel in)11828 protected Intent(Parcel in) { 11829 // Remember that we came from a remote process to help detect security 11830 // issues caused by later unsafe launches 11831 mLocalFlags = LOCAL_FLAG_FROM_PARCEL; 11832 readFromParcel(in); 11833 } 11834 readFromParcel(Parcel in)11835 public void readFromParcel(Parcel in) { 11836 setAction(in.readString8()); 11837 mData = Uri.CREATOR.createFromParcel(in); 11838 mType = in.readString8(); 11839 mIdentifier = in.readString8(); 11840 mFlags = in.readInt(); 11841 mPackage = in.readString8(); 11842 mComponent = ComponentName.readFromParcel(in); 11843 11844 if (in.readInt() != 0) { 11845 mSourceBounds = Rect.CREATOR.createFromParcel(in); 11846 } 11847 11848 int N = in.readInt(); 11849 if (N > 0) { 11850 mCategories = new ArraySet<String>(); 11851 int i; 11852 for (i=0; i<N; i++) { 11853 mCategories.add(in.readString8().intern()); 11854 } 11855 } else { 11856 mCategories = null; 11857 } 11858 11859 if (in.readInt() != 0) { 11860 mSelector = new Intent(in); 11861 } 11862 11863 if (in.readInt() != 0) { 11864 mClipData = new ClipData(in); 11865 } 11866 mContentUserHint = in.readInt(); 11867 mExtras = in.readBundle(); 11868 if (in.readInt() != 0) { 11869 mOriginalIntent = new Intent(in); 11870 } 11871 } 11872 11873 /** 11874 * Parses the "intent" element (and its children) from XML and instantiates 11875 * an Intent object. The given XML parser should be located at the tag 11876 * where parsing should start (often named "intent"), from which the 11877 * basic action, data, type, and package and class name will be 11878 * retrieved. The function will then parse in to any child elements, 11879 * looking for <category android:name="xxx"> tags to add categories and 11880 * <extra android:name="xxx" android:value="yyy"> to attach extra data 11881 * to the intent. 11882 * 11883 * @param resources The Resources to use when inflating resources. 11884 * @param parser The XML parser pointing at an "intent" tag. 11885 * @param attrs The AttributeSet interface for retrieving extended 11886 * attribute data at the current <var>parser</var> location. 11887 * @return An Intent object matching the XML data. 11888 * @throws XmlPullParserException If there was an XML parsing error. 11889 * @throws IOException If there was an I/O error. 11890 */ parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)11891 public static @NonNull Intent parseIntent(@NonNull Resources resources, 11892 @NonNull XmlPullParser parser, AttributeSet attrs) 11893 throws XmlPullParserException, IOException { 11894 Intent intent = new Intent(); 11895 11896 TypedArray sa = resources.obtainAttributes(attrs, 11897 com.android.internal.R.styleable.Intent); 11898 11899 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); 11900 11901 String data = sa.getString(com.android.internal.R.styleable.Intent_data); 11902 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); 11903 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); 11904 11905 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier)); 11906 11907 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); 11908 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); 11909 if (packageName != null && className != null) { 11910 intent.setComponent(new ComponentName(packageName, className)); 11911 } 11912 11913 sa.recycle(); 11914 11915 int outerDepth = parser.getDepth(); 11916 int type; 11917 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 11918 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 11919 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 11920 continue; 11921 } 11922 11923 String nodeName = parser.getName(); 11924 if (nodeName.equals(TAG_CATEGORIES)) { 11925 sa = resources.obtainAttributes(attrs, 11926 com.android.internal.R.styleable.IntentCategory); 11927 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); 11928 sa.recycle(); 11929 11930 if (cat != null) { 11931 intent.addCategory(cat); 11932 } 11933 XmlUtils.skipCurrentTag(parser); 11934 11935 } else if (nodeName.equals(TAG_EXTRA)) { 11936 if (intent.mExtras == null) { 11937 intent.mExtras = new Bundle(); 11938 } 11939 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); 11940 XmlUtils.skipCurrentTag(parser); 11941 11942 } else { 11943 XmlUtils.skipCurrentTag(parser); 11944 } 11945 } 11946 11947 return intent; 11948 } 11949 11950 /** @hide */ saveToXml(XmlSerializer out)11951 public void saveToXml(XmlSerializer out) throws IOException { 11952 if (mAction != null) { 11953 out.attribute(null, ATTR_ACTION, mAction); 11954 } 11955 if (mData != null) { 11956 out.attribute(null, ATTR_DATA, mData.toString()); 11957 } 11958 if (mType != null) { 11959 out.attribute(null, ATTR_TYPE, mType); 11960 } 11961 if (mIdentifier != null) { 11962 out.attribute(null, ATTR_IDENTIFIER, mIdentifier); 11963 } 11964 if (mComponent != null) { 11965 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); 11966 } 11967 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); 11968 11969 if (mCategories != null) { 11970 out.startTag(null, TAG_CATEGORIES); 11971 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { 11972 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); 11973 } 11974 out.endTag(null, TAG_CATEGORIES); 11975 } 11976 } 11977 11978 /** @hide */ restoreFromXml(XmlPullParser in)11979 public static Intent restoreFromXml(XmlPullParser in) throws IOException, 11980 XmlPullParserException { 11981 Intent intent = new Intent(); 11982 final int outerDepth = in.getDepth(); 11983 11984 int attrCount = in.getAttributeCount(); 11985 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 11986 final String attrName = in.getAttributeName(attrNdx); 11987 final String attrValue = in.getAttributeValue(attrNdx); 11988 if (ATTR_ACTION.equals(attrName)) { 11989 intent.setAction(attrValue); 11990 } else if (ATTR_DATA.equals(attrName)) { 11991 intent.setData(Uri.parse(attrValue)); 11992 } else if (ATTR_TYPE.equals(attrName)) { 11993 intent.setType(attrValue); 11994 } else if (ATTR_IDENTIFIER.equals(attrName)) { 11995 intent.setIdentifier(attrValue); 11996 } else if (ATTR_COMPONENT.equals(attrName)) { 11997 intent.setComponent(ComponentName.unflattenFromString(attrValue)); 11998 } else if (ATTR_FLAGS.equals(attrName)) { 11999 intent.setFlags(Integer.parseInt(attrValue, 16)); 12000 } else { 12001 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName); 12002 } 12003 } 12004 12005 int event; 12006 String name; 12007 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && 12008 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { 12009 if (event == XmlPullParser.START_TAG) { 12010 name = in.getName(); 12011 if (TAG_CATEGORIES.equals(name)) { 12012 attrCount = in.getAttributeCount(); 12013 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 12014 intent.addCategory(in.getAttributeValue(attrNdx)); 12015 } 12016 } else { 12017 Log.w(TAG, "restoreFromXml: unknown name=" + name); 12018 XmlUtils.skipCurrentTag(in); 12019 } 12020 } 12021 } 12022 12023 return intent; 12024 } 12025 12026 /** 12027 * Normalize a MIME data type. 12028 * 12029 * <p>A normalized MIME type has white-space trimmed, 12030 * content-type parameters removed, and is lower-case. 12031 * This aligns the type with Android best practices for 12032 * intent filtering. 12033 * 12034 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". 12035 * "text/x-vCard" becomes "text/x-vcard". 12036 * 12037 * <p>All MIME types received from outside Android (such as user input, 12038 * or external sources like Bluetooth, NFC, or the Internet) should 12039 * be normalized before they are used to create an Intent. 12040 * 12041 * @param type MIME data type to normalize 12042 * @return normalized MIME data type, or null if the input was null 12043 * @see #setType 12044 * @see #setTypeAndNormalize 12045 */ normalizeMimeType(@ullable String type)12046 public static @Nullable String normalizeMimeType(@Nullable String type) { 12047 if (type == null) { 12048 return null; 12049 } 12050 12051 type = type.trim().toLowerCase(Locale.ROOT); 12052 12053 final int semicolonIndex = type.indexOf(';'); 12054 if (semicolonIndex != -1) { 12055 type = type.substring(0, semicolonIndex); 12056 } 12057 return type; 12058 } 12059 12060 /** 12061 * Prepare this {@link Intent} to leave an app process. 12062 * 12063 * @hide 12064 */ 12065 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) prepareToLeaveProcess(Context context)12066 public void prepareToLeaveProcess(Context context) { 12067 final boolean leavingPackage; 12068 if (mComponent != null) { 12069 leavingPackage = !Objects.equals(mComponent.getPackageName(), context.getPackageName()); 12070 } else if (mPackage != null) { 12071 leavingPackage = !Objects.equals(mPackage, context.getPackageName()); 12072 } else { 12073 // When no specific component or package has been defined, we have 12074 // to assume that we might be routed through an intent 12075 // disambiguation dialog which might leave our package 12076 leavingPackage = true; 12077 } 12078 prepareToLeaveProcess(leavingPackage); 12079 } 12080 12081 /** 12082 * Prepare this {@link Intent} to leave an app process. 12083 * 12084 * @hide 12085 */ prepareToLeaveProcess(boolean leavingPackage)12086 public void prepareToLeaveProcess(boolean leavingPackage) { 12087 setAllowFds(false); 12088 12089 if (mSelector != null) { 12090 mSelector.prepareToLeaveProcess(leavingPackage); 12091 } 12092 if (mClipData != null) { 12093 mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); 12094 } 12095 if (mOriginalIntent != null) { 12096 mOriginalIntent.prepareToLeaveProcess(leavingPackage); 12097 } 12098 12099 if (mExtras != null && !mExtras.isParcelled()) { 12100 final Object intent = mExtras.get(Intent.EXTRA_INTENT); 12101 if (intent instanceof Intent) { 12102 ((Intent) intent).prepareToLeaveProcess(leavingPackage); 12103 } 12104 } 12105 12106 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() 12107 && leavingPackage) { 12108 switch (mAction) { 12109 case ACTION_MEDIA_REMOVED: 12110 case ACTION_MEDIA_UNMOUNTED: 12111 case ACTION_MEDIA_CHECKING: 12112 case ACTION_MEDIA_NOFS: 12113 case ACTION_MEDIA_MOUNTED: 12114 case ACTION_MEDIA_SHARED: 12115 case ACTION_MEDIA_UNSHARED: 12116 case ACTION_MEDIA_BAD_REMOVAL: 12117 case ACTION_MEDIA_UNMOUNTABLE: 12118 case ACTION_MEDIA_EJECT: 12119 case ACTION_MEDIA_SCANNER_STARTED: 12120 case ACTION_MEDIA_SCANNER_FINISHED: 12121 case ACTION_MEDIA_SCANNER_SCAN_FILE: 12122 case ACTION_PACKAGE_NEEDS_VERIFICATION: 12123 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION: 12124 case ACTION_PACKAGE_VERIFIED: 12125 case ACTION_PACKAGE_ENABLE_ROLLBACK: 12126 // Ignore legacy actions 12127 break; 12128 default: 12129 mData.checkFileUriExposed("Intent.getData()"); 12130 } 12131 } 12132 12133 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() 12134 && leavingPackage) { 12135 switch (mAction) { 12136 case ACTION_PROVIDER_CHANGED: 12137 case QuickContact.ACTION_QUICK_CONTACT: 12138 // Ignore actions that don't need to grant 12139 break; 12140 default: 12141 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); 12142 } 12143 } 12144 12145 // Translate raw filesystem paths out of storage sandbox 12146 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null 12147 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) { 12148 final StorageManager sm = AppGlobals.getInitialApplication() 12149 .getSystemService(StorageManager.class); 12150 final File before = new File(mData.getPath()); 12151 final File after = sm.translateAppToSystem(before, 12152 android.os.Process.myPid(), android.os.Process.myUid()); 12153 if (!Objects.equals(before, after)) { 12154 Log.v(TAG, "Translated " + before + " to " + after); 12155 mData = Uri.fromFile(after); 12156 } 12157 } 12158 12159 // Detect cases where we're about to launch a potentially unsafe intent 12160 if (StrictMode.vmUnsafeIntentLaunchEnabled()) { 12161 if ((mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 12162 && (mLocalFlags 12163 & (LOCAL_FLAG_FROM_PROTECTED_COMPONENT | LOCAL_FLAG_FROM_SYSTEM)) == 0) { 12164 StrictMode.onUnsafeIntentLaunch(this); 12165 } else if ((mLocalFlags & LOCAL_FLAG_UNFILTERED_EXTRAS) != 0) { 12166 StrictMode.onUnsafeIntentLaunch(this); 12167 } else if ((mLocalFlags & LOCAL_FLAG_FROM_URI) != 0 12168 && !(mCategories != null && mCategories.contains(CATEGORY_BROWSABLE) 12169 && mComponent == null)) { 12170 // Since the docs for #URI_ALLOW_UNSAFE recommend setting the category to browsable 12171 // for an implicit Intent parsed from a URI a violation should be reported if these 12172 // conditions are not met. 12173 StrictMode.onUnsafeIntentLaunch(this); 12174 } 12175 } 12176 } 12177 12178 /** 12179 * @hide 12180 */ prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source)12181 public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) { 12182 if (fromProtectedComponent) { 12183 prepareToEnterProcess(LOCAL_FLAG_FROM_PROTECTED_COMPONENT, source); 12184 } else { 12185 prepareToEnterProcess(0, source); 12186 } 12187 } 12188 12189 /** 12190 * @hide 12191 */ prepareToEnterProcess(int localFlags, AttributionSource source)12192 public void prepareToEnterProcess(int localFlags, AttributionSource source) { 12193 // We just entered destination process, so we should be able to read all 12194 // parcelables inside. 12195 setDefusable(true); 12196 12197 if (mSelector != null) { 12198 // We can't recursively claim that this data is from a protected 12199 // component, since it may have been filled in by a malicious app 12200 mSelector.prepareToEnterProcess(0, source); 12201 } 12202 if (mClipData != null) { 12203 mClipData.prepareToEnterProcess(source); 12204 } 12205 if (mOriginalIntent != null) { 12206 // We can't recursively claim that this data is from a protected 12207 // component, since it may have been filled in by a malicious app 12208 mOriginalIntent.prepareToEnterProcess(0, source); 12209 } 12210 12211 if (mContentUserHint != UserHandle.USER_CURRENT) { 12212 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { 12213 fixUris(mContentUserHint); 12214 mContentUserHint = UserHandle.USER_CURRENT; 12215 } 12216 } 12217 12218 mLocalFlags |= localFlags; 12219 12220 // Special attribution fix-up logic for any BluetoothDevice extras 12221 // passed via Bluetooth intents 12222 if (mAction != null && mAction.startsWith("android.bluetooth.") 12223 && hasExtra(BluetoothDevice.EXTRA_DEVICE)) { 12224 final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE, BluetoothDevice.class); 12225 if (device != null) { 12226 device.prepareToEnterProcess(source); 12227 } 12228 } 12229 } 12230 12231 /** @hide */ hasWebURI()12232 public boolean hasWebURI() { 12233 if (getData() == null) { 12234 return false; 12235 } 12236 final String scheme = getScheme(); 12237 if (TextUtils.isEmpty(scheme)) { 12238 return false; 12239 } 12240 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS); 12241 } 12242 12243 /** @hide */ isWebIntent()12244 public boolean isWebIntent() { 12245 return ACTION_VIEW.equals(mAction) 12246 && hasWebURI(); 12247 } 12248 isImageCaptureIntent()12249 private boolean isImageCaptureIntent() { 12250 return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction) 12251 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction) 12252 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction)); 12253 } 12254 12255 /** @hide */ isImplicitImageCaptureIntent()12256 public boolean isImplicitImageCaptureIntent() { 12257 return mPackage == null && mComponent == null && isImageCaptureIntent(); 12258 } 12259 12260 /** 12261 * @hide 12262 */ fixUris(int contentUserHint)12263 public void fixUris(int contentUserHint) { 12264 Uri data = getData(); 12265 if (data != null) { 12266 mData = maybeAddUserId(data, contentUserHint); 12267 } 12268 if (mClipData != null) { 12269 mClipData.fixUris(contentUserHint); 12270 } 12271 String action = getAction(); 12272 if (ACTION_SEND.equals(action)) { 12273 final Uri stream = getParcelableExtra(EXTRA_STREAM, Uri.class); 12274 if (stream != null) { 12275 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); 12276 } 12277 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 12278 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM, Uri.class); 12279 if (streams != null) { 12280 ArrayList<Uri> newStreams = new ArrayList<Uri>(); 12281 for (int i = 0; i < streams.size(); i++) { 12282 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); 12283 } 12284 putParcelableArrayListExtra(EXTRA_STREAM, newStreams); 12285 } 12286 } else if (isImageCaptureIntent()) { 12287 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT, Uri.class); 12288 if (output != null) { 12289 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); 12290 } 12291 } 12292 } 12293 12294 /** 12295 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 12296 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 12297 * intents in {@link #ACTION_CHOOSER}. 12298 * 12299 * @return Whether any contents were migrated. 12300 * @hide 12301 */ migrateExtraStreamToClipData()12302 public boolean migrateExtraStreamToClipData() { 12303 return migrateExtraStreamToClipData(AppGlobals.getInitialApplication()); 12304 } 12305 12306 /** 12307 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 12308 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 12309 * intents in {@link #ACTION_CHOOSER}. 12310 * 12311 * @param context app context 12312 * @return Whether any contents were migrated. 12313 * @hide 12314 */ migrateExtraStreamToClipData(Context context)12315 public boolean migrateExtraStreamToClipData(Context context) { 12316 // Refuse to touch if extras already parcelled 12317 if (mExtras != null && mExtras.isParcelled()) return false; 12318 12319 // Bail when someone already gave us ClipData 12320 if (getClipData() != null) return false; 12321 12322 final String action = getAction(); 12323 if (ACTION_CHOOSER.equals(action)) { 12324 // Inspect contained intents to see if we need to migrate extras. We 12325 // don't promote ClipData to the parent, since ChooserActivity will 12326 // already start the picked item as the caller, and we can't combine 12327 // the flags in a safe way. 12328 12329 boolean migrated = false; 12330 try { 12331 final Intent intent = getParcelableExtra(EXTRA_INTENT, Intent.class); 12332 if (intent != null) { 12333 migrated |= intent.migrateExtraStreamToClipData(context); 12334 } 12335 } catch (ClassCastException e) { 12336 } 12337 try { 12338 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); 12339 if (intents != null) { 12340 for (int i = 0; i < intents.length; i++) { 12341 final Intent intent = (Intent) intents[i]; 12342 if (intent != null) { 12343 migrated |= intent.migrateExtraStreamToClipData(context); 12344 } 12345 } 12346 } 12347 } catch (ClassCastException e) { 12348 } 12349 return migrated; 12350 12351 } else if (ACTION_SEND.equals(action)) { 12352 try { 12353 final Uri stream = getParcelableExtra(EXTRA_STREAM, Uri.class); 12354 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); 12355 final String htmlText = getStringExtra(EXTRA_HTML_TEXT); 12356 if (stream != null || text != null || htmlText != null) { 12357 final ClipData clipData = new ClipData( 12358 null, new String[] { getType() }, 12359 new ClipData.Item(text, htmlText, null, stream)); 12360 setClipData(clipData); 12361 if (stream != null) { 12362 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 12363 } 12364 return true; 12365 } 12366 } catch (ClassCastException e) { 12367 } 12368 12369 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 12370 try { 12371 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM, Uri.class); 12372 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); 12373 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); 12374 int num = -1; 12375 if (streams != null) { 12376 num = streams.size(); 12377 } 12378 if (texts != null) { 12379 if (num >= 0 && num != texts.size()) { 12380 // Wha...! F- you. 12381 return false; 12382 } 12383 num = texts.size(); 12384 } 12385 if (htmlTexts != null) { 12386 if (num >= 0 && num != htmlTexts.size()) { 12387 // Wha...! F- you. 12388 return false; 12389 } 12390 num = htmlTexts.size(); 12391 } 12392 if (num > 0) { 12393 final ClipData clipData = new ClipData( 12394 null, new String[] { getType() }, 12395 makeClipItem(streams, texts, htmlTexts, 0)); 12396 12397 for (int i = 1; i < num; i++) { 12398 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); 12399 } 12400 12401 setClipData(clipData); 12402 if (streams != null) { 12403 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 12404 } 12405 return true; 12406 } 12407 } catch (ClassCastException e) { 12408 } 12409 } else if (isImageCaptureIntent()) { 12410 Uri output; 12411 try { 12412 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT, Uri.class); 12413 } catch (ClassCastException e) { 12414 return false; 12415 } 12416 12417 if (output != null) { 12418 output = maybeConvertFileToContentUri(context, output); 12419 putExtra(MediaStore.EXTRA_OUTPUT, output); 12420 12421 setClipData(ClipData.newRawUri("", output)); 12422 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); 12423 return true; 12424 } 12425 } 12426 12427 return false; 12428 } 12429 maybeConvertFileToContentUri(Context context, Uri uri)12430 private Uri maybeConvertFileToContentUri(Context context, Uri uri) { 12431 if (ContentResolver.SCHEME_FILE.equals(uri.getScheme()) 12432 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) { 12433 File file = new File(uri.getPath()); 12434 try { 12435 if (!file.exists()) file.createNewFile(); 12436 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath())); 12437 if (uri != null) { 12438 return uri; 12439 } 12440 } catch (IOException e) { 12441 Log.e(TAG, "Ignoring failure to create file " + file, e); 12442 } 12443 } 12444 return uri; 12445 } 12446 12447 /** 12448 * Convert the dock state to a human readable format. 12449 * @hide 12450 */ dockStateToString(int dock)12451 public static String dockStateToString(int dock) { 12452 switch (dock) { 12453 case EXTRA_DOCK_STATE_HE_DESK: 12454 return "EXTRA_DOCK_STATE_HE_DESK"; 12455 case EXTRA_DOCK_STATE_LE_DESK: 12456 return "EXTRA_DOCK_STATE_LE_DESK"; 12457 case EXTRA_DOCK_STATE_CAR: 12458 return "EXTRA_DOCK_STATE_CAR"; 12459 case EXTRA_DOCK_STATE_DESK: 12460 return "EXTRA_DOCK_STATE_DESK"; 12461 case EXTRA_DOCK_STATE_UNDOCKED: 12462 return "EXTRA_DOCK_STATE_UNDOCKED"; 12463 default: 12464 return Integer.toString(dock); 12465 } 12466 } 12467 makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)12468 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, 12469 ArrayList<String> htmlTexts, int which) { 12470 Uri uri = streams != null ? streams.get(which) : null; 12471 CharSequence text = texts != null ? texts.get(which) : null; 12472 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; 12473 return new ClipData.Item(text, htmlText, null, uri); 12474 } 12475 12476 /** @hide */ isDocument()12477 public boolean isDocument() { 12478 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; 12479 } 12480 12481 /** @hide */ isSandboxActivity(@onNull Context context)12482 public boolean isSandboxActivity(@NonNull Context context) { 12483 if (mAction != null && mAction.equals(ACTION_START_SANDBOXED_ACTIVITY)) { 12484 return true; 12485 } 12486 final String sandboxPackageName = context.getPackageManager().getSdkSandboxPackageName(); 12487 if (mPackage != null && mPackage.equals(sandboxPackageName)) { 12488 return true; 12489 } 12490 if (mComponent != null && mComponent.getPackageName().equals(sandboxPackageName)) { 12491 return true; 12492 } 12493 return false; 12494 } 12495 } 12496