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 import static android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE; 22 import static android.security.Flags.FLAG_FRP_ENFORCEMENT; 23 import static android.service.chooser.Flags.FLAG_ENABLE_SHARESHEET_METADATA_EXTRA; 24 25 import android.Manifest; 26 import android.accessibilityservice.AccessibilityService; 27 import android.annotation.AnyRes; 28 import android.annotation.BroadcastBehavior; 29 import android.annotation.FlaggedApi; 30 import android.annotation.IntDef; 31 import android.annotation.NonNull; 32 import android.annotation.Nullable; 33 import android.annotation.RequiresPermission; 34 import android.annotation.SdkConstant; 35 import android.annotation.SdkConstant.SdkConstantType; 36 import android.annotation.SuppressLint; 37 import android.annotation.SystemApi; 38 import android.annotation.TestApi; 39 import android.app.Activity; 40 import android.app.ActivityThread; 41 import android.app.AppGlobals; 42 import android.app.StatusBarManager; 43 import android.bluetooth.BluetoothDevice; 44 import android.compat.annotation.UnsupportedAppUsage; 45 import android.content.pm.ActivityInfo; 46 import android.content.pm.ApplicationInfo; 47 import android.content.pm.ComponentInfo; 48 import android.content.pm.PackageManager; 49 import android.content.pm.ResolveInfo; 50 import android.content.pm.ShortcutInfo; 51 import android.content.pm.SuspendDialogInfo; 52 import android.content.pm.verify.domain.DomainVerificationManager; 53 import android.content.res.Resources; 54 import android.content.res.TypedArray; 55 import android.graphics.Rect; 56 import android.net.Uri; 57 import android.os.Build; 58 import android.os.Bundle; 59 import android.os.BundleMerger; 60 import android.os.CancellationSignal; 61 import android.os.IBinder; 62 import android.os.IncidentManager; 63 import android.os.Parcel; 64 import android.os.Parcelable; 65 import android.os.PersistableBundle; 66 import android.os.Process; 67 import android.os.ResultReceiver; 68 import android.os.ShellCommand; 69 import android.os.StrictMode; 70 import android.os.SystemClock; 71 import android.os.UserHandle; 72 import android.os.storage.StorageManager; 73 import android.provider.ContactsContract.QuickContact; 74 import android.provider.DocumentsContract; 75 import android.provider.DocumentsProvider; 76 import android.provider.MediaStore; 77 import android.provider.OpenableColumns; 78 import android.service.chooser.AdditionalContentContract; 79 import android.service.chooser.ChooserAction; 80 import android.service.chooser.ChooserResult; 81 import android.telecom.PhoneAccount; 82 import android.telecom.TelecomManager; 83 import android.text.TextUtils; 84 import android.util.ArraySet; 85 import android.util.AttributeSet; 86 import android.util.Log; 87 import android.util.proto.ProtoOutputStream; 88 89 import com.android.internal.util.XmlUtils; 90 91 import org.xmlpull.v1.XmlPullParser; 92 import org.xmlpull.v1.XmlPullParserException; 93 import org.xmlpull.v1.XmlSerializer; 94 95 import java.io.File; 96 import java.io.IOException; 97 import java.io.PrintWriter; 98 import java.io.Serializable; 99 import java.lang.annotation.Retention; 100 import java.lang.annotation.RetentionPolicy; 101 import java.net.URISyntaxException; 102 import java.util.ArrayList; 103 import java.util.HashSet; 104 import java.util.List; 105 import java.util.Locale; 106 import java.util.Objects; 107 import java.util.Set; 108 import java.util.TimeZone; 109 110 /** 111 * An intent is an abstract description of an operation to be performed. It 112 * can be used with {@link Context#startActivity(Intent) startActivity} to 113 * launch an {@link android.app.Activity}, 114 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to 115 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, 116 * and {@link android.content.Context#startService} or 117 * {@link android.content.Context#bindService} to communicate with a 118 * background {@link android.app.Service}. 119 * 120 * <p>An Intent provides a facility for performing late runtime binding between the code in 121 * different applications. Its most significant use is in the launching of activities, where it 122 * can be thought of as the glue between activities. It is basically a passive data structure 123 * holding an abstract description of an action to be performed.</p> 124 * 125 * <div class="special reference"> 126 * <h3>Developer Guides</h3> 127 * <p>For information about how to create and resolve intents, read the 128 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> 129 * developer guide.</p> 130 * </div> 131 * 132 * <a name="IntentStructure"></a> 133 * <h3>Intent Structure</h3> 134 * <p>The primary pieces of information in an intent are:</p> 135 * 136 * <ul> 137 * <li> <p><b>action</b> -- The general action to be performed, such as 138 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, 139 * etc.</p> 140 * </li> 141 * <li> <p><b>data</b> -- The data to operate on, such as a person record 142 * in the contacts database, expressed as a {@link android.net.Uri}.</p> 143 * </li> 144 * </ul> 145 * 146 * 147 * <p>Some examples of action/data pairs are:</p> 148 * 149 * <ul> 150 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display 151 * information about the person whose identifier is "1".</p> 152 * </li> 153 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display 154 * the phone dialer with the person filled in.</p> 155 * </li> 156 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display 157 * the phone dialer with the given number filled in. Note how the 158 * VIEW action does what is considered the most reasonable thing for 159 * a particular URI.</p> 160 * </li> 161 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display 162 * the phone dialer with the given number filled in.</p> 163 * </li> 164 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit 165 * information about the person whose identifier is "1".</p> 166 * </li> 167 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display 168 * a list of people, which the user can browse through. This example is a 169 * typical top-level entry into the Contacts application, showing you the 170 * list of people. Selecting a particular person to view would result in a 171 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> } 172 * being used to start an activity to display that person.</p> 173 * </li> 174 * </ul> 175 * 176 * <p>In addition to these primary attributes, there are a number of secondary 177 * attributes that you can also include with an intent:</p> 178 * 179 * <ul> 180 * <li> <p><b>category</b> -- Gives additional information about the action 181 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should 182 * appear in the Launcher as a top-level application, while 183 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list 184 * of alternative actions the user can perform on a piece of data.</p> 185 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the 186 * intent data. Normally the type is inferred from the data itself. 187 * By setting this attribute, you disable that evaluation and force 188 * an explicit type.</p> 189 * <li> <p><b>component</b> -- Specifies an explicit name of a component 190 * class to use for the intent. Normally this is determined by looking 191 * at the other information in the intent (the action, data/type, and 192 * categories) and matching that with a component that can handle it. 193 * If this attribute is set then none of the evaluation is performed, 194 * and this component is used exactly as is. By specifying this attribute, 195 * all of the other Intent attributes become optional.</p> 196 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. 197 * This can be used to provide extended information to the component. 198 * For example, if we have a action to send an e-mail message, we could 199 * also include extra pieces of data here to supply a subject, body, 200 * etc.</p> 201 * </ul> 202 * 203 * <p>Here are some examples of other operations you can specify as intents 204 * using these additional parameters:</p> 205 * 206 * <ul> 207 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- 208 * Launch the home screen.</p> 209 * </li> 210 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 211 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI 212 * vnd.android.cursor.item/phone}</i></b> 213 * -- Display the list of people's phone numbers, allowing the user to 214 * browse through them and pick one and return it to the parent activity.</p> 215 * </li> 216 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 217 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> 218 * -- Display all pickers for data that can be opened with 219 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, 220 * allowing the user to pick one of them and then some data inside of it 221 * and returning the resulting URI to the caller. This can be used, 222 * for example, in an e-mail application to allow the user to pick some 223 * data to include as an attachment.</p> 224 * </li> 225 * </ul> 226 * 227 * <p>There are a variety of standard Intent action and category constants 228 * defined in the Intent class, but applications can also define their own. 229 * These strings use Java-style scoping, to ensure they are unique -- for 230 * example, the standard {@link #ACTION_VIEW} is called 231 * "android.intent.action.VIEW".</p> 232 * 233 * <p>Put together, the set of actions, data types, categories, and extra data 234 * defines a language for the system allowing for the expression of phrases 235 * such as "call john smith's cell". As applications are added to the system, 236 * they can extend this language by adding new actions, types, and categories, or 237 * they can modify the behavior of existing phrases by supplying their own 238 * activities that handle them.</p> 239 * 240 * <a name="IntentResolution"></a> 241 * <h3>Intent Resolution</h3> 242 * 243 * <p>There are two primary forms of intents you will use. 244 * 245 * <ul> 246 * <li> <p><b>Explicit Intents</b> have specified a component (via 247 * {@link #setComponent} or {@link #setClass}), which provides the exact 248 * class to be run. Often these will not include any other information, 249 * simply being a way for an application to launch various internal 250 * activities it has as the user interacts with the application. 251 * 252 * <li> <p><b>Implicit Intents</b> have not specified a component; 253 * instead, they must include enough information for the system to 254 * determine which of the available components is best to run for that 255 * intent. 256 * </ul> 257 * 258 * <p>When using implicit intents, given such an arbitrary intent we need to 259 * know what to do with it. This is handled by the process of <em>Intent 260 * resolution</em>, which maps an Intent to an {@link android.app.Activity}, 261 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or 262 * more activities/receivers) that can handle it.</p> 263 * 264 * <p>The intent resolution mechanism basically revolves around matching an 265 * Intent against all of the <intent-filter> descriptions in the 266 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} 267 * objects explicitly registered with {@link Context#registerReceiver}.) More 268 * details on this can be found in the documentation on the {@link 269 * IntentFilter} class.</p> 270 * 271 * <p>There are three pieces of information in the Intent that are used for 272 * resolution: the action, type, and category. Using this information, a query 273 * is done on the {@link PackageManager} for a component that can handle the 274 * intent. The appropriate component is determined based on the intent 275 * information supplied in the <code>AndroidManifest.xml</code> file as 276 * follows:</p> 277 * 278 * <ul> 279 * <li> <p>The <b>action</b>, if given, must be listed by the component as 280 * one it handles.</p> 281 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not 282 * already supplied in the Intent. Like the action, if a type is 283 * included in the intent (either explicitly or implicitly in its 284 * data), then this must be listed by the component as one it handles.</p> 285 * <li> For data that is not a <code>content:</code> URI and where no explicit 286 * type is included in the Intent, instead the <b>scheme</b> of the 287 * intent data (such as <code>http:</code> or <code>mailto:</code>) is 288 * considered. Again like the action, if we are matching a scheme it 289 * must be listed by the component as one it can handle. 290 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed 291 * by the activity as categories it handles. That is, if you include 292 * the categories {@link #CATEGORY_LAUNCHER} and 293 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components 294 * with an intent that lists <em>both</em> of those categories. 295 * Activities will very often need to support the 296 * {@link #CATEGORY_DEFAULT} so that they can be found by 297 * {@link Context#startActivity Context.startActivity()}.</p> 298 * </ul> 299 * 300 * <p>For example, consider the Note Pad sample application that 301 * allows a user to browse through a list of notes data and view details about 302 * individual items. Text in italics indicates places where you would replace a 303 * name with one specific to your own package.</p> 304 * 305 * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 306 * package="<i>com.android.notepad</i>"> 307 * <application android:icon="@drawable/app_notes" 308 * android:label="@string/app_name"> 309 * 310 * <provider class=".NotePadProvider" 311 * android:authorities="<i>com.google.provider.NotePad</i>" /> 312 * 313 * <activity class=".NotesList" android:label="@string/title_notes_list"> 314 * <intent-filter> 315 * <action android:name="android.intent.action.MAIN" /> 316 * <category android:name="android.intent.category.LAUNCHER" /> 317 * </intent-filter> 318 * <intent-filter> 319 * <action android:name="android.intent.action.VIEW" /> 320 * <action android:name="android.intent.action.EDIT" /> 321 * <action android:name="android.intent.action.PICK" /> 322 * <category android:name="android.intent.category.DEFAULT" /> 323 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 324 * </intent-filter> 325 * <intent-filter> 326 * <action android:name="android.intent.action.GET_CONTENT" /> 327 * <category android:name="android.intent.category.DEFAULT" /> 328 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 329 * </intent-filter> 330 * </activity> 331 * 332 * <activity class=".NoteEditor" android:label="@string/title_note"> 333 * <intent-filter android:label="@string/resolve_edit"> 334 * <action android:name="android.intent.action.VIEW" /> 335 * <action android:name="android.intent.action.EDIT" /> 336 * <category android:name="android.intent.category.DEFAULT" /> 337 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 338 * </intent-filter> 339 * 340 * <intent-filter> 341 * <action android:name="android.intent.action.INSERT" /> 342 * <category android:name="android.intent.category.DEFAULT" /> 343 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 344 * </intent-filter> 345 * 346 * </activity> 347 * 348 * <activity class=".TitleEditor" android:label="@string/title_edit_title" 349 * android:theme="@android:style/Theme.Dialog"> 350 * <intent-filter android:label="@string/resolve_title"> 351 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 352 * <category android:name="android.intent.category.DEFAULT" /> 353 * <category android:name="android.intent.category.ALTERNATIVE" /> 354 * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> 355 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 356 * </intent-filter> 357 * </activity> 358 * 359 * </application> 360 * </manifest></pre> 361 * 362 * <p>The first activity, 363 * <code>com.android.notepad.NotesList</code>, serves as our main 364 * entry into the app. It can do three things as described by its three intent 365 * templates: 366 * <ol> 367 * <li><pre> 368 * <intent-filter> 369 * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> 370 * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> 371 * </intent-filter></pre> 372 * <p>This provides a top-level entry into the NotePad application: the standard 373 * MAIN action is a main entry point (not requiring any other information in 374 * the Intent), and the LAUNCHER category says that this entry point should be 375 * listed in the application launcher.</p> 376 * <li><pre> 377 * <intent-filter> 378 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 379 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 380 * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> 381 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 382 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 383 * </intent-filter></pre> 384 * <p>This declares the things that the activity can do on a directory of 385 * notes. The type being supported is given with the <type> tag, where 386 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which 387 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can 388 * be retrieved which holds our note pad data (<code>vnd.google.note</code>). 389 * The activity allows the user to view or edit the directory of data (via 390 * the VIEW and EDIT actions), or to pick a particular note and return it 391 * to the caller (via the PICK action). Note also the DEFAULT category 392 * supplied here: this is <em>required</em> for the 393 * {@link Context#startActivity Context.startActivity} method to resolve your 394 * activity when its component name is not explicitly specified.</p> 395 * <li><pre> 396 * <intent-filter> 397 * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> 398 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 399 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 400 * </intent-filter></pre> 401 * <p>This filter describes the ability to return to the caller a note selected by 402 * the user without needing to know where it came from. The data type 403 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which 404 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can 405 * be retrieved which contains our note pad data (<code>vnd.google.note</code>). 406 * The GET_CONTENT action is similar to the PICK action, where the activity 407 * will return to its caller a piece of data selected by the user. Here, 408 * however, the caller specifies the type of data they desire instead of 409 * the type of data the user will be picking from.</p> 410 * </ol> 411 * 412 * <p>Given these capabilities, the following intents will resolve to the 413 * NotesList activity:</p> 414 * 415 * <ul> 416 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the 417 * activities that can be used as top-level entry points into an 418 * application.</p> 419 * <li> <p><b>{ action=android.app.action.MAIN, 420 * category=android.app.category.LAUNCHER }</b> is the actual intent 421 * used by the Launcher to populate its top-level list.</p> 422 * <li> <p><b>{ action=android.intent.action.VIEW 423 * data=content://com.google.provider.NotePad/notes }</b> 424 * displays a list of all the notes under 425 * "content://com.google.provider.NotePad/notes", which 426 * the user can browse through and see the details on.</p> 427 * <li> <p><b>{ action=android.app.action.PICK 428 * data=content://com.google.provider.NotePad/notes }</b> 429 * provides a list of the notes under 430 * "content://com.google.provider.NotePad/notes", from which 431 * the user can pick a note whose data URL is returned back to the caller.</p> 432 * <li> <p><b>{ action=android.app.action.GET_CONTENT 433 * type=vnd.android.cursor.item/vnd.google.note }</b> 434 * is similar to the pick action, but allows the caller to specify the 435 * kind of data they want back so that the system can find the appropriate 436 * activity to pick something of that data type.</p> 437 * </ul> 438 * 439 * <p>The second activity, 440 * <code>com.android.notepad.NoteEditor</code>, shows the user a single 441 * note entry and allows them to edit it. It can do two things as described 442 * by its two intent templates: 443 * <ol> 444 * <li><pre> 445 * <intent-filter android:label="@string/resolve_edit"> 446 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 447 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 448 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 449 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 450 * </intent-filter></pre> 451 * <p>The first, primary, purpose of this activity is to let the user interact 452 * with a single note, as decribed by the MIME type 453 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can 454 * either VIEW a note or allow the user to EDIT it. Again we support the 455 * DEFAULT category to allow the activity to be launched without explicitly 456 * specifying its component.</p> 457 * <li><pre> 458 * <intent-filter> 459 * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> 460 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 461 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 462 * </intent-filter></pre> 463 * <p>The secondary use of this activity is to insert a new note entry into 464 * an existing directory of notes. This is used when the user creates a new 465 * note: the INSERT action is executed on the directory of notes, causing 466 * this activity to run and have the user create the new note data which 467 * it then adds to the content provider.</p> 468 * </ol> 469 * 470 * <p>Given these capabilities, the following intents will resolve to the 471 * NoteEditor activity:</p> 472 * 473 * <ul> 474 * <li> <p><b>{ action=android.intent.action.VIEW 475 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 476 * shows the user the content of note <var>{ID}</var>.</p> 477 * <li> <p><b>{ action=android.app.action.EDIT 478 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 479 * allows the user to edit the content of note <var>{ID}</var>.</p> 480 * <li> <p><b>{ action=android.app.action.INSERT 481 * data=content://com.google.provider.NotePad/notes }</b> 482 * creates a new, empty note in the notes list at 483 * "content://com.google.provider.NotePad/notes" 484 * and allows the user to edit it. If they keep their changes, the URI 485 * of the newly created note is returned to the caller.</p> 486 * </ul> 487 * 488 * <p>The last activity, 489 * <code>com.android.notepad.TitleEditor</code>, allows the user to 490 * edit the title of a note. This could be implemented as a class that the 491 * application directly invokes (by explicitly setting its component in 492 * the Intent), but here we show a way you can publish alternative 493 * operations on existing data:</p> 494 * 495 * <pre> 496 * <intent-filter android:label="@string/resolve_title"> 497 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 498 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 499 * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> 500 * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> 501 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 502 * </intent-filter></pre> 503 * 504 * <p>In the single intent template here, we 505 * have created our own private action called 506 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to 507 * edit the title of a note. It must be invoked on a specific note 508 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous 509 * view and edit actions, but here displays and edits the title contained 510 * in the note data. 511 * 512 * <p>In addition to supporting the default category as usual, our title editor 513 * also supports two other standard categories: ALTERNATIVE and 514 * SELECTED_ALTERNATIVE. Implementing 515 * these categories allows others to find the special action it provides 516 * without directly knowing about it, through the 517 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or 518 * more often to build dynamic menu items with 519 * {@link android.view.Menu#addIntentOptions}. Note that in the intent 520 * template here was also supply an explicit name for the template 521 * (via <code>android:label="@string/resolve_title"</code>) to better control 522 * what the user sees when presented with this activity as an alternative 523 * action to the data they are viewing. 524 * 525 * <p>Given these capabilities, the following intent will resolve to the 526 * TitleEditor activity:</p> 527 * 528 * <ul> 529 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE 530 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 531 * displays and allows the user to edit the title associated 532 * with note <var>{ID}</var>.</p> 533 * </ul> 534 * 535 * <h3>Standard Activity Actions</h3> 536 * 537 * <p>These are the current standard actions that Intent defines for launching 538 * activities (usually through {@link Context#startActivity}. The most 539 * important, and by far most frequently used, are {@link #ACTION_MAIN} and 540 * {@link #ACTION_EDIT}. 541 * 542 * <ul> 543 * <li> {@link #ACTION_MAIN} 544 * <li> {@link #ACTION_VIEW} 545 * <li> {@link #ACTION_ATTACH_DATA} 546 * <li> {@link #ACTION_EDIT} 547 * <li> {@link #ACTION_PICK} 548 * <li> {@link #ACTION_CHOOSER} 549 * <li> {@link #ACTION_GET_CONTENT} 550 * <li> {@link #ACTION_DIAL} 551 * <li> {@link #ACTION_CALL} 552 * <li> {@link #ACTION_SEND} 553 * <li> {@link #ACTION_SENDTO} 554 * <li> {@link #ACTION_ANSWER} 555 * <li> {@link #ACTION_INSERT} 556 * <li> {@link #ACTION_DELETE} 557 * <li> {@link #ACTION_RUN} 558 * <li> {@link #ACTION_SYNC} 559 * <li> {@link #ACTION_PICK_ACTIVITY} 560 * <li> {@link #ACTION_SEARCH} 561 * <li> {@link #ACTION_WEB_SEARCH} 562 * <li> {@link #ACTION_FACTORY_TEST} 563 * </ul> 564 * 565 * <h3>Standard Broadcast Actions</h3> 566 * 567 * <p>These are the current standard actions that Intent defines for receiving 568 * broadcasts (usually through {@link Context#registerReceiver} or a 569 * <receiver> tag in a manifest). 570 * 571 * <ul> 572 * <li> {@link #ACTION_TIME_TICK} 573 * <li> {@link #ACTION_TIME_CHANGED} 574 * <li> {@link #ACTION_TIMEZONE_CHANGED} 575 * <li> {@link #ACTION_BOOT_COMPLETED} 576 * <li> {@link #ACTION_PACKAGE_ADDED} 577 * <li> {@link #ACTION_PACKAGE_CHANGED} 578 * <li> {@link #ACTION_PACKAGE_REMOVED} 579 * <li> {@link #ACTION_PACKAGE_RESTARTED} 580 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} 581 * <li> {@link #ACTION_PACKAGES_SUSPENDED} 582 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} 583 * <li> {@link #ACTION_UID_REMOVED} 584 * <li> {@link #ACTION_BATTERY_CHANGED} 585 * <li> {@link #ACTION_POWER_CONNECTED} 586 * <li> {@link #ACTION_POWER_DISCONNECTED} 587 * <li> {@link #ACTION_SHUTDOWN} 588 * </ul> 589 * 590 * <p class="note"><strong>Note: </strong>If your app targets Android 11 591 * (API level 30) or higher, registering broadcast such as 592 * {@link #ACTION_PACKAGES_SUSPENDED} that includes package details in the 593 * extras receives a filtered list of apps or nothing. Learn more about how to 594 * <a href="/training/basics/intents/package-visibility">manage package visibility</a>. 595 * </p> 596 * 597 * <h3>Standard Categories</h3> 598 * 599 * <p>These are the current standard categories that can be used to further 600 * clarify an Intent via {@link #addCategory}. 601 * 602 * <ul> 603 * <li> {@link #CATEGORY_DEFAULT} 604 * <li> {@link #CATEGORY_BROWSABLE} 605 * <li> {@link #CATEGORY_TAB} 606 * <li> {@link #CATEGORY_ALTERNATIVE} 607 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} 608 * <li> {@link #CATEGORY_LAUNCHER} 609 * <li> {@link #CATEGORY_INFO} 610 * <li> {@link #CATEGORY_HOME} 611 * <li> {@link #CATEGORY_PREFERENCE} 612 * <li> {@link #CATEGORY_TEST} 613 * <li> {@link #CATEGORY_CAR_DOCK} 614 * <li> {@link #CATEGORY_DESK_DOCK} 615 * <li> {@link #CATEGORY_LE_DESK_DOCK} 616 * <li> {@link #CATEGORY_HE_DESK_DOCK} 617 * <li> {@link #CATEGORY_CAR_MODE} 618 * <li> {@link #CATEGORY_APP_MARKET} 619 * <li> {@link #CATEGORY_VR_HOME} 620 * </ul> 621 * 622 * <h3>Standard Extra Data</h3> 623 * 624 * <p>These are the current standard fields that can be used as extra data via 625 * {@link #putExtra}. 626 * 627 * <ul> 628 * <li> {@link #EXTRA_ALARM_COUNT} 629 * <li> {@link #EXTRA_BCC} 630 * <li> {@link #EXTRA_CC} 631 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} 632 * <li> {@link #EXTRA_DATA_REMOVED} 633 * <li> {@link #EXTRA_DOCK_STATE} 634 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} 635 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} 636 * <li> {@link #EXTRA_DOCK_STATE_CAR} 637 * <li> {@link #EXTRA_DOCK_STATE_DESK} 638 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} 639 * <li> {@link #EXTRA_DONT_KILL_APP} 640 * <li> {@link #EXTRA_EMAIL} 641 * <li> {@link #EXTRA_INITIAL_INTENTS} 642 * <li> {@link #EXTRA_INTENT} 643 * <li> {@link #EXTRA_KEY_EVENT} 644 * <li> {@link #EXTRA_ORIGINATING_URI} 645 * <li> {@link #EXTRA_PHONE_NUMBER} 646 * <li> {@link #EXTRA_REFERRER} 647 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} 648 * <li> {@link #EXTRA_REPLACING} 649 * <li> {@link #EXTRA_SHORTCUT_ICON} 650 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} 651 * <li> {@link #EXTRA_SHORTCUT_INTENT} 652 * <li> {@link #EXTRA_STREAM} 653 * <li> {@link #EXTRA_SHORTCUT_NAME} 654 * <li> {@link #EXTRA_SUBJECT} 655 * <li> {@link #EXTRA_TEMPLATE} 656 * <li> {@link #EXTRA_TEXT} 657 * <li> {@link #EXTRA_TITLE} 658 * <li> {@link #EXTRA_UID} 659 * <li> {@link #EXTRA_USER_INITIATED} 660 * </ul> 661 * 662 * <h3>Flags</h3> 663 * 664 * <p>These are the possible flags that can be used in the Intent via 665 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list 666 * of all possible flags. 667 */ 668 @android.ravenwood.annotation.RavenwoodKeepWholeClass 669 public class Intent implements Parcelable, Cloneable { 670 private static final String TAG = "Intent"; 671 672 private static final String ATTR_ACTION = "action"; 673 private static final String TAG_CATEGORIES = "categories"; 674 private static final String ATTR_CATEGORY = "category"; 675 private static final String TAG_EXTRA = "extra"; 676 private static final String ATTR_TYPE = "type"; 677 private static final String ATTR_IDENTIFIER = "ident"; 678 private static final String ATTR_COMPONENT = "component"; 679 private static final String ATTR_DATA = "data"; 680 private static final String ATTR_FLAGS = "flags"; 681 682 // --------------------------------------------------------------------- 683 // --------------------------------------------------------------------- 684 // Standard intent activity actions (see action variable). 685 686 /** 687 * Activity Action: Start as a main entry point, does not expect to 688 * receive data. 689 * <p>Input: nothing 690 * <p>Output: nothing 691 */ 692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 693 public static final String ACTION_MAIN = "android.intent.action.MAIN"; 694 695 /** 696 * Activity Action: Display the data to the user. This is the most common 697 * action performed on data -- it is the generic action you can use on 698 * a piece of data to get the most reasonable thing to occur. For example, 699 * when used on a contacts entry it will view the entry; when used on a 700 * mailto: URI it will bring up a compose window filled with the information 701 * supplied by the URI; when used with a tel: URI it will invoke the 702 * dialer. 703 * <p>Input: {@link #getData} is URI from which to retrieve data. 704 * <p>Output: nothing. 705 */ 706 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 707 public static final String ACTION_VIEW = "android.intent.action.VIEW"; 708 709 /** 710 * Extra that can be included on activity intents coming from the storage UI 711 * when it launches sub-activities to manage various types of storage. For example, 712 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show 713 * the images on the device, and in that case also include this extra to tell the 714 * app it is coming from the storage UI so should help the user manage storage of 715 * this type. 716 */ 717 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE"; 718 719 /** 720 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is 721 * performed on a piece of data. 722 */ 723 public static final String ACTION_DEFAULT = ACTION_VIEW; 724 725 /** 726 * Activity Action: Quick view the data. Launches a quick viewer for 727 * a URI or a list of URIs. 728 * <p>Activities handling this intent action should handle the vast majority of 729 * MIME types rather than only specific ones. 730 * <p>Quick viewers must render the quick view image locally, and must not send 731 * file content outside current device. 732 * <p>Input: {@link #getData} is a mandatory content URI of the item to 733 * preview. {@link #getClipData} contains an optional list of content URIs 734 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an 735 * optional index of the URI in the clip data to show first. 736 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features 737 * that can be shown in the quick view UI. 738 * <p>Output: nothing. 739 * @see #EXTRA_INDEX 740 * @see #EXTRA_QUICK_VIEW_FEATURES 741 */ 742 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 743 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; 744 745 /** 746 * Used to indicate that some piece of data should be attached to some other 747 * place. For example, image data could be attached to a contact. It is up 748 * to the recipient to decide where the data should be attached; the intent 749 * does not specify the ultimate destination. 750 * <p>Input: {@link #getData} is URI of data to be attached. 751 * <p>Output: nothing. 752 */ 753 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 754 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; 755 756 /** 757 * Activity Action: Provide explicit editable access to the given data. 758 * <p>Input: {@link #getData} is URI of data to be edited. 759 * <p>Output: nothing. 760 */ 761 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 762 public static final String ACTION_EDIT = "android.intent.action.EDIT"; 763 764 /** 765 * Activity Action: Pick an existing item, or insert a new item, and then edit it. 766 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. 767 * The extras can contain type specific data to pass through to the editing/creating 768 * activity. 769 * <p>Output: The URI of the item that was picked. This must be a content: 770 * URI so that any receiver can access it. 771 */ 772 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 773 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; 774 775 /** 776 * Activity Action: Pick an item from the data, returning what was selected. 777 * <p>Input: {@link #getData} is URI containing a directory of data 778 * (vnd.android.cursor.dir/*) from which to pick an item. 779 * <p>Output: The URI of the item that was picked. 780 */ 781 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 782 public static final String ACTION_PICK = "android.intent.action.PICK"; 783 784 /** 785 * Activity Action: Creates a reminder. 786 * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user. 787 * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at 788 * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will 789 * be shown to the user. The time is specified in milliseconds since the Epoch (optional). 790 * </p> 791 * <p>Output: Nothing.</p> 792 * 793 * @see #EXTRA_TITLE 794 * @see #EXTRA_TEXT 795 * @see #EXTRA_TIME 796 */ 797 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 798 public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER"; 799 800 /** 801 * Activity Action: Creates a shortcut. 802 * <p>Input: Nothing.</p> 803 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> 804 * <p>For compatibility with older versions of android the intent may also contain three 805 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), 806 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE 807 * (value: ShortcutIconResource).</p> 808 * 809 * @see android.content.pm.ShortcutManager#createShortcutResultIntent 810 * @see #EXTRA_SHORTCUT_INTENT 811 * @see #EXTRA_SHORTCUT_NAME 812 * @see #EXTRA_SHORTCUT_ICON 813 * @see #EXTRA_SHORTCUT_ICON_RESOURCE 814 * @see android.content.Intent.ShortcutIconResource 815 */ 816 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 817 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; 818 819 /** 820 * The name of the extra used to define the Intent of a shortcut. 821 * 822 * @see #ACTION_CREATE_SHORTCUT 823 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 824 */ 825 @Deprecated 826 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; 827 /** 828 * The name of the extra used to define the name of a shortcut. 829 * 830 * @see #ACTION_CREATE_SHORTCUT 831 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 832 */ 833 @Deprecated 834 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; 835 /** 836 * The name of the extra used to define the icon, as a Bitmap, of a shortcut. 837 * 838 * @see #ACTION_CREATE_SHORTCUT 839 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 840 */ 841 @Deprecated 842 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; 843 /** 844 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. 845 * 846 * @see #ACTION_CREATE_SHORTCUT 847 * @see android.content.Intent.ShortcutIconResource 848 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 849 */ 850 @Deprecated 851 public static final String EXTRA_SHORTCUT_ICON_RESOURCE = 852 "android.intent.extra.shortcut.ICON_RESOURCE"; 853 854 /** 855 * An activity that provides a user interface for adjusting application preferences. 856 * Optional but recommended settings for all applications which have settings. 857 */ 858 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 859 public static final String ACTION_APPLICATION_PREFERENCES 860 = "android.intent.action.APPLICATION_PREFERENCES"; 861 862 /** 863 * Activity Action: Launch an activity showing the app information. 864 * For applications which install other applications (such as app stores), it is recommended 865 * to handle this action for providing the app information to the user. 866 * 867 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs 868 * to be displayed. 869 * <p>Output: Nothing. 870 */ 871 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 872 public static final String ACTION_SHOW_APP_INFO 873 = "android.intent.action.SHOW_APP_INFO"; 874 875 /** 876 * Activity Action: Placeholder that the component handling it can do activity 877 * recognition. Can be placed on a service. Only one service per package is 878 * supported. 879 * 880 * <p>Input: Nothing.</p> 881 * <p>Output: Nothing </p> 882 * 883 * @hide 884 */ 885 @SystemApi 886 @SdkConstant(SdkConstantType.SERVICE_ACTION) 887 public static final String ACTION_ACTIVITY_RECOGNIZER = 888 "android.intent.action.ACTIVITY_RECOGNIZER"; 889 890 /** 891 * Represents a shortcut/live folder icon resource. 892 * 893 * @see Intent#ACTION_CREATE_SHORTCUT 894 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE 895 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER 896 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON 897 */ 898 public static class ShortcutIconResource implements Parcelable { 899 /** 900 * The package name of the application containing the icon. 901 */ 902 public String packageName; 903 904 /** 905 * The resource name of the icon, including package, name and type. 906 */ 907 public String resourceName; 908 909 /** 910 * Creates a new ShortcutIconResource for the specified context and resource 911 * identifier. 912 * 913 * @param context The context of the application. 914 * @param resourceId The resource identifier for the icon. 915 * @return A new ShortcutIconResource with the specified's context package name 916 * and icon resource identifier.`` 917 */ fromContext(Context context, @AnyRes int resourceId)918 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { 919 ShortcutIconResource icon = new ShortcutIconResource(); 920 icon.packageName = context.getPackageName(); 921 icon.resourceName = context.getResources().getResourceName(resourceId); 922 return icon; 923 } 924 925 /** 926 * Used to read a ShortcutIconResource from a Parcel. 927 */ 928 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR = 929 new Parcelable.Creator<ShortcutIconResource>() { 930 931 public ShortcutIconResource createFromParcel(Parcel source) { 932 ShortcutIconResource icon = new ShortcutIconResource(); 933 icon.packageName = source.readString8(); 934 icon.resourceName = source.readString8(); 935 return icon; 936 } 937 938 public ShortcutIconResource[] newArray(int size) { 939 return new ShortcutIconResource[size]; 940 } 941 }; 942 943 /** 944 * No special parcel contents. 945 */ describeContents()946 public int describeContents() { 947 return 0; 948 } 949 writeToParcel(Parcel dest, int flags)950 public void writeToParcel(Parcel dest, int flags) { 951 dest.writeString8(packageName); 952 dest.writeString8(resourceName); 953 } 954 955 @Override toString()956 public String toString() { 957 return resourceName; 958 } 959 } 960 961 /** 962 * Activity Action: Display an activity chooser, allowing the user to pick 963 * what they want to before proceeding. This can be used as an alternative 964 * to the standard activity picker that is displayed by the system when 965 * you try to start an activity with multiple possible matches, with these 966 * differences in behavior: 967 * <ul> 968 * <li>You can specify the title that will appear in the activity chooser. 969 * <li>The user does not have the option to make one of the matching 970 * activities a preferred activity, and all possible activities will 971 * always be shown even if one of them is currently marked as the 972 * preferred activity. 973 * </ul> 974 * <p> 975 * This action should be used when the user will naturally expect to 976 * select an activity in order to proceed. An example if when not to use 977 * it is when the user clicks on a "mailto:" link. They would naturally 978 * expect to go directly to their mail app, so startActivity() should be 979 * called directly: it will 980 * either launch the current preferred app, or put up a dialog allowing the 981 * user to pick an app to use and optionally marking that as preferred. 982 * <p> 983 * In contrast, if the user is selecting a menu item to send a picture 984 * they are viewing to someone else, there are many different things they 985 * may want to do at this point: send it through e-mail, upload it to a 986 * web service, etc. In this case the CHOOSER action should be used, to 987 * always present to the user a list of the things they can do, with a 988 * nice title given by the caller such as "Send this photo with:". 989 * <p> 990 * If you need to grant URI permissions through a chooser, you must specify 991 * the permissions to be granted on the ACTION_CHOOSER Intent 992 * <em>in addition</em> to the EXTRA_INTENT inside. This means using 993 * {@link #setClipData} to specify the URIs to be granted as well as 994 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 995 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. 996 * <p> 997 * As a convenience, an Intent of this form can be created with the 998 * {@link #createChooser} function. 999 * <p> 1000 * Input: No data should be specified. get*Extra must have 1001 * a {@link #EXTRA_INTENT} field containing the Intent being executed, 1002 * and can optionally have a {@link #EXTRA_TITLE} field containing the 1003 * title text to display in the chooser. 1004 * <p> 1005 * Output: Depends on the protocol of {@link #EXTRA_INTENT}. 1006 */ 1007 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1008 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; 1009 1010 /** 1011 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 1012 * 1013 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 1014 * target intent, also optionally supplying a title. If the target 1015 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 1016 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 1017 * set in the returned chooser intent, with its ClipData set appropriately: 1018 * either a direct reflection of {@link #getClipData()} if that is non-null, 1019 * or a new ClipData built from {@link #getData()}. 1020 * 1021 * @param target The Intent that the user will be selecting an activity 1022 * to perform. 1023 * @param title Optional title that will be displayed in the chooser, 1024 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1025 * @return Return a new Intent object that you can hand to 1026 * {@link Context#startActivity(Intent) Context.startActivity()} and 1027 * related methods. 1028 */ createChooser(Intent target, CharSequence title)1029 public static Intent createChooser(Intent target, CharSequence title) { 1030 return createChooser(target, title, null); 1031 } 1032 1033 /** 1034 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 1035 * 1036 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 1037 * target intent, also optionally supplying a title. If the target 1038 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 1039 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 1040 * set in the returned chooser intent, with its ClipData set appropriately: 1041 * either a direct reflection of {@link #getClipData()} if that is non-null, 1042 * or a new ClipData built from {@link #getData()}.</p> 1043 * 1044 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback 1045 * when the user makes a choice. This can be useful if the calling application wants 1046 * to remember the last chosen target and surface it as a more prominent or one-touch 1047 * affordance elsewhere in the UI for next time.</p> 1048 * 1049 * @param target The Intent that the user will be selecting an activity 1050 * to perform. 1051 * @param title Optional title that will be displayed in the chooser, 1052 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1053 * @param sender Optional IntentSender to be called when a choice is made. 1054 * @return Return a new Intent object that you can hand to 1055 * {@link Context#startActivity(Intent) Context.startActivity()} and 1056 * related methods. 1057 */ createChooser(Intent target, CharSequence title, IntentSender sender)1058 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) { 1059 Intent intent = new Intent(ACTION_CHOOSER); 1060 intent.putExtra(EXTRA_INTENT, target); 1061 if (title != null) { 1062 intent.putExtra(EXTRA_TITLE, title); 1063 } 1064 1065 if (sender != null) { 1066 if (android.service.chooser.Flags.enableChooserResult()) { 1067 intent.putExtra(EXTRA_CHOOSER_RESULT_INTENT_SENDER, sender); 1068 } else { 1069 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); 1070 } 1071 } 1072 1073 // Migrate any clip data and flags from target. 1074 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION 1075 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 1076 | FLAG_GRANT_PREFIX_URI_PERMISSION); 1077 if (permFlags != 0) { 1078 ClipData targetClipData = target.getClipData(); 1079 if (targetClipData == null && target.getData() != null) { 1080 ClipData.Item item = new ClipData.Item(target.getData()); 1081 String[] mimeTypes; 1082 if (target.getType() != null) { 1083 mimeTypes = new String[] { target.getType() }; 1084 } else { 1085 mimeTypes = new String[] { }; 1086 } 1087 targetClipData = new ClipData(null, mimeTypes, item); 1088 } 1089 if (targetClipData != null) { 1090 intent.setClipData(targetClipData); 1091 intent.addFlags(permFlags); 1092 } 1093 } 1094 1095 return intent; 1096 } 1097 1098 /** 1099 * Activity Action: Allow the user to select a particular kind of data and 1100 * return it. This is different than {@link #ACTION_PICK} in that here we 1101 * just say what kind of data is desired, not a URI of existing data from 1102 * which the user can pick. An ACTION_GET_CONTENT could allow the user to 1103 * create the data as it runs (for example taking a picture or recording a 1104 * sound), let them browse over the web and download the desired data, 1105 * etc. 1106 * <p> 1107 * There are two main ways to use this action: if you want a specific kind 1108 * of data, such as a person contact, you set the MIME type to the kind of 1109 * data you want and launch it with {@link Context#startActivity(Intent)}. 1110 * The system will then launch the best application to select that kind 1111 * of data for you. 1112 * <p> 1113 * You may also be interested in any of a set of types of content the user 1114 * can pick. For example, an e-mail application that wants to allow the 1115 * user to add an attachment to an e-mail message can use this action to 1116 * bring up a list of all of the types of content the user can attach. 1117 * <p> 1118 * In this case, you should wrap the GET_CONTENT intent with a chooser 1119 * (through {@link #createChooser}), which will give the proper interface 1120 * for the user to pick how to send your data and allow you to specify 1121 * a prompt indicating what they are doing. You will usually specify a 1122 * broad MIME type (such as image/* or {@literal *}/*), resulting in a 1123 * broad range of content types the user can select from. 1124 * <p> 1125 * When using such a broad GET_CONTENT action, it is often desirable to 1126 * only pick from data that can be represented as a stream. This is 1127 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. 1128 * <p> 1129 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that 1130 * the launched content chooser only returns results representing data that 1131 * is locally available on the device. For example, if this extra is set 1132 * to true then an image picker should not show any pictures that are available 1133 * from a remote server but not already on the local device (thus requiring 1134 * they be downloaded when opened). 1135 * <p> 1136 * If the caller can handle multiple returned items (the user performing 1137 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} 1138 * to indicate this. 1139 * <p> 1140 * Input: {@link #getType} is the desired MIME type to retrieve. Note 1141 * that no URI is supplied in the intent, as there are no constraints on 1142 * where the returned data originally comes from. You may also include the 1143 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be 1144 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content 1145 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to 1146 * allow the user to select multiple items. 1147 * <p> 1148 * Output: The URI of the item that was picked. This must be a content: 1149 * URI so that any receiver can access it. 1150 */ 1151 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1152 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; 1153 /** 1154 * Activity Action: Dial a number as specified by the data. This shows a 1155 * UI with the number being dialed, allowing the user to explicitly 1156 * initiate the call. 1157 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1158 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1159 * number. 1160 * <p>Output: nothing. 1161 */ 1162 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1163 public static final String ACTION_DIAL = "android.intent.action.DIAL"; 1164 /** 1165 * Activity Action: Perform a call to someone specified by the data. 1166 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1167 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1168 * number. 1169 * <p>Output: nothing. 1170 * 1171 * <p>Note: there will be restrictions on which applications can initiate a 1172 * call; most applications should use the {@link #ACTION_DIAL}. 1173 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency 1174 * numbers. Applications can <strong>dial</strong> emergency numbers using 1175 * {@link #ACTION_DIAL}, however. 1176 * 1177 * <p>Note: This Intent can only be used to dial call forwarding MMI codes if the application 1178 * using this intent is set as the default or system dialer. The system will treat any other 1179 * application using this Intent for the purpose of dialing call forwarding MMI codes as if the 1180 * {@link #ACTION_DIAL} Intent was used instead. 1181 * 1182 * <p>Note: An app filling the {@link android.app.role.RoleManager#ROLE_DIALER} role should use 1183 * {@link android.telecom.TelecomManager#placeCall(Uri, Bundle)} to place calls rather than 1184 * relying on this intent. 1185 * 1186 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M} 1187 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE} 1188 * permission which is not granted, then attempting to use this action will 1189 * result in a {@link java.lang.SecurityException}. 1190 */ 1191 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1192 public static final String ACTION_CALL = "android.intent.action.CALL"; 1193 /** 1194 * Activity Action: Perform a call to an emergency number specified by the 1195 * data. 1196 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1197 * tel: URI of an explicit phone number. 1198 * <p>Output: nothing. 1199 * 1200 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on 1201 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} 1202 * extra (if specified) and may be placed on another {@link PhoneAccount} with the 1203 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external 1204 * factors, such as network conditions and Modem/SIM status. 1205 * @hide 1206 */ 1207 @SystemApi 1208 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1209 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; 1210 /** 1211 * Activity Action: Dial a emergency number specified by the data. This shows a 1212 * UI with the number being dialed, allowing the user to explicitly 1213 * initiate the call. 1214 * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData} 1215 * is a tel: URI of an explicit emergency phone number. 1216 * <p>Output: nothing. 1217 * @hide 1218 */ 1219 @SystemApi 1220 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1221 public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY"; 1222 /** 1223 * Activity action: Perform a call to any number (emergency or not) 1224 * specified by the data. 1225 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1226 * tel: URI of an explicit phone number. 1227 * <p>Output: nothing. 1228 * @hide 1229 */ 1230 @SystemApi 1231 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1232 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; 1233 1234 /** 1235 * Activity Action: Main entry point for carrier setup apps. 1236 * <p>Carrier apps that provide an implementation for this action may be invoked to configure 1237 * carrier service and typically require 1238 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to 1239 * fulfill their duties. 1240 */ 1241 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1242 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP"; 1243 /** 1244 * Activity Action: Send a message to someone specified by the data. 1245 * <p>Input: {@link #getData} is URI describing the target. 1246 * <p>Output: nothing. 1247 */ 1248 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1249 public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; 1250 /** 1251 * Activity Action: Deliver some data to someone else. Who the data is 1252 * being delivered to is not specified; it is up to the receiver of this 1253 * action to ask the user where the data should be sent. 1254 * <p> 1255 * When launching a SEND intent, you should usually wrap it in a chooser 1256 * (through {@link #createChooser}), which will give the proper interface 1257 * for the user to pick how to send your data and allow you to specify 1258 * a prompt indicating what they are doing. 1259 * <p> 1260 * Input: {@link #getType} is the MIME type of the data being sent. 1261 * get*Extra can have either a {@link #EXTRA_TEXT} 1262 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If 1263 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it 1264 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* 1265 * if the MIME type is unknown (this will only allow senders that can 1266 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can 1267 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve 1268 * your text with HTML formatting. 1269 * <p> 1270 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1271 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1272 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1273 * content: URIs and other advanced features of {@link ClipData}. If 1274 * using this approach, you still must supply the same data through the 1275 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1276 * for compatibility with old applications. If you don't set a ClipData, 1277 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1278 * <p> 1279 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1280 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1281 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1282 * be openable only as asset typed files using 1283 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1284 * <p> 1285 * Optional standard extras, which may be interpreted by some recipients as 1286 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1287 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1288 * <p> 1289 * Output: nothing. 1290 */ 1291 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1292 public static final String ACTION_SEND = "android.intent.action.SEND"; 1293 /** 1294 * Activity Action: Deliver multiple data to someone else. 1295 * <p> 1296 * Like {@link #ACTION_SEND}, except the data is multiple. 1297 * <p> 1298 * Input: {@link #getType} is the MIME type of the data being sent. 1299 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link 1300 * #EXTRA_STREAM} field, containing the data to be sent. If using 1301 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} 1302 * for clients to retrieve your text with HTML formatting. 1303 * <p> 1304 * Multiple types are supported, and receivers should handle mixed types 1305 * whenever possible. The right way for the receiver to check them is to 1306 * use the content resolver on each URI. The intent sender should try to 1307 * put the most concrete mime type in the intent type, but it can fall 1308 * back to {@literal <type>/*} or {@literal *}/* as needed. 1309 * <p> 1310 * e.g. if you are sending image/jpg and image/jpg, the intent's type can 1311 * be image/jpg, but if you are sending image/jpg and image/png, then the 1312 * intent's type should be image/*. 1313 * <p> 1314 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1315 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1316 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1317 * content: URIs and other advanced features of {@link ClipData}. If 1318 * using this approach, you still must supply the same data through the 1319 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1320 * for compatibility with old applications. If you don't set a ClipData, 1321 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1322 * <p> 1323 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1324 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1325 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1326 * be openable only as asset typed files using 1327 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1328 * <p> 1329 * Optional standard extras, which may be interpreted by some recipients as 1330 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1331 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1332 * <p> 1333 * Output: nothing. 1334 */ 1335 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1336 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; 1337 /** 1338 * Activity Action: Handle an incoming phone call. 1339 * <p>Input: nothing. 1340 * <p>Output: nothing. 1341 */ 1342 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1343 public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; 1344 /** 1345 * Activity Action: Insert an empty item into the given container. 1346 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1347 * in which to place the data. 1348 * <p>Output: URI of the new data that was created. 1349 */ 1350 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1351 public static final String ACTION_INSERT = "android.intent.action.INSERT"; 1352 /** 1353 * Activity Action: Create a new item in the given container, initializing it 1354 * from the current contents of the clipboard. 1355 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1356 * in which to place the data. 1357 * <p>Output: URI of the new data that was created. 1358 */ 1359 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1360 public static final String ACTION_PASTE = "android.intent.action.PASTE"; 1361 /** 1362 * Activity Action: Delete the given data from its container. 1363 * <p>Input: {@link #getData} is URI of data to be deleted. 1364 * <p>Output: nothing. 1365 */ 1366 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1367 public static final String ACTION_DELETE = "android.intent.action.DELETE"; 1368 /** 1369 * Activity Action: Run the data, whatever that means. 1370 * <p>Input: ? (Note: this is currently specific to the test harness.) 1371 * <p>Output: nothing. 1372 */ 1373 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1374 public static final String ACTION_RUN = "android.intent.action.RUN"; 1375 /** 1376 * Activity Action: Perform a data synchronization. 1377 * <p>Input: ? 1378 * <p>Output: ? 1379 */ 1380 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1381 public static final String ACTION_SYNC = "android.intent.action.SYNC"; 1382 /** 1383 * Activity Action: Pick an activity given an intent, returning the class 1384 * selected. 1385 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent 1386 * used with {@link PackageManager#queryIntentActivities} to determine the 1387 * set of activities from which to pick. 1388 * <p>Output: Class name of the activity that was selected. 1389 */ 1390 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1391 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; 1392 /** 1393 * Activity Action: Perform a search. 1394 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1395 * is the text to search for. If empty, simply 1396 * enter your search results Activity with the search UI activated. 1397 * <p>Output: nothing. 1398 */ 1399 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1400 public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; 1401 /** 1402 * Activity Action: Start the platform-defined tutorial 1403 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1404 * is the text to search for. If empty, simply 1405 * enter your search results Activity with the search UI activated. 1406 * <p>Output: nothing. 1407 */ 1408 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1409 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; 1410 /** 1411 * Activity Action: Perform a web search. 1412 * <p> 1413 * Input: {@link android.app.SearchManager#QUERY 1414 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is 1415 * a url starts with http or https, the site will be opened. If it is plain 1416 * text, Google search will be applied. 1417 * <p> 1418 * Output: nothing. 1419 */ 1420 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1421 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; 1422 1423 /** 1424 * Activity Action: Perform assist action. 1425 * <p> 1426 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1427 * additional optional contextual information about where the user was when they 1428 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer 1429 * information. 1430 * Output: nothing. 1431 */ 1432 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1433 public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; 1434 1435 /** 1436 * Activity Action: Perform voice assist action. 1437 * <p> 1438 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1439 * additional optional contextual information about where the user was when they 1440 * requested the voice assist. 1441 * Output: nothing. 1442 * @hide 1443 */ 1444 @SystemApi 1445 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1446 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; 1447 1448 /** 1449 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground 1450 * application package at the time the assist was invoked. 1451 */ 1452 public static final String EXTRA_ASSIST_PACKAGE 1453 = "android.intent.extra.ASSIST_PACKAGE"; 1454 1455 /** 1456 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground 1457 * application package at the time the assist was invoked. 1458 */ 1459 public static final String EXTRA_ASSIST_UID 1460 = "android.intent.extra.ASSIST_UID"; 1461 1462 /** 1463 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual 1464 * information supplied by the current foreground app at the time of the assist request. 1465 * This is a {@link Bundle} of additional data. 1466 */ 1467 public static final String EXTRA_ASSIST_CONTEXT 1468 = "android.intent.extra.ASSIST_CONTEXT"; 1469 1470 /** 1471 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a 1472 * keyboard as the primary input device for assistance. 1473 */ 1474 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = 1475 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; 1476 1477 /** 1478 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id 1479 * that was used to invoke the assist. 1480 */ 1481 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = 1482 "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; 1483 1484 /** 1485 * Activity Action: List all available applications. 1486 * <p>Input: Nothing. 1487 * <p>Output: nothing. 1488 */ 1489 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1490 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; 1491 1492 /** 1493 * Activity Action: Action to show the list of all work apps in the launcher. For example, 1494 * shows the work apps folder or tab. 1495 * 1496 * <p>Input: Nothing. 1497 * <p>Output: nothing. 1498 */ 1499 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1500 public static final String ACTION_SHOW_WORK_APPS = 1501 "android.intent.action.SHOW_WORK_APPS"; 1502 1503 /** 1504 * Activity Action: Show settings for choosing wallpaper. 1505 * <p>Input: Nothing. 1506 * <p>Output: Nothing. 1507 */ 1508 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1509 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; 1510 1511 /** 1512 * Activity Action: Show activity for reporting a bug. 1513 * <p>Input: Nothing. 1514 * <p>Output: Nothing. 1515 */ 1516 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1517 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; 1518 1519 /** 1520 * Activity Action: Main entry point for factory tests. Only used when 1521 * the device is booting in factory test node. The implementing package 1522 * must be installed in the system image. 1523 * <p>Input: nothing 1524 * <p>Output: nothing 1525 */ 1526 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1527 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; 1528 1529 /** 1530 * Activity Action: The user pressed the "call" button to go to the dialer 1531 * or other appropriate UI for placing a call. 1532 * <p>Input: Nothing. 1533 * <p>Output: Nothing. 1534 */ 1535 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1536 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; 1537 1538 /** 1539 * Activity Action: Start Voice Command. 1540 * <p>Input: Nothing. 1541 * <p>Output: Nothing. 1542 * <p class="note"> 1543 * In some cases, a matching Activity may not exist, so ensure you 1544 * safeguard against this. 1545 */ 1546 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1547 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; 1548 1549 /** 1550 * Activity Action: Start action associated with long pressing on the 1551 * search key. 1552 * <p>Input: Nothing. 1553 * <p>Output: Nothing. 1554 */ 1555 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1556 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; 1557 1558 /** 1559 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. 1560 * This intent is delivered to the package which installed the application, usually 1561 * Google Play. 1562 * <p>Input: No data is specified. The bug report is passed in using 1563 * an {@link #EXTRA_BUG_REPORT} field. 1564 * <p>Output: Nothing. 1565 * 1566 * @see #EXTRA_BUG_REPORT 1567 */ 1568 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1569 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; 1570 1571 /** 1572 * An incident or bug report has been taken, and a system app has requested it to be shared, 1573 * so trigger the confirmation screen. 1574 * 1575 * This will be sent directly to the registered receiver with the 1576 * android.permission.APPROVE_INCIDENT_REPORTS permission. 1577 * @hide 1578 */ 1579 @SystemApi 1580 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED = 1581 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED"; 1582 1583 /** 1584 * An incident report has been taken, and the user has approved it for sharing. 1585 * <p> 1586 * This will be sent directly to the registered receiver, which must have 1587 * both the DUMP and USAGE_STATS permissions. 1588 * <p> 1589 * After receiving this, the application should wait until a suitable time 1590 * (e.g. network available), get the list of available reports with 1591 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)} 1592 * and then when the reports have been successfully uploaded, call 1593 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}. 1594 * 1595 * @hide 1596 */ 1597 @SystemApi 1598 public static final String ACTION_INCIDENT_REPORT_READY = 1599 "android.intent.action.INCIDENT_REPORT_READY"; 1600 1601 /** 1602 * Activity Action: Show power usage information to the user. 1603 * <p>Input: Nothing. 1604 * <p>Output: Nothing. 1605 */ 1606 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1607 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; 1608 1609 /** 1610 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs 1611 * to run. 1612 * <p>Input: Nothing. 1613 * <p>Output: Nothing. 1614 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified 1615 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD} 1616 * @hide 1617 * @removed 1618 */ 1619 @Deprecated 1620 @SystemApi 1621 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = 1622 "android.intent.action.DEVICE_INITIALIZATION_WIZARD"; 1623 1624 /** 1625 * Activity Action: Setup wizard to launch after a platform update. This 1626 * activity should have a string meta-data field associated with it, 1627 * {@link #METADATA_SETUP_VERSION}, which defines the current version of 1628 * the platform for setup. The activity will be launched only if 1629 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the 1630 * same value. 1631 * <p>Input: Nothing. 1632 * <p>Output: Nothing. 1633 * @hide 1634 */ 1635 @SystemApi 1636 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1637 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; 1638 1639 /** 1640 * Activity Action: Start the Keyboard Shortcuts Helper screen. 1641 * <p>Input: Nothing. 1642 * <p>Output: Nothing. 1643 * @hide 1644 */ 1645 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1646 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = 1647 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; 1648 1649 /** 1650 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. 1651 * <p>Input: Nothing. 1652 * <p>Output: Nothing. 1653 * @hide 1654 */ 1655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1656 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = 1657 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; 1658 1659 /** 1660 * Activity Action: Show settings for managing network data usage of a 1661 * specific application. Applications should define an activity that offers 1662 * options to control data usage. 1663 */ 1664 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1665 public static final String ACTION_MANAGE_NETWORK_USAGE = 1666 "android.intent.action.MANAGE_NETWORK_USAGE"; 1667 1668 /** 1669 * Activity Action: Launch application installer. 1670 * <p> 1671 * Input: The data must be a content: URI at which the application 1672 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, 1673 * you can also use "package:<package-name>" to install an application for the 1674 * current user that is already installed for another user. You can optionally supply 1675 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, 1676 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. 1677 * <p> 1678 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1679 * succeeded. 1680 * <p> 1681 * <strong>Note:</strong>If your app is targeting API level higher than 25 you 1682 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} 1683 * in order to launch the application installer. 1684 * </p> 1685 * 1686 * @see #EXTRA_INSTALLER_PACKAGE_NAME 1687 * @see #EXTRA_NOT_UNKNOWN_SOURCE 1688 * @see #EXTRA_RETURN_RESULT 1689 * 1690 * @deprecated use {@link android.content.pm.PackageInstaller} instead 1691 */ 1692 @Deprecated 1693 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1694 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; 1695 1696 /** 1697 * Activity Action: Activity to handle split installation failures. 1698 * <p>Splits may be installed dynamically. This happens when an Activity is launched, 1699 * but the split that contains the application isn't installed. When a split is 1700 * installed in this manner, the containing package usually doesn't know this is 1701 * happening. However, if an error occurs during installation, the containing 1702 * package can define a single activity handling this action to deal with such 1703 * failures. 1704 * <p>The activity handling this action must be in the base package. 1705 * <p> 1706 * Input: {@link #EXTRA_INTENT} the original intent that started split installation. 1707 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed. 1708 */ 1709 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1710 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE"; 1711 1712 /** 1713 * Activity Action: Launch instant application installer. 1714 * <p class="note"> 1715 * This is a protected intent that can only be sent by the system. 1716 * </p> 1717 * 1718 * @hide 1719 */ 1720 @SystemApi 1721 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1722 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE 1723 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE"; 1724 1725 /** 1726 * Service Action: Resolve instant application. 1727 * <p> 1728 * The system will have a persistent connection to this service. 1729 * This is a protected intent that can only be sent by the system. 1730 * </p> 1731 * 1732 * @hide 1733 */ 1734 @SystemApi 1735 @SdkConstant(SdkConstantType.SERVICE_ACTION) 1736 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE 1737 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; 1738 1739 /** 1740 * Activity Action: Launch instant app settings. 1741 * 1742 * <p class="note"> 1743 * This is a protected intent that can only be sent by the system. 1744 * </p> 1745 * 1746 * @hide 1747 */ 1748 @SystemApi 1749 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1750 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS 1751 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS"; 1752 1753 /** 1754 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1755 * package. Specifies the installer package name; this package will receive the 1756 * {@link #ACTION_APP_ERROR} intent. 1757 */ 1758 public static final String EXTRA_INSTALLER_PACKAGE_NAME 1759 = "android.intent.extra.INSTALLER_PACKAGE_NAME"; 1760 1761 /** 1762 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1763 * package. Specifies that the application being installed should not be 1764 * treated as coming from an unknown source, but as coming from the app 1765 * invoking the Intent. For this to work you must start the installer with 1766 * startActivityForResult(). 1767 */ 1768 public static final String EXTRA_NOT_UNKNOWN_SOURCE 1769 = "android.intent.extra.NOT_UNKNOWN_SOURCE"; 1770 1771 /** 1772 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and 1773 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent 1774 * data field originated from. 1775 */ 1776 public static final String EXTRA_ORIGINATING_URI 1777 = "android.intent.extra.ORIGINATING_URI"; 1778 1779 /** 1780 * This extra can be used with any Intent used to launch an activity, supplying information 1781 * about who is launching that activity. This field contains a {@link android.net.Uri} 1782 * object, typically an http: or https: URI of the web site that the referral came from; 1783 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify 1784 * a native application that it came from. 1785 * 1786 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} 1787 * instead of directly retrieving the extra. It is also valid for applications to 1788 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create 1789 * a string, not a Uri; the field here, if supplied, will always take precedence, 1790 * however.</p> 1791 * 1792 * @see #EXTRA_REFERRER_NAME 1793 */ 1794 public static final String EXTRA_REFERRER 1795 = "android.intent.extra.REFERRER"; 1796 1797 /** 1798 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather 1799 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can 1800 * not be created, in particular when Intent extras are supplied through the 1801 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} 1802 * schemes. 1803 * 1804 * @see #EXTRA_REFERRER 1805 */ 1806 public static final String EXTRA_REFERRER_NAME 1807 = "android.intent.extra.REFERRER_NAME"; 1808 1809 /** 1810 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and 1811 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install 1812 * Currently only a system app that hosts the provider authority "downloads" or holds the 1813 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this. 1814 * @hide 1815 */ 1816 @SystemApi 1817 public static final String EXTRA_ORIGINATING_UID 1818 = "android.intent.extra.ORIGINATING_UID"; 1819 1820 /** 1821 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1822 * package. Tells the installer UI to skip the confirmation with the user 1823 * if the .apk is replacing an existing one. 1824 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android 1825 * will no longer show an interstitial message about updating existing 1826 * applications so this is no longer needed. 1827 */ 1828 @Deprecated 1829 public static final String EXTRA_ALLOW_REPLACE 1830 = "android.intent.extra.ALLOW_REPLACE"; 1831 1832 /** 1833 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or 1834 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should 1835 * return to the application the result code of the install/uninstall. The returned result 1836 * code will be {@link android.app.Activity#RESULT_OK} on success or 1837 * {@link android.app.Activity#RESULT_FIRST_USER} on failure. 1838 */ 1839 public static final String EXTRA_RETURN_RESULT 1840 = "android.intent.extra.RETURN_RESULT"; 1841 1842 /** 1843 * Package manager install result code. @hide because result codes are not 1844 * yet ready to be exposed. 1845 */ 1846 @SystemApi 1847 public static final String EXTRA_INSTALL_RESULT = "android.intent.extra.INSTALL_RESULT"; 1848 1849 /** 1850 * Activity Action: Launch application uninstaller. 1851 * <p> 1852 * Input: The data must be a package: URI whose scheme specific part is 1853 * the package name of the current installed package to be uninstalled. 1854 * You can optionally supply {@link #EXTRA_RETURN_RESULT}. 1855 * <p> 1856 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the uninstall 1857 * succeeded. 1858 * <p> 1859 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} 1860 * since {@link Build.VERSION_CODES#P}. 1861 * 1862 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)} 1863 * instead 1864 */ 1865 @Deprecated 1866 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1867 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; 1868 1869 /** 1870 * Specify whether the package should be uninstalled for all users. 1871 * @hide because these should not be part of normal application flow. 1872 */ 1873 @SystemApi 1874 public static final String EXTRA_UNINSTALL_ALL_USERS 1875 = "android.intent.extra.UNINSTALL_ALL_USERS"; 1876 1877 /** 1878 * A string that associates with a metadata entry, indicating the last run version of the 1879 * platform that was setup. 1880 * 1881 * @see #ACTION_UPGRADE_SETUP 1882 * 1883 * @hide 1884 */ 1885 @SystemApi 1886 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; 1887 1888 /** 1889 * Activity action: Launch UI to manage the permissions of an app. 1890 * <p> 1891 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions 1892 * will be managed by the launched UI. 1893 * </p> 1894 * <p> 1895 * Output: Nothing. 1896 * </p> 1897 * 1898 * @see #EXTRA_PACKAGE_NAME 1899 * 1900 * @hide 1901 * @deprecated Use {@link android.provider.Settings#ACTION_APP_PERMISSIONS_SETTINGS} 1902 * instead. 1903 */ 1904 @Deprecated 1905 @SystemApi 1906 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1907 public static final String ACTION_MANAGE_APP_PERMISSIONS = 1908 "android.intent.action.MANAGE_APP_PERMISSIONS"; 1909 1910 /** 1911 * Activity action: Launch UI to manage a specific permission group of an app. 1912 * <p> 1913 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission 1914 * will be managed by the launched UI. 1915 * </p> 1916 * <p> 1917 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission 1918 * whose group should be managed by the launched UI. 1919 * </p> 1920 * <p> 1921 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group 1922 * that should be managed by the launched UI. Do not send both this and EXTRA_PERMISSION_NAME 1923 * together. 1924 * </p> 1925 * <p> 1926 * <li> {@link #EXTRA_USER} specifies the {@link UserHandle} of the user that owns the app. 1927 * </p> 1928 * <p> 1929 * Output: Nothing. 1930 * </p> 1931 * 1932 * @see #EXTRA_PACKAGE_NAME 1933 * @see #EXTRA_PERMISSION_NAME 1934 * @see #EXTRA_PERMISSION_GROUP_NAME 1935 * @see #EXTRA_USER 1936 * 1937 * @hide 1938 */ 1939 @SystemApi 1940 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 1941 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1942 public static final String ACTION_MANAGE_APP_PERMISSION = 1943 "android.intent.action.MANAGE_APP_PERMISSION"; 1944 1945 /** 1946 * Activity action: Launch UI to manage permissions. 1947 * <p> 1948 * Input: Nothing. 1949 * </p> 1950 * <p> 1951 * Output: Nothing. 1952 * </p> 1953 * 1954 * @hide 1955 */ 1956 @SystemApi 1957 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1958 public static final String ACTION_MANAGE_PERMISSIONS = 1959 "android.intent.action.MANAGE_PERMISSIONS"; 1960 1961 /** 1962 * Activity action: Launch UI to manage auto-revoke state. 1963 * 1964 * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS 1965 * 1966 * <p> 1967 * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with 1968 * a package name, whose auto-revoke state will be reviewed (mandatory). 1969 * E.g. {@code Uri.fromParts("package", packageName, null) } 1970 * </p> 1971 * <p> 1972 * Output: Nothing. 1973 * </p> 1974 */ 1975 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1976 public static final String ACTION_AUTO_REVOKE_PERMISSIONS = 1977 "android.intent.action.AUTO_REVOKE_PERMISSIONS"; 1978 1979 /** 1980 * Activity action: Launch UI to manage unused apps (hibernated apps). 1981 * 1982 * <p> 1983 * Input: Nothing. 1984 * </p> 1985 * <p> 1986 * Output: Nothing. 1987 * </p> 1988 */ 1989 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1990 public static final String ACTION_MANAGE_UNUSED_APPS = 1991 "android.intent.action.MANAGE_UNUSED_APPS"; 1992 1993 /** 1994 * Activity action: Launch UI to review permissions for an app. 1995 * The system uses this intent if permission review for apps not 1996 * supporting the new runtime permissions model is enabled. In 1997 * this mode a permission review is required before any of the 1998 * app components can run. 1999 * <p> 2000 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose 2001 * permissions will be reviewed (mandatory). 2002 * </p> 2003 * <p> 2004 * Input: {@link #EXTRA_INTENT} specifies a pending intent to 2005 * be fired after the permission review (optional). 2006 * </p> 2007 * <p> 2008 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to 2009 * be invoked after the permission review (optional). 2010 * </p> 2011 * <p> 2012 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent 2013 * passed via {@link #EXTRA_INTENT} needs a result (optional). 2014 * </p> 2015 * <p> 2016 * Output: Nothing. 2017 * </p> 2018 * 2019 * @see #EXTRA_PACKAGE_NAME 2020 * @see #EXTRA_INTENT 2021 * @see #EXTRA_REMOTE_CALLBACK 2022 * @see #EXTRA_RESULT_NEEDED 2023 * 2024 * @hide 2025 */ 2026 @SystemApi 2027 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2028 public static final String ACTION_REVIEW_PERMISSIONS = 2029 "android.intent.action.REVIEW_PERMISSIONS"; 2030 2031 /** 2032 * Activity action: Launch UI to show information about the usage 2033 * of a given permission group. This action would be handled by apps that 2034 * want to show details about how and why given permission group is being 2035 * used. 2036 * <p> 2037 * <strong>Important:</strong>You must protect the activity that handles 2038 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE 2039 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the 2040 * system can launch this activity. The system will not launch 2041 * activities that are not properly protected. 2042 * 2043 * <p> 2044 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group 2045 * for which the launched UI would be targeted. 2046 * </p> 2047 * <p> 2048 * Output: Nothing. 2049 * </p> 2050 */ 2051 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2052 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2053 public static final String ACTION_VIEW_PERMISSION_USAGE = 2054 "android.intent.action.VIEW_PERMISSION_USAGE"; 2055 2056 /** 2057 * Activity action: Launch UI to show information about the usage of a given permission group in 2058 * a given period. This action would be handled by apps that want to show details about how and 2059 * why given permission group is being used. 2060 * <p> 2061 * <strong>Important:</strong>You must protect the activity that handles this action with the 2062 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that 2063 * only the system can launch this activity. The system will not launch activities that are not 2064 * properly protected. 2065 * 2066 * <p> 2067 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for which the 2068 * launched UI would be targeted. 2069 * </p> 2070 * <p> 2071 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry. 2072 * </p> 2073 * <p> 2074 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in 2075 * millis). Both start time and end time are needed and start time must be <= end time. 2076 * </p> 2077 * <p> 2078 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in 2079 * millis). Both start time and end time are needed and start time must be <= end time. 2080 * </p> 2081 * <p> 2082 * Output: Nothing. 2083 * </p> 2084 */ 2085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2086 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2087 public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD = 2088 "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD"; 2089 2090 /** 2091 * Activity action: Launch the Safety Center Quick Settings UI. 2092 * 2093 * <p> 2094 * Input: Nothing. 2095 * </p> 2096 * <p> 2097 * Output: Nothing. 2098 * </p> 2099 * 2100 * @hide 2101 */ 2102 @SystemApi 2103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2104 @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) 2105 public static final String ACTION_VIEW_SAFETY_CENTER_QS = 2106 "android.intent.action.VIEW_SAFETY_CENTER_QS"; 2107 2108 /** 2109 * Activity action: Launch UI to manage a default app. 2110 * <p> 2111 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed 2112 * by the launched UI. 2113 * </p> 2114 * <p> 2115 * Output: Nothing. 2116 * </p> 2117 * 2118 * @hide 2119 */ 2120 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2122 @SystemApi 2123 public static final String ACTION_MANAGE_DEFAULT_APP = 2124 "android.intent.action.MANAGE_DEFAULT_APP"; 2125 2126 /** 2127 * Intent extra: A role name. 2128 * <p> 2129 * Type: String 2130 * </p> 2131 * 2132 * @see android.app.role.RoleManager 2133 * 2134 * @hide 2135 */ 2136 @SystemApi 2137 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME"; 2138 2139 /** 2140 * Activity action: Launch UI to manage special app accesses. 2141 * <p> 2142 * Input: Nothing. 2143 * </p> 2144 * <p> 2145 * Output: Nothing. 2146 * </p> 2147 * 2148 * @hide 2149 */ 2150 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2151 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2152 @SystemApi 2153 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES = 2154 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES"; 2155 2156 /** 2157 * Intent extra: A callback for reporting remote result as a bundle. 2158 * <p> 2159 * Type: IRemoteCallback 2160 * </p> 2161 * 2162 * @hide 2163 */ 2164 @SystemApi 2165 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; 2166 2167 /** 2168 * Intent extra: An app package name. 2169 * <p> 2170 * Type: String 2171 * </p> 2172 * 2173 */ 2174 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; 2175 2176 /** 2177 * Intent extra: A {@link android.os.LocaleList} 2178 * <p> 2179 * Type: LocaleList 2180 * </p> 2181 */ 2182 public static final String EXTRA_LOCALE_LIST = "android.intent.extra.LOCALE_LIST"; 2183 2184 /** 2185 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an 2186 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}. 2187 * 2188 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the 2189 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}. 2190 * This is meant to enable the suspended app to better handle the state of being suspended. 2191 * 2192 * @see #ACTION_MY_PACKAGE_SUSPENDED 2193 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2194 * @see PackageManager#isPackageSuspended() 2195 * @see PackageManager#getSuspendedPackageAppExtras() 2196 */ 2197 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS"; 2198 2199 /** 2200 * Intent extra: An app split name. 2201 * <p> 2202 * Type: String 2203 * </p> 2204 */ 2205 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; 2206 2207 /** 2208 * Intent extra: A {@link ComponentName} value. 2209 * <p> 2210 * Type: String 2211 * </p> 2212 */ 2213 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME"; 2214 2215 /** 2216 * Intent extra: An extra for specifying whether a result is needed. 2217 * <p> 2218 * Type: boolean 2219 * </p> 2220 * 2221 * @hide 2222 */ 2223 @SystemApi 2224 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; 2225 2226 /** 2227 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with 2228 * {@link #ACTION_SEND}. 2229 * 2230 * @see ShortcutInfo#getId() 2231 * 2232 * <p> 2233 * Type: String 2234 * </p> 2235 */ 2236 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID"; 2237 2238 /** 2239 * Activity action: Launch UI to manage which apps have a given permission. 2240 * <p> 2241 * Input: {@link #EXTRA_PERMISSION_NAME} or {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the 2242 * permission group which will be managed by the launched UI. 2243 * </p> 2244 * <p> 2245 * Output: Nothing. 2246 * </p> 2247 * 2248 * @see #EXTRA_PERMISSION_NAME 2249 * @see #EXTRA_PERMISSION_GROUP_NAME 2250 * 2251 * @hide 2252 */ 2253 @SystemApi 2254 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2255 public static final String ACTION_MANAGE_PERMISSION_APPS = 2256 "android.intent.action.MANAGE_PERMISSION_APPS"; 2257 2258 /** 2259 * Intent extra: The name of a permission. 2260 * <p> 2261 * Type: String 2262 * </p> 2263 * 2264 * @hide 2265 */ 2266 @SystemApi 2267 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; 2268 2269 /** 2270 * Intent extra: The name of a permission group. 2271 * <p> 2272 * Type: String 2273 * </p> 2274 */ 2275 public static final String EXTRA_PERMISSION_GROUP_NAME = 2276 "android.intent.extra.PERMISSION_GROUP_NAME"; 2277 2278 /** 2279 * Intent extra: The number of milliseconds. 2280 * <p> 2281 * Type: long 2282 * </p> 2283 */ 2284 public static final String EXTRA_DURATION_MILLIS = 2285 "android.intent.extra.DURATION_MILLIS"; 2286 2287 /** 2288 * Activity action: Launch UI to review app uses of permissions. 2289 * <p> 2290 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name 2291 * that will be displayed by the launched UI. Do not pass both this and 2292 * {@link #EXTRA_PERMISSION_GROUP_NAME} . 2293 * </p> 2294 * <p> 2295 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2296 * that will be displayed by the launched UI. Do not pass both this and 2297 * {@link #EXTRA_PERMISSION_NAME}. 2298 * </p> 2299 * <p> 2300 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2301 * activity to show (optional). Must be non-negative. 2302 * </p> 2303 * <p> 2304 * Output: Nothing. 2305 * </p> 2306 * <p class="note"> 2307 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2308 * </p> 2309 * 2310 * @see #EXTRA_PERMISSION_NAME 2311 * @see #EXTRA_PERMISSION_GROUP_NAME 2312 * @see #EXTRA_DURATION_MILLIS 2313 * 2314 * @hide 2315 */ 2316 @SystemApi 2317 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2319 public static final String ACTION_REVIEW_PERMISSION_USAGE = 2320 "android.intent.action.REVIEW_PERMISSION_USAGE"; 2321 2322 /** 2323 * Activity action: Launch UI to review the timeline history of permissions. 2324 * <p> 2325 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2326 * that will be displayed by the launched UI. 2327 * </p> 2328 * <p> 2329 * Output: Nothing. 2330 * </p> 2331 * <p class="note"> 2332 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2333 * </p> 2334 * 2335 * @see #EXTRA_PERMISSION_GROUP_NAME 2336 * 2337 * @hide 2338 */ 2339 @SystemApi 2340 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2341 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2342 public static final String ACTION_REVIEW_PERMISSION_HISTORY = 2343 "android.intent.action.REVIEW_PERMISSION_HISTORY"; 2344 2345 /** 2346 * Activity action: Launch UI to review ongoing app uses of permissions. 2347 * <p> 2348 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2349 * activity to show (optional). Must be non-negative. 2350 * </p> 2351 * <p> 2352 * Output: Nothing. 2353 * </p> 2354 * <p class="note"> 2355 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2356 * </p> 2357 * 2358 * @see #EXTRA_DURATION_MILLIS 2359 * 2360 * @hide 2361 */ 2362 @SystemApi 2363 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2364 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2365 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE = 2366 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE"; 2367 2368 /** 2369 * Activity action: Launch UI to review running accessibility services. 2370 * <p> 2371 * Input: Nothing. 2372 * </p> 2373 * <p> 2374 * Output: Nothing. 2375 * </p> 2376 * 2377 * @hide 2378 */ 2379 @SystemApi 2380 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES) 2381 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2382 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES = 2383 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"; 2384 2385 /** 2386 * Activity action: Launch UI to manage the usage of a given permission group. 2387 * This action would be handled by apps that want to show controls about the features 2388 * which use the permission group. 2389 * 2390 * <p> 2391 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for 2392 * which the launched UI would be targeted. 2393 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry. 2394 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in 2395 * millis). If both start time and end time are present, start time must be <= end time. 2396 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in 2397 * millis). If the end time is empty, that implies that the permission usage is still in use. 2398 * If both start time and end time are present, start time must be <= end time. 2399 * Input: {@link #EXTRA_SHOWING_ATTRIBUTION} specifies whether the subattribution was shown 2400 * in the UI. 2401 * </p> 2402 * <p> 2403 * Output: Nothing. 2404 * </p> 2405 * <p class="note"> 2406 * You must protect the activity that handles this action with the 2407 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that 2408 * only the system can launch this activity. The system will not launch activities 2409 * that are not properly protected. 2410 * </p> 2411 * 2412 * @see #EXTRA_PERMISSION_GROUP_NAME 2413 * @see #EXTRA_ATTRIBUTION_TAGS 2414 * @see #EXTRA_START_TIME 2415 * @see #EXTRA_END_TIME 2416 * @see #EXTRA_SHOWING_ATTRIBUTION 2417 * 2418 * @hide 2419 */ 2420 @SystemApi 2421 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2422 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2423 public static final String ACTION_MANAGE_PERMISSION_USAGE = 2424 "android.intent.action.MANAGE_PERMISSION_USAGE"; 2425 2426 /** 2427 * Activity action: Launch UI to view the app's feature's information. 2428 * 2429 * <p> 2430 * Output: Nothing. 2431 * </p> 2432 * <p class="note"> 2433 * You must protect the activity that handles this action with the 2434 * {@link android.Manifest.permission#START_VIEW_APP_FEATURES} permission to ensure that 2435 * only the system can launch this activity. The system will not launch activities 2436 * that are not properly protected. 2437 * 2438 * An optional <meta-data> tag in the activity's manifest with 2439 * android:name=app_features_preference_summary and android:resource=@string/<string name> will 2440 * be used to add a summary line for the "All Services" preference in settings. 2441 * </p> 2442 * @hide 2443 */ 2444 @SystemApi 2445 @RequiresPermission(android.Manifest.permission.START_VIEW_APP_FEATURES) 2446 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2447 public static final String ACTION_VIEW_APP_FEATURES = 2448 "android.intent.action.VIEW_APP_FEATURES"; 2449 2450 /** 2451 * Activity action: Launch UI to open the Safety Center, which highlights the user's security 2452 * and privacy status. 2453 */ 2454 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2455 public static final String ACTION_SAFETY_CENTER = 2456 "android.intent.action.SAFETY_CENTER"; 2457 2458 /** 2459 * Activity action: Launch the UI to view recent updates that installed apps have made to their 2460 * data sharing policy in their safety labels. 2461 * 2462 * <p> 2463 * Input: Nothing. 2464 * </p> 2465 * <p> 2466 * Output: Nothing. 2467 * </p> 2468 * 2469 * <p class="note"> 2470 * This intent action requires the {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} 2471 * permission. 2472 * </p> 2473 * 2474 * @hide 2475 */ 2476 @SystemApi 2477 @RequiresPermission(Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2478 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2479 public static final String ACTION_REVIEW_APP_DATA_SHARING_UPDATES = 2480 "android.intent.action.REVIEW_APP_DATA_SHARING_UPDATES"; 2481 2482 // --------------------------------------------------------------------- 2483 // --------------------------------------------------------------------- 2484 // Standard intent broadcast actions (see action variable). 2485 2486 /** 2487 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. 2488 * <p> 2489 * For historical reasons, the name of this broadcast action refers to the power 2490 * state of the screen but it is actually sent in response to changes in the 2491 * overall interactive state of the device. 2492 * </p><p> 2493 * This broadcast is sent when the device becomes non-interactive which may have 2494 * nothing to do with the screen turning off. To determine the 2495 * actual state of the screen, use {@link android.view.Display#getState}. 2496 * </p><p> 2497 * See {@link android.os.PowerManager#isInteractive} for details. 2498 * </p> 2499 * You <em>cannot</em> receive this through components declared in 2500 * manifests, only by explicitly registering for it with 2501 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2502 * Context.registerReceiver()}. 2503 * 2504 * <p class="note">This is a protected intent that can only be sent 2505 * by the system. 2506 */ 2507 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2508 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; 2509 2510 /** 2511 * Broadcast Action: Sent when the device wakes up and becomes interactive. 2512 * <p> 2513 * For historical reasons, the name of this broadcast action refers to the power 2514 * state of the screen but it is actually sent in response to changes in the 2515 * overall interactive state of the device. 2516 * </p><p> 2517 * This broadcast is sent when the device becomes interactive which may have 2518 * nothing to do with the screen turning on. To determine the 2519 * actual state of the screen, use {@link android.view.Display#getState}. 2520 * </p><p> 2521 * See {@link android.os.PowerManager#isInteractive} for details. 2522 * </p> 2523 * You <em>cannot</em> receive this through components declared in 2524 * manifests, only by explicitly registering for it with 2525 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2526 * Context.registerReceiver()}. 2527 * 2528 * <p class="note">This is a protected intent that can only be sent 2529 * by the system. 2530 */ 2531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2532 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; 2533 2534 /** 2535 * Broadcast Action: Sent after the system stops dreaming. 2536 * 2537 * <p class="note">This is a protected intent that can only be sent by the system. 2538 * It is only sent to registered receivers.</p> 2539 */ 2540 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2541 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; 2542 2543 /** 2544 * Broadcast Action: Sent after the system starts dreaming. 2545 * 2546 * <p class="note">This is a protected intent that can only be sent by the system. 2547 * It is only sent to registered receivers.</p> 2548 */ 2549 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2550 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; 2551 2552 /** 2553 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the 2554 * keyguard is gone). 2555 * 2556 * <p class="note">This is a protected intent that can only be sent 2557 * by the system. 2558 */ 2559 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2560 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; 2561 2562 /** 2563 * Broadcast Action: The current time has changed. Sent every 2564 * minute. You <em>cannot</em> receive this through components declared 2565 * in manifests, only by explicitly registering for it with 2566 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2567 * Context.registerReceiver()}. 2568 * 2569 * <p class="note">This is a protected intent that can only be sent 2570 * by the system. 2571 */ 2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2573 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; 2574 /** 2575 * Broadcast Action: The time was set. 2576 */ 2577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2578 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; 2579 /** 2580 * Broadcast Action: The date has changed. 2581 */ 2582 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2583 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; 2584 /** 2585 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> 2586 * <ul> 2587 * <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new 2588 * time zone.</li> 2589 * </ul> 2590 * 2591 * <p class="note">This is a protected intent that can only be sent 2592 * by the system. 2593 */ 2594 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2595 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; 2596 /** 2597 * Alarm Changed Action: This is broadcast when the AlarmClock 2598 * application's alarm is set or unset. It is used by the 2599 * AlarmClock application and the StatusBar service. 2600 * @hide 2601 */ 2602 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2603 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2604 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; 2605 2606 /** 2607 * Broadcast Action: This is broadcast once, after the user has finished 2608 * booting, but while still in the "locked" state. It can be used to perform 2609 * application-specific initialization, such as installing alarms. You must 2610 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} 2611 * permission in order to receive this broadcast. 2612 * <p> 2613 * This broadcast is sent immediately at boot by all devices (regardless of 2614 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or 2615 * higher. Upon receipt of this broadcast, the user is still locked and only 2616 * device-protected storage can be accessed safely. If you want to access 2617 * credential-protected storage, you need to wait for the user to be 2618 * unlocked (typically by entering their lock pattern or PIN for the first 2619 * time), after which the {@link #ACTION_USER_UNLOCKED} and 2620 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. 2621 * <p> 2622 * To receive this broadcast, your receiver component must be marked as 2623 * being {@link ComponentInfo#directBootAware}. 2624 * <p class="note"> 2625 * This is a protected intent that can only be sent by the system. 2626 * 2627 * @see Context#createDeviceProtectedStorageContext() 2628 */ 2629 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2630 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; 2631 2632 /** 2633 * Broadcast Action: This is broadcast once, after the user has finished 2634 * booting. It can be used to perform application-specific initialization, 2635 * such as installing alarms. You must hold the 2636 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in 2637 * order to receive this broadcast. 2638 * <p> 2639 * This broadcast is sent at boot by all devices (both with and without 2640 * direct boot support). Upon receipt of this broadcast, the user is 2641 * unlocked and both device-protected and credential-protected storage can 2642 * accessed safely. 2643 * <p> 2644 * If you need to run while the user is still locked (before they've entered 2645 * their lock pattern or PIN for the first time), you can listen for the 2646 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. 2647 * <p class="note"> 2648 * This is a protected intent that can only be sent by the system. 2649 */ 2650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2651 @BroadcastBehavior(includeBackground = true) 2652 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; 2653 2654 /** 2655 * Broadcast Action: This is broadcast when a user action should request a 2656 * temporary system dialog to dismiss. Some examples of temporary system 2657 * dialogs are the notification window-shade and the recent tasks dialog. 2658 * 2659 * @deprecated This intent is deprecated for third-party applications starting from Android 2660 * {@link Build.VERSION_CODES#S} for security reasons. Unauthorized usage by applications 2661 * will result in the broadcast intent being dropped for apps targeting API level less than 2662 * {@link Build.VERSION_CODES#S} and in a {@link SecurityException} for apps targeting SDK 2663 * level {@link Build.VERSION_CODES#S} or higher. Instrumentation initiated from the shell 2664 * (eg. tests) is still able to use the intent. The platform will automatically collapse 2665 * the proper system dialogs in the proper use-cases. For all others, the user is the one in 2666 * control of closing dialogs. 2667 * 2668 * @see AccessibilityService#GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE 2669 */ 2670 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2671 @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS) 2672 @Deprecated 2673 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; 2674 /** 2675 * Broadcast Action: Trigger the download and eventual installation 2676 * of a package. 2677 * <p>Input: {@link #getData} is the URI of the package file to download. 2678 * 2679 * <p class="note">This is a protected intent that can only be sent 2680 * by the system. 2681 * 2682 * @deprecated This constant has never been used. 2683 */ 2684 @Deprecated 2685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2686 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; 2687 /** 2688 * Broadcast Action: A new application package has been installed on the 2689 * device. The data contains the name of the package. Note that the 2690 * newly installed package does <em>not</em> receive this broadcast. 2691 * <p>May include the following extras: 2692 * <ul> 2693 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2694 * <li> {@link #EXTRA_REPLACING} is set to true if this is following 2695 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. 2696 * </ul> 2697 * 2698 * <p class="note">This is a protected intent that can only be sent 2699 * by the system. 2700 */ 2701 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2702 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; 2703 /** 2704 * Broadcast Action: A new version of an application package has been 2705 * installed, replacing an existing version that was previously installed. 2706 * The data contains the name of the package. 2707 * <p>May include the following extras: 2708 * <ul> 2709 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2710 * </ul> 2711 * 2712 * <p class="note">This is a protected intent that can only be sent 2713 * by the system. 2714 */ 2715 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2716 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; 2717 /** 2718 * Broadcast Action: A new version of your application has been installed 2719 * over an existing one. This is only sent to the application that was 2720 * replaced. It does not contain any additional data; to receive it, just 2721 * use an intent filter for this action. 2722 * 2723 * <p class="note">This is a protected intent that can only be sent 2724 * by the system. 2725 */ 2726 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2727 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; 2728 /** 2729 * Broadcast Action: An existing application package has been removed from 2730 * the device. The data contains the name of the package. The package 2731 * that is being removed does <em>not</em> receive 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 that the application 2740 * was removed with the user-initiated action. 2741 * </ul> 2742 * 2743 * <p class="note">This is a protected intent that can only be sent 2744 * by the system. 2745 */ 2746 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2747 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; 2748 /** 2749 * Broadcast Action: An existing application package has been removed from 2750 * the device. The data contains the name of the package and the visibility 2751 * allow list. The package that is being removed does <em>not</em> receive 2752 * this Intent. 2753 * <ul> 2754 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2755 * to the package. 2756 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2757 * application -- data and code -- is being removed. 2758 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2759 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2760 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal 2761 * that the application was removed with the user-initiated action. 2762 * <li> {@link #EXTRA_VISIBILITY_ALLOW_LIST} containing an int array to 2763 * indicate the visibility allow list. 2764 * </ul> 2765 * 2766 * <p class="note">This is a protected intent that can only be sent 2767 * by the system. 2768 * 2769 * @hide This broadcast is used internally by the system. 2770 */ 2771 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2772 public static final String ACTION_PACKAGE_REMOVED_INTERNAL = 2773 "android.intent.action.PACKAGE_REMOVED_INTERNAL"; 2774 /** 2775 * Broadcast Action: An existing application package has been completely 2776 * removed from the device. The data contains the name of the package. 2777 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when 2778 * {@link #EXTRA_DATA_REMOVED} is true and 2779 * {@link #EXTRA_REPLACING} is false of that broadcast. 2780 * 2781 * <ul> 2782 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2783 * to the package. 2784 * </ul> 2785 * 2786 * <p class="note">This is a protected intent that can only be sent 2787 * by the system. 2788 */ 2789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2790 public static final String ACTION_PACKAGE_FULLY_REMOVED 2791 = "android.intent.action.PACKAGE_FULLY_REMOVED"; 2792 /** 2793 * Broadcast Action: An existing application package has been changed (for 2794 * example, a component has been enabled or disabled). The data contains 2795 * the name of the package. 2796 * <ul> 2797 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2798 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name 2799 * of the changed components (or the package name itself). 2800 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the 2801 * default action of restarting the application. 2802 * </ul> 2803 * 2804 * <p class="note">This is a protected intent that can only be sent 2805 * by the system. 2806 */ 2807 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2808 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; 2809 2810 /** 2811 * Broadcast Action: An application package that was previously in the stopped state has been 2812 * started and is no longer considered stopped. 2813 * <p>When a package is force-stopped, the {@link #ACTION_PACKAGE_RESTARTED} broadcast is sent 2814 * and the package in the stopped state cannot self-start for any reason unless there's an 2815 * explicit request to start a component in the package. The {@link #ACTION_PACKAGE_UNSTOPPED} 2816 * broadcast is sent when such an explicit process start occurs and the package is taken 2817 * out of the stopped state. The data contains the name of the package. 2818 * </p> 2819 * <ul> 2820 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2821 * <li> {@link #EXTRA_TIME} containing the {@link SystemClock#elapsedRealtime() 2822 * elapsed realtime} of when the package was unstopped. 2823 * </ul> 2824 * 2825 * <p class="note">This is a protected intent that can only be sent by the system. 2826 * 2827 * @see ApplicationInfo#FLAG_STOPPED 2828 * @see #ACTION_PACKAGE_RESTARTED 2829 */ 2830 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2831 @FlaggedApi(android.content.pm.Flags.FLAG_STAY_STOPPED) 2832 public static final String ACTION_PACKAGE_UNSTOPPED = "android.intent.action.PACKAGE_UNSTOPPED"; 2833 2834 /** 2835 * Broadcast Action: Sent to the system rollback manager when a package 2836 * needs to have rollback enabled. 2837 * <p class="note"> 2838 * This is a protected intent that can only be sent by the system. 2839 * </p> 2840 * 2841 * @hide This broadcast is used internally by the system. 2842 */ 2843 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2844 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK = 2845 "android.intent.action.PACKAGE_ENABLE_ROLLBACK"; 2846 /** 2847 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain 2848 * package needs to be cancelled. 2849 * 2850 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager 2851 * that enabling a specific rollback has timed out. 2852 * 2853 * @hide 2854 */ 2855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2856 public static final String ACTION_CANCEL_ENABLE_ROLLBACK = 2857 "android.intent.action.CANCEL_ENABLE_ROLLBACK"; 2858 /** 2859 * Broadcast Action: A rollback has been committed. 2860 * 2861 * <p class="note">This is a protected intent that can only be sent 2862 * by the system. The receiver must hold MANAGE_ROLLBACK permission. 2863 * 2864 * @hide 2865 */ 2866 @SystemApi 2867 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2868 public static final String ACTION_ROLLBACK_COMMITTED = 2869 "android.intent.action.ROLLBACK_COMMITTED"; 2870 /** 2871 * @hide 2872 * Broadcast Action: Ask system services if there is any reason to 2873 * restart the given package. The data contains the name of the 2874 * package. 2875 * <ul> 2876 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2877 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. 2878 * </ul> 2879 * 2880 * <p class="note">This is a protected intent that can only be sent 2881 * by the system. 2882 */ 2883 @SystemApi 2884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2885 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; 2886 /** 2887 * Broadcast Action: The user has restarted a package, and all of its 2888 * processes have been killed. All runtime state 2889 * associated with it (processes, alarms, notifications, etc) should 2890 * be removed. Note that the restarted package does <em>not</em> 2891 * receive this broadcast. 2892 * The data contains the name of the package. 2893 * <ul> 2894 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2895 * </ul> 2896 * 2897 * <p class="note">This is a protected intent that can only be sent 2898 * by the system. 2899 * <p> 2900 * Starting in Android V, an extra timestamp 2901 * {@link #EXTRA_TIME} is included with this broadcast to indicate the exact time the package 2902 * was restarted, in {@link SystemClock#elapsedRealtime() elapsed realtime}. 2903 * </p> 2904 */ 2905 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2906 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; 2907 2908 /** 2909 * Broadcast Action: The user has cleared the data of a package. This should 2910 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of 2911 * its persistent data is erased and this broadcast sent. 2912 * Note that the cleared package does <em>not</em> 2913 * receive this broadcast. The data contains the name of the package. 2914 * <ul> 2915 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the 2916 * package whose data was cleared is an uninstalled instant app, then the UID 2917 * will be -1. The platform keeps some meta-data associated with instant apps 2918 * after they are uninstalled. 2919 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared 2920 * data was for an instant app. 2921 * </ul> 2922 * 2923 * <p class="note">This is a protected intent that can only be sent 2924 * by the system. 2925 */ 2926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2927 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; 2928 /** 2929 * Broadcast Action: Packages have been suspended. 2930 * <p>Includes the following extras: 2931 * <ul> 2932 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended 2933 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended 2934 * </ul> 2935 * 2936 * <p class="note">This is a protected intent that can only be sent 2937 * by the system. It is only sent to registered receivers. 2938 */ 2939 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2940 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; 2941 /** 2942 * Broadcast Action: Packages have been unsuspended. 2943 * <p>Includes the following extras: 2944 * <ul> 2945 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended 2946 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended 2947 * </ul> 2948 * 2949 * <p class="note">This is a protected intent that can only be sent 2950 * by the system. It is only sent to registered receivers. 2951 */ 2952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2953 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; 2954 /** 2955 * Broadcast Action: One of the suspend conditions have been modified for the packages. 2956 * <p>Includes the following extras: 2957 * <ul> 2958 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been modified 2959 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been modified 2960 * </ul> 2961 * 2962 * <p class="note">This is a protected intent that can only be sent 2963 * by the system. It is only sent to registered receivers. 2964 * 2965 * @hide 2966 */ 2967 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2968 public static final String ACTION_PACKAGES_SUSPENSION_CHANGED = 2969 "android.intent.action.PACKAGES_SUSPENSION_CHANGED"; 2970 2971 /** 2972 * Broadcast Action: Distracting packages have been changed. 2973 * <p>Includes the following extras: 2974 * <ul> 2975 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed. 2976 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed. 2977 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages. 2978 * </ul> 2979 * 2980 * <p class="note">This is a protected intent that can only be sent 2981 * by the system. It is only sent to registered receivers. 2982 * 2983 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 2984 * @hide 2985 */ 2986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2987 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED = 2988 "android.intent.action.DISTRACTING_PACKAGES_CHANGED"; 2989 2990 /** 2991 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent 2992 * whenever a package is put into a suspended state or any of its app extras change while in the 2993 * suspended state. 2994 * <p> Optionally includes the following extras: 2995 * <ul> 2996 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain 2997 * useful information for the app being suspended. 2998 * </ul> 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 #ACTION_MY_PACKAGE_UNSUSPENDED 3004 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 3005 * @see PackageManager#isPackageSuspended() 3006 * @see PackageManager#getSuspendedPackageAppExtras() 3007 */ 3008 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3009 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED"; 3010 3011 /** 3012 * Activity Action: Started to show more details about why an application was suspended. 3013 * 3014 * <p>Whenever the system detects an activity launch for a suspended app, this action can 3015 * be used to show more details about the reason for suspension. 3016 * 3017 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity 3018 * handling this intent and protect it with 3019 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}. 3020 * 3021 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package. 3022 * 3023 * <p class="note">This is a protected intent that can only be sent 3024 * by the system. 3025 * 3026 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 3027 * PersistableBundle, String) 3028 * @see PackageManager#isPackageSuspended() 3029 * @see #ACTION_PACKAGES_SUSPENDED 3030 * 3031 * @hide 3032 */ 3033 @SystemApi 3034 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 3035 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS = 3036 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS"; 3037 3038 /** 3039 * Broadcast Action: Sent to indicate that the user unsuspended a package. 3040 * 3041 * <p>This can happen when the user taps on the neutral button of the 3042 * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using 3043 * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the 3044 * suspending app that originally specified this dialog while calling 3045 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 3046 * PersistableBundle, SuspendDialogInfo)}. 3047 * 3048 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just 3049 * got unsuspended. 3050 * 3051 * <p class="note">This is a protected intent that can only be sent 3052 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 3053 * the manifest.</em> 3054 * 3055 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 3056 * PersistableBundle, SuspendDialogInfo) 3057 * @see PackageManager#isPackageSuspended() 3058 * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS 3059 * @hide 3060 */ 3061 @SystemApi 3062 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3063 public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY = 3064 "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY"; 3065 3066 /** 3067 * Broadcast Action: Sent to a package that has been unsuspended. 3068 * 3069 * <p class="note">This is a protected intent that can only be sent 3070 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 3071 * the manifest.</em> 3072 * 3073 * @see #ACTION_MY_PACKAGE_SUSPENDED 3074 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 3075 * @see PackageManager#isPackageSuspended() 3076 * @see PackageManager#getSuspendedPackageAppExtras() 3077 */ 3078 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3079 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED"; 3080 3081 /** 3082 * Broadcast Action: A uid has been removed from the system. The uid 3083 * number is stored in the extra data under {@link #EXTRA_UID}. 3084 * 3085 * In certain instances, {@link #EXTRA_REPLACING} is set to true if the UID is not being 3086 * fully removed. 3087 * 3088 * <p class="note">This is a protected intent that can only be sent 3089 * by the system. 3090 */ 3091 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3092 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; 3093 3094 /** 3095 * Broadcast Action: Sent to the installer package of an application when 3096 * that application is first launched (that is the first time it is moved 3097 * out of the stopped state). The data contains the name of the package. 3098 * 3099 * <p>When the application is first launched, the application itself doesn't receive this 3100 * broadcast.</p> 3101 * 3102 * <p class="note">This is a protected intent that can only be sent 3103 * by the system. 3104 */ 3105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3106 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; 3107 3108 /** 3109 * Broadcast Action: Sent to the system package verifier when a package 3110 * needs to be verified. The data contains the package URI. 3111 * <p class="note"> 3112 * This is a protected intent that can only be sent by the system. 3113 * </p> 3114 */ 3115 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3116 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; 3117 3118 /** 3119 * Broadcast Action: Sent to the system package verifier when a package is 3120 * verified. The data contains the package URI. 3121 * <p class="note"> 3122 * This is a protected intent that can only be sent by the system. 3123 */ 3124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3125 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; 3126 3127 /** 3128 * Broadcast Action: Sent to the system intent filter verifier when an 3129 * intent filter needs to be verified. The data contains the filter data 3130 * hosts to be verified against. 3131 * <p class="note"> 3132 * This is a protected intent that can only be sent by the system. 3133 * </p> 3134 * 3135 * @hide 3136 * @deprecated Superseded by domain verification APIs. See {@link DomainVerificationManager}. 3137 */ 3138 @Deprecated 3139 @SystemApi 3140 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3141 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = 3142 "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; 3143 3144 3145 /** 3146 * Broadcast Action: Sent to the system domain verification agent when an app's domains need 3147 * to be verified. The data contains the domains hosts to be verified against. 3148 * <p class="note"> 3149 * This is a protected intent that can only be sent by the system. 3150 * </p> 3151 * 3152 * @hide 3153 */ 3154 @SystemApi 3155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3156 public static final String ACTION_DOMAINS_NEED_VERIFICATION = 3157 "android.intent.action.DOMAINS_NEED_VERIFICATION"; 3158 3159 /** 3160 * Broadcast Action: Resources for a set of packages (which were 3161 * previously unavailable) are currently 3162 * available since the media on which they exist is available. 3163 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 3164 * list of packages whose availability changed. 3165 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 3166 * list of uids of packages whose availability changed. 3167 * Note that the 3168 * packages in this list do <em>not</em> receive this broadcast. 3169 * The specified set of packages are now available on the system. 3170 * <p>Includes the following extras: 3171 * <ul> 3172 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 3173 * whose resources(were previously unavailable) are currently available. 3174 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the 3175 * packages whose resources(were previously unavailable) 3176 * are currently available. 3177 * </ul> 3178 * 3179 * <p class="note">This is a protected intent that can only be sent 3180 * by the system. 3181 */ 3182 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3183 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = 3184 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; 3185 3186 /** 3187 * Broadcast Action: Resources for a set of packages are currently 3188 * unavailable since the media on which they exist is unavailable. 3189 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 3190 * list of packages whose availability changed. 3191 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 3192 * list of uids of packages whose availability changed. 3193 * The specified set of packages can no longer be 3194 * launched and are practically unavailable on the system. 3195 * <p>Inclues the following extras: 3196 * <ul> 3197 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 3198 * whose resources are no longer available. 3199 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages 3200 * whose resources are no longer available. 3201 * </ul> 3202 * 3203 * <p class="note">This is a protected intent that can only be sent 3204 * by the system. 3205 */ 3206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3207 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = 3208 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; 3209 3210 /** 3211 * Broadcast Action: preferred activities have changed *explicitly*. 3212 * 3213 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. 3214 * when an app is installed or uninstalled, but in such cases this broadcast will *not* 3215 * be sent. 3216 * 3217 * {@link #EXTRA_USER_HANDLE} contains the user ID in question. 3218 * 3219 * @hide 3220 */ 3221 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3222 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = 3223 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; 3224 3225 3226 /** 3227 * Broadcast Action: The current system wallpaper has changed. See 3228 * {@link android.app.WallpaperManager} for retrieving the new wallpaper. 3229 * This should <em>only</em> be used to determine when the wallpaper 3230 * has changed to show the new wallpaper to the user. You should certainly 3231 * never, in response to this, change the wallpaper or other attributes of 3232 * it such as the suggested size. That would be unexpected, right? You'd cause 3233 * all kinds of loops, especially if other apps are doing similar things, 3234 * right? Of course. So please don't do this. 3235 * 3236 * @deprecated Modern applications should use 3237 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER 3238 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper 3239 * shown behind their UI, rather than watching for this broadcast and 3240 * rendering the wallpaper on their own. 3241 */ 3242 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3243 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; 3244 /** 3245 * Broadcast Action: The current device {@link android.content.res.Configuration} 3246 * (orientation, locale, etc) has changed. When such a change happens, the 3247 * UIs (view hierarchy) will need to be rebuilt based on this new 3248 * information; for the most part, applications don't need to worry about 3249 * this, because the system will take care of stopping and restarting the 3250 * application to make sure it sees the new changes. Some system code that 3251 * can not be restarted will need to watch for this action and handle it 3252 * appropriately. 3253 * 3254 * <p class="note"> 3255 * You <em>cannot</em> receive this through components declared 3256 * in manifests, only by explicitly registering for it with 3257 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3258 * Context.registerReceiver()}. 3259 * 3260 * <p class="note">This is a protected intent that can only be sent 3261 * by the system. 3262 * 3263 * @see android.content.res.Configuration 3264 */ 3265 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3266 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; 3267 3268 /** 3269 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed 3270 * such that the device may be eligible for the installation of additional configuration splits. 3271 * Configuration properties that can trigger this broadcast include locale and display density. 3272 * 3273 * <p class="note"> 3274 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through 3275 * components declared in manifests. However, the receiver <em>must</em> hold the 3276 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. 3277 * 3278 * <p class="note"> 3279 * This is a protected intent that can only be sent by the system. 3280 * 3281 * @hide 3282 */ 3283 @SystemApi 3284 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3285 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = 3286 "android.intent.action.SPLIT_CONFIGURATION_CHANGED"; 3287 /** 3288 * Broadcast Action: The receiver's effective locale has changed. 3289 * 3290 * This happens when the device locale, the receiving app's locale 3291 * (set via {@link android.app.LocaleManager#setApplicationLocales}) or language tags 3292 * of Regional preferences changed. 3293 * 3294 * Can be received by manifest-declared receivers. 3295 * 3296 * <p class="note"> If only the app locale changed, includes the following extras: 3297 * <ul> 3298 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed. 3299 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app 3300 * </ul> 3301 * 3302 * <p class="note">This is a protected intent that can only be sent 3303 * by the system. 3304 */ 3305 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3306 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; 3307 /** 3308 * Broadcast Action: Locale of a particular app has changed. 3309 * 3310 * <p class="note"> This broadcast is explicitly sent to the 3311 * {@link android.content.pm.InstallSourceInfo#getInstallingPackageName} installer 3312 * of the app whose locale has changed. 3313 * <p class="note"> The broadcast could also be received by manifest-declared receivers with 3314 * {@code android.permission.READ_APP_SPECIFIC_LOCALES} 3315 * 3316 * <p class="note">This is a protected intent that can only be sent 3317 * by the system. 3318 * 3319 * <p>Includes the following extras: 3320 * <ul> 3321 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed. 3322 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app 3323 * </ul> 3324 */ 3325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3326 public static final String ACTION_APPLICATION_LOCALE_CHANGED = 3327 "android.intent.action.APPLICATION_LOCALE_CHANGED"; 3328 /** 3329 * Broadcast Action: This is a <em>sticky broadcast</em> containing the 3330 * charging state, level, and other information about the battery. 3331 * See {@link android.os.BatteryManager} for documentation on the 3332 * contents of the Intent. 3333 * 3334 * <p class="note"> 3335 * You <em>cannot</em> receive this through components declared 3336 * in manifests, only by explicitly registering for it with 3337 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3338 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, 3339 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, 3340 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related 3341 * broadcasts that are sent and can be received through manifest 3342 * receivers. 3343 * 3344 * <p class="note">This is a protected intent that can only be sent 3345 * by the system. 3346 */ 3347 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3348 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; 3349 3350 3351 /** 3352 * Broadcast Action: Sent when the current battery level or plug type changes. 3353 * 3354 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle} 3355 * instances representing individual battery level changes with associated 3356 * extras from {@link #ACTION_BATTERY_CHANGED}. 3357 * 3358 * <p class="note"> 3359 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission. 3360 * 3361 * @hide 3362 */ 3363 @SystemApi 3364 public static final String ACTION_BATTERY_LEVEL_CHANGED = 3365 "android.intent.action.BATTERY_LEVEL_CHANGED"; 3366 /** 3367 * Broadcast Action: Indicates low battery condition on the device. 3368 * This broadcast corresponds to the "Low battery warning" system dialog. 3369 * 3370 * <p class="note">This is a protected intent that can only be sent 3371 * by the system. 3372 */ 3373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3374 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; 3375 /** 3376 * Broadcast Action: Indicates the battery is now okay after being low. 3377 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has 3378 * gone back up to an okay state. 3379 * 3380 * <p class="note">This is a protected intent that can only be sent 3381 * by the system. 3382 */ 3383 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3384 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; 3385 /** 3386 * Broadcast Action: External power has been connected to the device. 3387 * This is intended for applications that wish to register specifically to this notification. 3388 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3389 * stay active to receive this notification. This action can be used to implement actions 3390 * that wait until power is available to trigger. 3391 * 3392 * <p class="note">This is a protected intent that can only be sent 3393 * by the system. 3394 */ 3395 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3396 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; 3397 /** 3398 * Broadcast Action: External power has been removed from the device. 3399 * This is intended for applications that wish to register specifically to this notification. 3400 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3401 * stay active to receive this notification. This action can be used to implement actions 3402 * that wait until power is available to trigger. 3403 * 3404 * <p class="note">This is a protected intent that can only be sent 3405 * by the system. 3406 */ 3407 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3408 public static final String ACTION_POWER_DISCONNECTED = 3409 "android.intent.action.ACTION_POWER_DISCONNECTED"; 3410 /** 3411 * Broadcast Action: Device is shutting down. 3412 * This is broadcast when the device is being shut down (completely turned 3413 * off, not sleeping). Once the broadcast is complete, the final shutdown 3414 * will proceed and all unsaved data lost. Apps will not normally need 3415 * to handle this, since the foreground activity will be paused as well. 3416 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered 3417 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3418 * Context.registerReceiver}. 3419 * 3420 * <p class="note">This is a protected intent that can only be sent 3421 * by the system. 3422 * <p>May include the following extras: 3423 * <ul> 3424 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this 3425 * shutdown is only for userspace processes. If not set, assumed to be false. 3426 * </ul> 3427 */ 3428 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3429 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; 3430 /** 3431 * Activity Action: Start this activity to request system shutdown. 3432 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true 3433 * to request confirmation from the user before shutting down. The optional boolean 3434 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to 3435 * indicate that the shutdown is requested by the user. 3436 * 3437 * <p class="note">This is a protected intent that can only be sent 3438 * by the system. 3439 * 3440 * {@hide} 3441 */ 3442 public static final String ACTION_REQUEST_SHUTDOWN 3443 = "com.android.internal.intent.action.REQUEST_SHUTDOWN"; 3444 /** 3445 * Broadcast Action: A sticky broadcast that indicates low storage space 3446 * condition on the device 3447 * <p class="note"> 3448 * This is a protected intent that can only be sent by the system. 3449 * 3450 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3451 * or above, this broadcast will no longer be delivered to any 3452 * {@link BroadcastReceiver} defined in your manifest. Instead, 3453 * apps are strongly encouraged to use the improved 3454 * {@link Context#getCacheDir()} behavior so the system can 3455 * automatically free up storage when needed. 3456 */ 3457 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3458 @Deprecated 3459 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; 3460 /** 3461 * Broadcast Action: Indicates low storage space condition on the device no 3462 * longer exists 3463 * <p class="note"> 3464 * This is a protected intent that can only be sent by the system. 3465 * 3466 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3467 * or above, this broadcast will no longer be delivered to any 3468 * {@link BroadcastReceiver} defined in your manifest. Instead, 3469 * apps are strongly encouraged to use the improved 3470 * {@link Context#getCacheDir()} behavior so the system can 3471 * automatically free up storage when needed. 3472 */ 3473 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3474 @Deprecated 3475 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; 3476 /** 3477 * Broadcast Action: A sticky broadcast that indicates a storage space full 3478 * condition on the device. This is intended for activities that want to be 3479 * able to fill the data partition completely, leaving only enough free 3480 * space to prevent system-wide SQLite failures. 3481 * <p class="note"> 3482 * This is a protected intent that can only be sent by the system. 3483 * 3484 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3485 * or above, this broadcast will no longer be delivered to any 3486 * {@link BroadcastReceiver} defined in your manifest. Instead, 3487 * apps are strongly encouraged to use the improved 3488 * {@link Context#getCacheDir()} behavior so the system can 3489 * automatically free up storage when needed. 3490 * @hide 3491 */ 3492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3493 @Deprecated 3494 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; 3495 /** 3496 * Broadcast Action: Indicates storage space full condition on the device no 3497 * longer exists. 3498 * <p class="note"> 3499 * This is a protected intent that can only be sent by the system. 3500 * 3501 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3502 * or above, this broadcast will no longer be delivered to any 3503 * {@link BroadcastReceiver} defined in your manifest. Instead, 3504 * apps are strongly encouraged to use the improved 3505 * {@link Context#getCacheDir()} behavior so the system can 3506 * automatically free up storage when needed. 3507 * @hide 3508 */ 3509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3510 @Deprecated 3511 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; 3512 /** 3513 * Broadcast Action: Indicates low memory condition notification acknowledged by user 3514 * and package management should be started. 3515 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW 3516 * notification. 3517 */ 3518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3519 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; 3520 /** 3521 * Broadcast Action: The device has entered USB Mass Storage mode. 3522 * This is used mainly for the USB Settings panel. 3523 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3524 * when the SD card file system is mounted or unmounted 3525 * @deprecated replaced by android.os.storage.StorageEventListener 3526 */ 3527 @Deprecated 3528 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3529 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; 3530 3531 /** 3532 * Broadcast Action: The device has exited USB Mass Storage mode. 3533 * This is used mainly for the USB Settings panel. 3534 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3535 * when the SD card file system is mounted or unmounted 3536 * @deprecated replaced by android.os.storage.StorageEventListener 3537 */ 3538 @Deprecated 3539 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3540 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; 3541 3542 /** 3543 * Broadcast Action: External media has been removed. 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_REMOVED = "android.intent.action.MEDIA_REMOVED"; 3548 3549 /** 3550 * Broadcast Action: External media is present, but not mounted at its mount point. 3551 * The path to the mount point for the unmounted media is contained in the Intent.mData field. 3552 */ 3553 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3554 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; 3555 3556 /** 3557 * Broadcast Action: External media is present, and being disk-checked 3558 * The path to the mount point for the checking media is contained in the Intent.mData field. 3559 */ 3560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3561 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; 3562 3563 /** 3564 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) 3565 * The path to the mount point for the checking media is contained in the Intent.mData field. 3566 */ 3567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3568 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; 3569 3570 /** 3571 * Broadcast Action: External media is present and mounted at its mount point. 3572 * The path to the mount point for the mounted media is contained in the Intent.mData field. 3573 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the 3574 * media was mounted read only. 3575 */ 3576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3577 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; 3578 3579 /** 3580 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. 3581 * The path to the mount point for the shared media is contained in the Intent.mData field. 3582 */ 3583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3584 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; 3585 3586 /** 3587 * Broadcast Action: External media is no longer being shared via USB mass storage. 3588 * The path to the mount point for the previously shared media is contained in the Intent.mData field. 3589 * 3590 * @hide 3591 */ 3592 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; 3593 3594 /** 3595 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. 3596 * The path to the mount point for the removed media is contained in the Intent.mData field. 3597 */ 3598 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3599 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; 3600 3601 /** 3602 * Broadcast Action: External media is present but cannot be mounted. 3603 * The path to the mount point for the unmountable media is contained in the Intent.mData field. 3604 */ 3605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3606 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; 3607 3608 /** 3609 * Broadcast Action: User has expressed the desire to remove the external storage media. 3610 * Applications should close all files they have open within the mount point when they receive this intent. 3611 * The path to the mount point for the media to be ejected is contained in the Intent.mData field. 3612 */ 3613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3614 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; 3615 3616 /** 3617 * Broadcast Action: The media scanner has started scanning a directory. 3618 * The path to the directory being scanned is contained in the Intent.mData field. 3619 */ 3620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3621 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; 3622 3623 /** 3624 * Broadcast Action: The media scanner has finished scanning a directory. 3625 * The path to the scanned directory is contained in the Intent.mData field. 3626 */ 3627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3628 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; 3629 3630 /** 3631 * Broadcast Action: Request the media scanner to scan a file and add it to 3632 * the media database. 3633 * <p> 3634 * The path to the file is contained in {@link Intent#getData()}. 3635 * 3636 * @deprecated Callers should migrate to inserting items directly into 3637 * {@link MediaStore}, where they will be automatically scanned 3638 * after each mutation. 3639 */ 3640 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3641 @Deprecated 3642 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; 3643 3644 /** 3645 * Broadcast Action: The "Media Button" was pressed. Includes a single 3646 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3647 * caused the broadcast. 3648 */ 3649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3650 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; 3651 3652 /** 3653 * Broadcast Action: The "Camera Button" was pressed. Includes a single 3654 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3655 * caused the broadcast. 3656 */ 3657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3658 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; 3659 3660 // *** NOTE: @todo(*) The following really should go into a more domain-specific 3661 // location; they are not general-purpose actions. 3662 3663 /** 3664 * Broadcast Action: A GTalk connection has been established. 3665 */ 3666 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3667 public static final String ACTION_GTALK_SERVICE_CONNECTED = 3668 "android.intent.action.GTALK_CONNECTED"; 3669 3670 /** 3671 * Broadcast Action: A GTalk connection has been disconnected. 3672 */ 3673 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3674 public static final String ACTION_GTALK_SERVICE_DISCONNECTED = 3675 "android.intent.action.GTALK_DISCONNECTED"; 3676 3677 /** 3678 * Broadcast Action: An input method has been changed. 3679 */ 3680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3681 public static final String ACTION_INPUT_METHOD_CHANGED = 3682 "android.intent.action.INPUT_METHOD_CHANGED"; 3683 3684 /** 3685 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or 3686 * more radios have been turned off or on. The intent will have the following extra value:</p> 3687 * <ul> 3688 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, 3689 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been 3690 * turned off</li> 3691 * </ul> 3692 * 3693 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3694 */ 3695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3696 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; 3697 3698 /** 3699 * Broadcast Action: Some content providers have parts of their namespace 3700 * where they publish new events or items that the user may be especially 3701 * interested in. For these things, they may broadcast this action when the 3702 * set of interesting items change. 3703 * 3704 * For example, GmailProvider sends this notification when the set of unread 3705 * mail in the inbox changes. 3706 * 3707 * <p>The data of the intent identifies which part of which provider 3708 * changed. When queried through the content resolver, the data URI will 3709 * return the data set in question. 3710 * 3711 * <p>The intent will have the following extra values: 3712 * <ul> 3713 * <li><em>count</em> - The number of items in the data set. This is the 3714 * same as the number of items in the cursor returned by querying the 3715 * data URI. </li> 3716 * </ul> 3717 * 3718 * This intent will be sent at boot (if the count is non-zero) and when the 3719 * data set changes. It is possible for the data set to change without the 3720 * count changing (for example, if a new unread message arrives in the same 3721 * sync operation in which a message is archived). The phone should still 3722 * ring/vibrate/etc as normal in this case. 3723 */ 3724 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3725 public static final String ACTION_PROVIDER_CHANGED = 3726 "android.intent.action.PROVIDER_CHANGED"; 3727 3728 /** 3729 * Broadcast Action: Wired Headset plugged in or unplugged. 3730 * 3731 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value 3732 * and documentation. 3733 * <p>If the minimum SDK version of your application is 3734 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer 3735 * to the <code>AudioManager</code> constant in your receiver registration code instead. 3736 */ 3737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3738 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG; 3739 3740 /** 3741 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> 3742 * <ul> 3743 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> 3744 * </ul> 3745 * 3746 * <p class="note">This is a protected intent that can only be sent 3747 * by the system. 3748 * 3749 * @hide 3750 */ 3751 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3752 public static final String ACTION_ADVANCED_SETTINGS_CHANGED 3753 = "android.intent.action.ADVANCED_SETTINGS"; 3754 3755 /** 3756 * Broadcast Action: Sent after application restrictions are changed. 3757 * 3758 * <p class="note">This is a protected intent that can only be sent 3759 * by the system.</p> 3760 */ 3761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3762 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = 3763 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; 3764 3765 /** 3766 * Broadcast Action: An outgoing call is about to be placed. 3767 * 3768 * <p>The Intent will have the following extra value:</p> 3769 * <ul> 3770 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - 3771 * the phone number originally intended to be dialed.</li> 3772 * </ul> 3773 * <p class="note">Starting in Android 15, this broadcast is no longer sent as an ordered 3774 * broadcast. The <code>resultData</code> no longer has any effect and will not determine the 3775 * actual routing of the call. Further, receivers of this broadcast do not get foreground 3776 * priority and cannot launch background activities.</p> 3777 * <p>Once the broadcast is finished, the resultData is used as the actual 3778 * number to call. If <code>null</code>, no call will be placed.</p> 3779 * <p>It is perfectly acceptable for multiple receivers to process the 3780 * outgoing call in turn: for example, a parental control application 3781 * might verify that the user is authorized to place the call at that 3782 * time, then a number-rewriting application might add an area code if 3783 * one was not specified.</p> 3784 * <p>For consistency, any receiver whose purpose is to prohibit phone 3785 * calls should have a priority of 0, to ensure it will see the final 3786 * phone number to be dialed. 3787 * Any receiver whose purpose is to rewrite phone numbers to be called 3788 * should have a positive priority. 3789 * Negative priorities are reserved for the system for this broadcast; 3790 * using them may cause problems.</p> 3791 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> 3792 * abort the broadcast.</p> 3793 * <p>Emergency calls cannot be intercepted using this mechanism, and 3794 * other calls cannot be modified to call emergency numbers using this 3795 * mechanism. 3796 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing 3797 * call to use their own service instead. Those apps should first prevent 3798 * the call from being placed by setting resultData to <code>null</code> 3799 * and then start their own app to make the call. 3800 * <p>You must hold the 3801 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} 3802 * permission to receive this Intent.</p> 3803 * 3804 * <p class="note">This is a protected intent that can only be sent 3805 * by the system. 3806 * 3807 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to 3808 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast. 3809 * This means that attempts to re-write the outgoing call by other apps using this intent will 3810 * be ignored. 3811 * </p> 3812 * 3813 * @deprecated Apps that redirect outgoing calls should use the 3814 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening 3815 * should use the {@link android.telecom.CallScreeningService} API. Apps which need to be 3816 * notified of basic call state should use 3817 * {@link android.telephony.TelephonyCallback.CallStateListener} to determine when a new 3818 * outgoing call is placed. 3819 */ 3820 @Deprecated 3821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3822 public static final String ACTION_NEW_OUTGOING_CALL = 3823 "android.intent.action.NEW_OUTGOING_CALL"; 3824 3825 /** 3826 * Broadcast Action: Have the device reboot. This is only for use by 3827 * system code. 3828 * 3829 * <p class="note">This is a protected intent that can only be sent 3830 * by the system. 3831 */ 3832 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3833 public static final String ACTION_REBOOT = 3834 "android.intent.action.REBOOT"; 3835 3836 /** 3837 * Broadcast Action: A sticky broadcast for changes in the physical 3838 * docking state of the device. 3839 * 3840 * <p>The intent will have the following extra values: 3841 * <ul> 3842 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock 3843 * state, indicating which dock the device is physically in.</li> 3844 * </ul> 3845 * <p>This is intended for monitoring the current physical dock state. 3846 * See {@link android.app.UiModeManager} for the normal API dealing with 3847 * dock mode changes. 3848 */ 3849 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3850 public static final String ACTION_DOCK_EVENT = 3851 "android.intent.action.DOCK_EVENT"; 3852 3853 /** 3854 * Broadcast Action: A broadcast when idle maintenance can be started. 3855 * This means that the user is not interacting with the device and is 3856 * not expected to do so soon. Typical use of the idle maintenance is 3857 * to perform somehow expensive tasks that can be postponed at a moment 3858 * when they will not degrade user experience. 3859 * <p> 3860 * <p class="note">In order to keep the device responsive in case of an 3861 * unexpected user interaction, implementations of a maintenance task 3862 * should be interruptible. In such a scenario a broadcast with action 3863 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you 3864 * should not do the maintenance work in 3865 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a 3866 * maintenance service by {@link Context#startService(Intent)}. Also 3867 * you should hold a wake lock while your maintenance service is running 3868 * to prevent the device going to sleep. 3869 * </p> 3870 * <p> 3871 * <p class="note">This is a protected intent that can only be sent by 3872 * the system. 3873 * </p> 3874 * 3875 * @see #ACTION_IDLE_MAINTENANCE_END 3876 * 3877 * @hide 3878 */ 3879 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3880 public static final String ACTION_IDLE_MAINTENANCE_START = 3881 "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; 3882 3883 /** 3884 * Broadcast Action: A broadcast when idle maintenance should be stopped. 3885 * This means that the user was not interacting with the device as a result 3886 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} 3887 * was sent and now the user started interacting with the device. Typical 3888 * use of the idle maintenance is to perform somehow expensive tasks that 3889 * can be postponed at a moment when they will not degrade user experience. 3890 * <p> 3891 * <p class="note">In order to keep the device responsive in case of an 3892 * unexpected user interaction, implementations of a maintenance task 3893 * should be interruptible. Hence, on receiving a broadcast with this 3894 * action, the maintenance task should be interrupted as soon as possible. 3895 * In other words, you should not do the maintenance work in 3896 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the 3897 * maintenance service that was started on receiving of 3898 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake 3899 * lock you acquired when your maintenance service started. 3900 * </p> 3901 * <p class="note">This is a protected intent that can only be sent 3902 * by the system. 3903 * 3904 * @see #ACTION_IDLE_MAINTENANCE_START 3905 * 3906 * @hide 3907 */ 3908 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3909 public static final String ACTION_IDLE_MAINTENANCE_END = 3910 "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; 3911 3912 /** 3913 * Broadcast Action: A broadcast sent to the main user when the main user changes their 3914 * Lock Screen Knowledge Factor, either because they changed the current value, or because 3915 * they added or removed it. 3916 * 3917 * <p class="note">At present, this intent is only broadcast to listeners with the 3918 * CONFIGURE_FACTORY_RESET_PROTECTION signature|privileged permiession.</p> 3919 * 3920 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3921 * 3922 * @hide 3923 */ 3924 @FlaggedApi(FLAG_FRP_ENFORCEMENT) 3925 @SystemApi 3926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3927 @BroadcastBehavior(protectedBroadcast = true) 3928 public static final String 3929 ACTION_MAIN_USER_LOCKSCREEN_KNOWLEDGE_FACTOR_CHANGED = 3930 "android.intent.action.MAIN_USER_LOCKSCREEN_KNOWLEDGE_FACTOR_CHANGED"; 3931 3932 /** 3933 * Broadcast Action: a remote intent is to be broadcasted. 3934 * 3935 * A remote intent is used for remote RPC between devices. The remote intent 3936 * is serialized and sent from one device to another device. The receiving 3937 * device parses the remote intent and broadcasts it. Note that anyone can 3938 * broadcast a remote intent. However, if the intent receiver of the remote intent 3939 * does not trust intent broadcasts from arbitrary intent senders, it should require 3940 * the sender to hold certain permissions so only trusted sender's broadcast will be 3941 * let through. 3942 * @hide 3943 */ 3944 public static final String ACTION_REMOTE_INTENT = 3945 "com.google.android.c2dm.intent.RECEIVE"; 3946 3947 /** 3948 * Broadcast Action: This is broadcast once when the user is booting after a 3949 * system update. It can be used to perform cleanup or upgrades after a 3950 * system update. 3951 * <p> 3952 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} 3953 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's 3954 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only 3955 * sent to receivers in the system image. 3956 * 3957 * @hide 3958 */ 3959 @SystemApi 3960 public static final String ACTION_PRE_BOOT_COMPLETED = 3961 "android.intent.action.PRE_BOOT_COMPLETED"; 3962 3963 /** 3964 * Broadcast to a specific application to query any supported restrictions to impose 3965 * on restricted users. The broadcast intent contains an extra 3966 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted 3967 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or 3968 * String[] depending on the restriction type.<p/> 3969 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, 3970 * which is of type <code>ArrayList<RestrictionEntry></code>. It can also 3971 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. 3972 * The activity specified by that intent will be launched for a result which must contain 3973 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. 3974 * The keys and values of the returned restrictions will be persisted. 3975 * @see RestrictionEntry 3976 */ 3977 public static final String ACTION_GET_RESTRICTION_ENTRIES = 3978 "android.intent.action.GET_RESTRICTION_ENTRIES"; 3979 3980 /** 3981 * Sent the first time a user is starting, to allow system apps to 3982 * perform one time initialization. (This will not be seen by third 3983 * party applications because a newly initialized user does not have any 3984 * third party applications installed for it.) This is sent early in 3985 * starting the user, around the time the home app is started, before 3986 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground 3987 * broadcast, since it is part of a visible user interaction; be as quick 3988 * as possible when handling it. 3989 * 3990 * <p><b>Note:</b> This broadcast is not sent to the system user. 3991 */ 3992 public static final String ACTION_USER_INITIALIZE = 3993 "android.intent.action.USER_INITIALIZE"; 3994 3995 /** 3996 * Sent after a user switch is complete, if the switch caused the process's user to be 3997 * brought to the foreground. This is only sent to receivers registered 3998 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3999 * Context.registerReceiver}. It is sent to the user that is going to the 4000 * foreground. This is sent as a foreground 4001 * broadcast, since it is part of a visible user interaction; be as quick 4002 * as possible when handling it. 4003 */ 4004 public static final String ACTION_USER_FOREGROUND = 4005 "android.intent.action.USER_FOREGROUND"; 4006 4007 /** 4008 * Sent after a user switch is complete, if the switch caused the process's user to be 4009 * sent to the background. This is only sent to receivers registered 4010 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 4011 * Context.registerReceiver}. It is sent to the user that is going to the 4012 * background. This is sent as a foreground 4013 * broadcast, since it is part of a visible user interaction; be as quick 4014 * as possible when handling it. 4015 */ 4016 public static final String ACTION_USER_BACKGROUND = 4017 "android.intent.action.USER_BACKGROUND"; 4018 4019 /** 4020 * Broadcast sent to the system when a user is added. 4021 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the new user 4022 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 4023 * user's user ID). 4024 * It is sent to all running users. 4025 * You must hold {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 4026 * @hide 4027 */ 4028 @SystemApi 4029 public static final String ACTION_USER_ADDED = 4030 "android.intent.action.USER_ADDED"; 4031 4032 /** 4033 * Broadcast sent by the system when a user is started. Carries an extra 4034 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only sent to 4035 * registered receivers, not manifest receivers. It is sent to the user 4036 * that has been started. This is sent as a foreground 4037 * broadcast, since it is part of a visible user interaction; be as quick 4038 * as possible when handling it. 4039 * 4040 * <p> 4041 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4042 * received. For example, the user could have been removed, started or stopped already, 4043 * regardless of which broadcast you receive. Because of that, receivers should always check 4044 * the current state of the user. 4045 * @hide 4046 */ 4047 public static final String ACTION_USER_STARTED = 4048 "android.intent.action.USER_STARTED"; 4049 4050 /** 4051 * Broadcast sent when a user is in the process of starting. Carries an extra 4052 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only 4053 * sent to registered receivers, not manifest receivers. It is sent to all 4054 * users (including the one that is being started). You must hold 4055 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 4056 * this broadcast. This is sent as a background broadcast, since 4057 * its result is not part of the primary UX flow; to safely keep track of 4058 * started/stopped state of a user you can use this in conjunction with 4059 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with 4060 * other user state broadcasts since those are foreground broadcasts so can 4061 * execute in a different order. 4062 * 4063 * <p> 4064 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4065 * received. For example, the user could have been removed, started or stopped already, 4066 * regardless of which broadcast you receive. Because of that, receivers should always check 4067 * the current state of the user. 4068 * @hide 4069 */ 4070 public static final String ACTION_USER_STARTING = 4071 "android.intent.action.USER_STARTING"; 4072 4073 /** 4074 * Broadcast sent when a user is going to be stopped. Carries an extra 4075 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only 4076 * sent to registered receivers, not manifest receivers. It is sent to all 4077 * users (including the one that is being stopped). You must hold 4078 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 4079 * this broadcast. The user will not stop until all receivers have 4080 * handled the broadcast. This is sent as a background broadcast, since 4081 * its result is not part of the primary UX flow; to safely keep track of 4082 * started/stopped state of a user you can use this in conjunction with 4083 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with 4084 * other user state broadcasts since those are foreground broadcasts so can 4085 * execute in a different order. 4086 * <p> 4087 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4088 * received. For example, the user could have been removed, started or stopped already, 4089 * regardless of which broadcast you receive. Because of that, receivers should always check 4090 * the current state of the user. 4091 * @hide 4092 */ 4093 public static final String ACTION_USER_STOPPING = 4094 "android.intent.action.USER_STOPPING"; 4095 4096 /** 4097 * Broadcast sent to the system when a user is stopped. Carries an extra 4098 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is similar to 4099 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a 4100 * specific package. This is only sent to registered receivers, not manifest 4101 * receivers. It is sent to all running users <em>except</em> the one that 4102 * has just been stopped (which is no longer running). 4103 * 4104 * <p> 4105 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4106 * received. For example, the user could have been removed, started or stopped already, 4107 * regardless of which broadcast you receive. Because of that, receivers should always check 4108 * the current state of the user. 4109 * @hide 4110 */ 4111 @TestApi 4112 public static final String ACTION_USER_STOPPED = 4113 "android.intent.action.USER_STOPPED"; 4114 4115 /** 4116 * Broadcast sent to the system when a user is removed. 4117 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the user that 4118 * was removed 4119 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 4120 * user's user ID). 4121 * It is sent to all running users except the 4122 * one that has been removed. The user will not be completely removed until all receivers have 4123 * handled the broadcast. You must hold 4124 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 4125 * @hide 4126 */ 4127 @SystemApi 4128 public static final String ACTION_USER_REMOVED = 4129 "android.intent.action.USER_REMOVED"; 4130 4131 /** 4132 * Broadcast sent to the system when the user switches. 4133 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} 4134 * of the user to become the current one 4135 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 4136 * user's user ID). 4137 * This is only sent to registered receivers, not manifest receivers. 4138 * It is sent to all running users. 4139 * You must hold 4140 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 4141 * 4142 * <p> 4143 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4144 * received. For example, the user could have been removed, started or stopped already, 4145 * regardless of which broadcast you receive. Because of that, receivers should always check 4146 * the current state of the user. 4147 * @hide 4148 */ 4149 /* 4150 * This broadcast is sent after the user switch is complete. In case a task needs to be done 4151 * while the switch is happening (i.e. while the screen is frozen to hide UI jank), please use 4152 * ActivityManagerService.registerUserSwitchObserver method. 4153 */ 4154 @SystemApi 4155 public static final String ACTION_USER_SWITCHED = 4156 "android.intent.action.USER_SWITCHED"; 4157 4158 /** 4159 * Broadcast Action: Sent when the credential-encrypted private storage has 4160 * become unlocked for the target user. This is only sent to registered 4161 * receivers, not manifest receivers. 4162 * 4163 * <p> 4164 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4165 * received. For example, the user could have been removed, started or stopped already, 4166 * regardless of which broadcast you receive. Because of that, receivers should always check 4167 * the current state of the user. 4168 */ 4169 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4170 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; 4171 4172 /** 4173 * Broadcast sent to the system when a user's information changes. Carries an extra 4174 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. 4175 * This is only sent to registered receivers, not manifest receivers. It is sent to all users. 4176 * @hide 4177 */ 4178 public static final String ACTION_USER_INFO_CHANGED = 4179 "android.intent.action.USER_INFO_CHANGED"; 4180 4181 /** 4182 * Broadcast sent to the primary user when an associated managed profile is added (the profile 4183 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies 4184 * the {@link UserHandle} of the profile that was added. Only applications (for example 4185 * Launchers) that need to display merged content across both primary and managed profiles need 4186 * to worry about this broadcast. This is only sent to registered receivers, 4187 * not manifest receivers. 4188 */ 4189 public static final String ACTION_MANAGED_PROFILE_ADDED = 4190 "android.intent.action.MANAGED_PROFILE_ADDED"; 4191 4192 /** 4193 * Broadcast sent to the primary user when an associated managed profile is removed. 4194 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile 4195 * that was removed. 4196 * Only applications (for example Launchers) that need to display merged content across both 4197 * primary and managed profiles need to worry about this broadcast. This is only sent to 4198 * registered receivers, not manifest receivers. 4199 */ 4200 public static final String ACTION_MANAGED_PROFILE_REMOVED = 4201 "android.intent.action.MANAGED_PROFILE_REMOVED"; 4202 4203 /** 4204 * Broadcast sent to the primary user when the credential-encrypted private storage for 4205 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that 4206 * specifies the {@link UserHandle} of the profile that was unlocked. Only applications (for 4207 * example Launchers) that need to display merged content across both primary and managed 4208 * profiles need to worry about this broadcast. This is only sent to registered receivers, 4209 * not manifest receivers. 4210 */ 4211 public static final String ACTION_MANAGED_PROFILE_UNLOCKED = 4212 "android.intent.action.MANAGED_PROFILE_UNLOCKED"; 4213 4214 /** 4215 * Broadcast sent to the primary user when an associated managed profile has become available. 4216 * Currently this includes when the user disables quiet mode for the profile. Carries an extra 4217 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4218 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4219 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4220 */ 4221 public static final String ACTION_MANAGED_PROFILE_AVAILABLE = 4222 "android.intent.action.MANAGED_PROFILE_AVAILABLE"; 4223 4224 /** 4225 * Broadcast sent to the primary user when an associated managed profile has become unavailable. 4226 * Currently this includes when the user enables quiet mode for the profile. Carries an extra 4227 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4228 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4229 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4230 */ 4231 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = 4232 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; 4233 4234 /** 4235 * Broadcast sent to the primary user when an associated profile has become available. 4236 * This is sent when a user disables quiet mode for the profile. Carries an extra 4237 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4238 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4239 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4240 * 4241 * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_AVAILABLE} but functions as a 4242 * generic broadcast for all users of type {@link android.os.UserManager#isProfile()}}. In 4243 * case of a managed profile, both {@link #ACTION_MANAGED_PROFILE_AVAILABLE} and 4244 * {@link #ACTION_PROFILE_AVAILABLE} broadcasts are sent. 4245 */ 4246 @FlaggedApi(FLAG_ALLOW_PRIVATE_PROFILE) 4247 public static final String ACTION_PROFILE_AVAILABLE = 4248 "android.intent.action.PROFILE_AVAILABLE"; 4249 4250 /** 4251 * Broadcast sent to the primary user when an associated profile has become unavailable. 4252 * This is sent when a user enables quiet mode for the profile. Carries an extra 4253 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4254 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4255 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4256 * 4257 * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_UNAVAILABLE} but functions as 4258 * a generic broadcast for all users of type {@link android.os.UserManager#isProfile()}}. In 4259 * case of a managed profile, both {@link #ACTION_MANAGED_PROFILE_UNAVAILABLE} and 4260 * {@link #ACTION_PROFILE_UNAVAILABLE} broadcasts are sent. 4261 */ 4262 @FlaggedApi(FLAG_ALLOW_PRIVATE_PROFILE) 4263 public static final String ACTION_PROFILE_UNAVAILABLE = 4264 "android.intent.action.PROFILE_UNAVAILABLE"; 4265 4266 /** 4267 * Broadcast sent to the parent user when an associated profile has been started and unlocked. 4268 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 4269 * This is only sent to registered receivers, not manifest receivers. 4270 */ 4271 public static final String ACTION_PROFILE_ACCESSIBLE = 4272 "android.intent.action.PROFILE_ACCESSIBLE"; 4273 4274 /** 4275 * Broadcast sent to the parent user when an associated profile has stopped. 4276 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 4277 * This is only sent to registered receivers, not manifest receivers. 4278 */ 4279 public static final String ACTION_PROFILE_INACCESSIBLE = 4280 "android.intent.action.PROFILE_INACCESSIBLE"; 4281 4282 /** 4283 * Broadcast sent to the parent user when an associated profile is removed. 4284 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile 4285 * that was removed. 4286 * 4287 * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_REMOVED} but functions as a 4288 * generic broadcast for all profile users. 4289 * It is sent in addition to the {@link #ACTION_MANAGED_PROFILE_REMOVED} broadcast when a 4290 * managed user is removed. 4291 * 4292 * <p>Only applications (for example Launchers) that need to display merged content across both 4293 * the parent user and its associated profiles need to worry about this broadcast. 4294 * This is only sent to registered receivers created with {@link Context#registerReceiver}. 4295 * It is not sent to manifest receivers. 4296 */ 4297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4298 public static final String ACTION_PROFILE_REMOVED = 4299 "android.intent.action.PROFILE_REMOVED"; 4300 4301 /** 4302 * Broadcast sent to the parent user when an associated profile is added (the profile was 4303 * created and is ready to be used). 4304 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile 4305 * that was added. 4306 * 4307 * <p>This broadcast is similar to {@link #ACTION_MANAGED_PROFILE_ADDED} but functions as a 4308 * generic broadcast for all profile users. 4309 * It is sent in addition to the {@link #ACTION_MANAGED_PROFILE_ADDED} broadcast when a 4310 * managed user is added. 4311 * 4312 * <p>Only applications (for example Launchers) that need to display merged content across both 4313 * the parent user and its associated profiles need to worry about this broadcast. 4314 * This is only sent to registered receivers created with {@link Context#registerReceiver}. 4315 * It is not sent to manifest receivers. 4316 */ 4317 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4318 public static final String ACTION_PROFILE_ADDED = 4319 "android.intent.action.PROFILE_ADDED"; 4320 4321 /** 4322 * Broadcast sent to the system user when the 'device locked' state changes for any user. 4323 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which 4324 * the device was locked or unlocked. 4325 * 4326 * This is only sent to registered receivers. 4327 * 4328 * @hide 4329 */ 4330 public static final String ACTION_DEVICE_LOCKED_CHANGED = 4331 "android.intent.action.DEVICE_LOCKED_CHANGED"; 4332 4333 /** 4334 * Sent when the user taps on the clock widget in the system's "quick settings" area. 4335 */ 4336 public static final String ACTION_QUICK_CLOCK = 4337 "android.intent.action.QUICK_CLOCK"; 4338 4339 /** 4340 * Activity Action: Shows the brightness setting dialog. 4341 * @hide 4342 */ 4343 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = 4344 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; 4345 4346 /** 4347 * Intent Extra: holds boolean that determines whether brightness dialog is full width when 4348 * in landscape mode. 4349 * @hide 4350 */ 4351 public static final String EXTRA_BRIGHTNESS_DIALOG_IS_FULL_WIDTH = 4352 "android.intent.extra.BRIGHTNESS_DIALOG_IS_FULL_WIDTH"; 4353 4354 /** 4355 * Broadcast Action: A global button was pressed. Includes a single 4356 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 4357 * caused the broadcast. 4358 * @hide 4359 */ 4360 @SystemApi 4361 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; 4362 4363 /** 4364 * Broadcast Action: Sent when media resource is granted. 4365 * <p> 4366 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource 4367 * granted. 4368 * </p> 4369 * <p class="note"> 4370 * This is a protected intent that can only be sent by the system. 4371 * </p> 4372 * <p class="note"> 4373 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. 4374 * </p> 4375 * 4376 * @hide 4377 */ 4378 public static final String ACTION_MEDIA_RESOURCE_GRANTED = 4379 "android.intent.action.MEDIA_RESOURCE_GRANTED"; 4380 4381 /** 4382 * Broadcast Action: An overlay package has changed. The data contains the 4383 * name of the overlay package which has changed. This is broadcast on all 4384 * changes to the OverlayInfo returned by {@link 4385 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The 4386 * most common change is a state change that will change whether the 4387 * overlay is enabled or not. 4388 * @hide 4389 */ 4390 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; 4391 4392 /** 4393 * Activity Action: Allow the user to select and return one or more existing 4394 * documents. When invoked, the system will display the various 4395 * {@link DocumentsProvider} instances installed on the device, letting the 4396 * user interactively navigate through them. These documents include local 4397 * media, such as photos and video, and documents provided by installed 4398 * cloud storage providers. 4399 * <p> 4400 * Each document is represented as a {@code content://} URI backed by a 4401 * {@link DocumentsProvider}, which can be opened as a stream with 4402 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 4403 * {@link android.provider.DocumentsContract.Document} metadata. 4404 * <p> 4405 * All selected documents are returned to the calling application with 4406 * persistable read and write permission grants. If you want to maintain 4407 * access to the documents across device reboots, you need to explicitly 4408 * take the persistable permissions using 4409 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. 4410 * <p> 4411 * Callers must indicate the acceptable document MIME types through 4412 * {@link #setType(String)}. For example, to select photos, use 4413 * {@code image/*}. If multiple disjoint MIME types are acceptable, define 4414 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to 4415 * {@literal *}/*. 4416 * <p> 4417 * If the caller can handle multiple returned items (the user performing 4418 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} 4419 * to indicate this. 4420 * <p> 4421 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4422 * URIs that can be opened with 4423 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4424 * <p> 4425 * Callers can set a document URI through 4426 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4427 * location of documents navigator. System will do its best to launch the 4428 * navigator in the specified document if it's a folder, or the folder that 4429 * contains the specified document if not. 4430 * <p> 4431 * Output: The URI of the item that was picked, returned in 4432 * {@link #getData()}. This must be a {@code content://} URI so that any 4433 * receiver can access it. If multiple documents were selected, they are 4434 * returned in {@link #getClipData()}. 4435 * 4436 * @see DocumentsContract 4437 * @see #ACTION_OPEN_DOCUMENT_TREE 4438 * @see #ACTION_CREATE_DOCUMENT 4439 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4440 */ 4441 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4442 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; 4443 4444 /** 4445 * Activity Action: Allow the user to create a new document. When invoked, 4446 * the system will display the various {@link DocumentsProvider} instances 4447 * installed on the device, letting the user navigate through them. The 4448 * returned document may be a newly created document with no content, or it 4449 * may be an existing document with the requested MIME type. 4450 * <p> 4451 * Each document is represented as a {@code content://} URI backed by a 4452 * {@link DocumentsProvider}, which can be opened as a stream with 4453 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 4454 * {@link android.provider.DocumentsContract.Document} metadata. 4455 * <p> 4456 * Callers must indicate the concrete MIME type of the document being 4457 * created by setting {@link #setType(String)}. This MIME type cannot be 4458 * changed after the document is created. 4459 * <p> 4460 * Callers can provide an initial display name through {@link #EXTRA_TITLE}, 4461 * but the user may change this value before creating the file. 4462 * <p> 4463 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4464 * URIs that can be opened with 4465 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4466 * <p> 4467 * Callers can set a document URI through 4468 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4469 * location of documents navigator. System will do its best to launch the 4470 * navigator in the specified document if it's a folder, or the folder that 4471 * contains the specified document if not. 4472 * <p> 4473 * Output: The URI of the item that was created. This must be a 4474 * {@code content://} URI so that any receiver can access it. 4475 * 4476 * @see DocumentsContract 4477 * @see #ACTION_OPEN_DOCUMENT 4478 * @see #ACTION_OPEN_DOCUMENT_TREE 4479 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4480 */ 4481 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4482 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; 4483 4484 /** 4485 * Activity Action: Allow the user to pick a directory subtree. When 4486 * invoked, the system will display the various {@link DocumentsProvider} 4487 * instances installed on the device, letting the user navigate through 4488 * them. Apps can fully manage documents within the returned directory. 4489 * <p> 4490 * To gain access to descendant (child, grandchild, etc) documents, use 4491 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and 4492 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} 4493 * with the returned URI. 4494 * <p> 4495 * Callers can set a document URI through 4496 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4497 * location of documents navigator. System will do its best to launch the 4498 * navigator in the specified document if it's a folder, or the folder that 4499 * contains the specified document if not. 4500 * <p> 4501 * Output: The URI representing the selected directory tree. 4502 * 4503 * @see DocumentsContract 4504 */ 4505 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4506 public static final String 4507 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; 4508 4509 4510 /** 4511 * Activity Action: Perform text translation. 4512 * <p> 4513 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate. 4514 * <p> 4515 * Output: nothing. 4516 */ 4517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4518 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE"; 4519 4520 /** 4521 * Activity Action: Define the meaning of the selected word(s). 4522 * <p> 4523 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define. 4524 * <p> 4525 * Output: nothing. 4526 */ 4527 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4528 public static final String ACTION_DEFINE = "android.intent.action.DEFINE"; 4529 4530 /** 4531 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or 4532 * exisiting sensor being disconnected. 4533 * 4534 * <p class="note">This is a protected intent that can only be sent by the system.</p> 4535 * 4536 * {@hide} 4537 */ 4538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4539 public static final String 4540 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; 4541 4542 /** 4543 * Deprecated - use ACTION_FACTORY_RESET instead. 4544 * @hide 4545 * @removed 4546 */ 4547 @Deprecated 4548 @SystemApi 4549 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; 4550 4551 /** 4552 * Broadcast intent sent by the RecoverySystem to inform listeners that a global clear (wipe) 4553 * is about to be performed. 4554 * @hide 4555 */ 4556 @SystemApi 4557 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4558 @RequiresPermission(Manifest.permission.MASTER_CLEAR) 4559 public static final String ACTION_MASTER_CLEAR_NOTIFICATION 4560 = "android.intent.action.MASTER_CLEAR_NOTIFICATION"; 4561 4562 /** 4563 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4564 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4565 * 4566 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. 4567 * 4568 * @hide 4569 */ 4570 @Deprecated 4571 public static final String EXTRA_FORCE_MASTER_CLEAR = 4572 "android.intent.extra.FORCE_MASTER_CLEAR"; 4573 4574 /** 4575 * A broadcast action to trigger a factory reset. 4576 * 4577 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The 4578 * reason for the factory reset should be specified as {@link #EXTRA_REASON}. 4579 * 4580 * <p>Not for use by third-party applications. 4581 * 4582 * @see #EXTRA_FORCE_FACTORY_RESET 4583 * 4584 * {@hide} 4585 */ 4586 @SystemApi 4587 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4588 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; 4589 4590 /** 4591 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4592 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4593 * 4594 * <p>Not for use by third-party applications. 4595 * 4596 * @hide 4597 */ 4598 @SystemApi 4599 public static final String EXTRA_FORCE_FACTORY_RESET = 4600 "android.intent.extra.FORCE_FACTORY_RESET"; 4601 4602 /** 4603 * Broadcast action: report that a settings element is being restored from backup. The intent 4604 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting, 4605 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE 4606 * is the value of that settings entry prior to the restore operation, and 4607 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been 4608 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three 4609 * values are represented as strings, the fourth one as int. 4610 * 4611 * <p>This broadcast is sent only for settings provider entries known to require special 4612 * handling around restore time to specific receivers. These entries are found in the 4613 * BROADCAST_ON_RESTORE table within the provider's backup agent implementation. 4614 * 4615 * @see #EXTRA_SETTING_NAME 4616 * @see #EXTRA_SETTING_PREVIOUS_VALUE 4617 * @see #EXTRA_SETTING_NEW_VALUE 4618 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT 4619 * {@hide} 4620 */ 4621 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4622 @SuppressLint("ActionValue") 4623 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; 4624 4625 /** 4626 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4627 * Contain the name of the restored setting. 4628 * {@hide} 4629 */ 4630 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4631 @SuppressLint("ActionValue") 4632 public static final String EXTRA_SETTING_NAME = "setting_name"; 4633 4634 /** 4635 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4636 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry prior to the restore 4637 * operation. 4638 * {@hide} 4639 */ 4640 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4641 @SuppressLint("ActionValue") 4642 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; 4643 4644 /** 4645 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4646 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry being restored. 4647 * {@hide} 4648 */ 4649 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4650 @SuppressLint("ActionValue") 4651 public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; 4652 4653 /** 4654 * Int intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4655 * Contain the version of the SDK that the setting has been restored from (corresponds to 4656 * {@link android.os.Build.VERSION#SDK_INT}). 4657 * {@hide} 4658 */ 4659 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4660 @SuppressLint("ActionValue") 4661 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int"; 4662 4663 /** 4664 * Activity Action: Process a piece of text. 4665 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. 4666 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> 4667 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> 4668 */ 4669 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4670 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; 4671 4672 /** 4673 * Broadcast Action: The sim card state has changed. 4674 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here 4675 * because TelephonyIntents is an internal class. 4676 * The intent will have following extras.</p> 4677 * <p> 4678 * @see #EXTRA_SIM_STATE 4679 * @see #EXTRA_SIM_LOCKED_REASON 4680 * @see #EXTRA_REBROADCAST_ON_UNLOCK 4681 * 4682 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or 4683 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4684 * 4685 * @hide 4686 */ 4687 @Deprecated 4688 @SystemApi 4689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4690 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED"; 4691 4692 /** 4693 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4694 * This will have one of the following intent values. 4695 * @see #SIM_STATE_UNKNOWN 4696 * @see #SIM_STATE_NOT_READY 4697 * @see #SIM_STATE_ABSENT 4698 * @see #SIM_STATE_PRESENT 4699 * @see #SIM_STATE_CARD_IO_ERROR 4700 * @see #SIM_STATE_CARD_RESTRICTED 4701 * @see #SIM_STATE_LOCKED 4702 * @see #SIM_STATE_READY 4703 * @see #SIM_STATE_IMSI 4704 * @see #SIM_STATE_LOADED 4705 * @hide 4706 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4707 */ 4708 public static final String EXTRA_SIM_STATE = "ss"; 4709 4710 /** 4711 * The intent value UNKNOWN represents the SIM state unknown 4712 * @hide 4713 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4714 */ 4715 public static final String SIM_STATE_UNKNOWN = "UNKNOWN"; 4716 4717 /** 4718 * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on 4719 * @hide 4720 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4721 */ 4722 public static final String SIM_STATE_NOT_READY = "NOT_READY"; 4723 4724 /** 4725 * The intent value ABSENT means the SIM card is missing 4726 * @hide 4727 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4728 */ 4729 public static final String SIM_STATE_ABSENT = "ABSENT"; 4730 4731 /** 4732 * The intent value PRESENT means the device has a SIM card inserted 4733 * @hide 4734 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4735 */ 4736 public static final String SIM_STATE_PRESENT = "PRESENT"; 4737 4738 /** 4739 * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error 4740 * @hide 4741 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4742 */ 4743 static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR"; 4744 4745 /** 4746 * The intent value CARD_RESTRICTED means card is present but not usable due to carrier 4747 * restrictions 4748 * @hide 4749 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4750 */ 4751 static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED"; 4752 4753 /** 4754 * The intent value LOCKED means the SIM is locked by PIN or by network 4755 * @hide 4756 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4757 */ 4758 public static final String SIM_STATE_LOCKED = "LOCKED"; 4759 4760 /** 4761 * The intent value READY means the SIM is ready to be accessed 4762 * @hide 4763 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4764 */ 4765 public static final String SIM_STATE_READY = "READY"; 4766 4767 /** 4768 * The intent value IMSI means the SIM IMSI is ready in property 4769 * @hide 4770 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4771 */ 4772 public static final String SIM_STATE_IMSI = "IMSI"; 4773 4774 /** 4775 * The intent value LOADED means all SIM records, including IMSI, are loaded 4776 * @hide 4777 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} 4778 */ 4779 public static final String SIM_STATE_LOADED = "LOADED"; 4780 4781 /** 4782 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4783 * This extra will have one of the following intent values. 4784 * <p> 4785 * @see #SIM_LOCKED_ON_PIN 4786 * @see #SIM_LOCKED_ON_PUK 4787 * @see #SIM_LOCKED_NETWORK 4788 * @see #SIM_ABSENT_ON_PERM_DISABLED 4789 * 4790 * @hide 4791 * @deprecated Use 4792 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4793 */ 4794 public static final String EXTRA_SIM_LOCKED_REASON = "reason"; 4795 4796 /** 4797 * The intent value PIN means the SIM is locked on PIN1 4798 * @hide 4799 * @deprecated Use 4800 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4801 */ 4802 public static final String SIM_LOCKED_ON_PIN = "PIN"; 4803 4804 /** 4805 * The intent value PUK means the SIM is locked on PUK1 4806 * @hide 4807 * @deprecated Use 4808 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4809 */ 4810 /* PUK means ICC is locked on PUK1 */ 4811 public static final String SIM_LOCKED_ON_PUK = "PUK"; 4812 4813 /** 4814 * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION 4815 * @hide 4816 * @deprecated Use 4817 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4818 */ 4819 public static final String SIM_LOCKED_NETWORK = "NETWORK"; 4820 4821 /** 4822 * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails 4823 * @hide 4824 * @deprecated Use 4825 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4826 */ 4827 public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED"; 4828 4829 /** 4830 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast 4831 * is a rebroadcast on unlock. Defaults to {@code false} if not specified. 4832 * 4833 * @hide 4834 * @deprecated Use {@link android.telephony.TelephonyManager#ACTION_SIM_CARD_STATE_CHANGED} or 4835 * {@link android.telephony.TelephonyManager#ACTION_SIM_APPLICATION_STATE_CHANGED} 4836 */ 4837 public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock"; 4838 4839 /** 4840 * Broadcast Action: indicate that the phone service state has changed. 4841 * The intent will have the following extra values:</p> 4842 * <p> 4843 * @see #EXTRA_VOICE_REG_STATE 4844 * @see #EXTRA_DATA_REG_STATE 4845 * @see #EXTRA_VOICE_ROAMING_TYPE 4846 * @see #EXTRA_DATA_ROAMING_TYPE 4847 * @see #EXTRA_OPERATOR_ALPHA_LONG 4848 * @see #EXTRA_OPERATOR_ALPHA_SHORT 4849 * @see #EXTRA_OPERATOR_NUMERIC 4850 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG 4851 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT 4852 * @see #EXTRA_DATA_OPERATOR_NUMERIC 4853 * @see #EXTRA_MANUAL 4854 * @see #EXTRA_VOICE_RADIO_TECH 4855 * @see #EXTRA_DATA_RADIO_TECH 4856 * @see #EXTRA_CSS_INDICATOR 4857 * @see #EXTRA_NETWORK_ID 4858 * @see #EXTRA_SYSTEM_ID 4859 * @see #EXTRA_CDMA_ROAMING_INDICATOR 4860 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR 4861 * @see #EXTRA_EMERGENCY_ONLY 4862 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION 4863 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION 4864 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST 4865 * 4866 * <p class="note"> 4867 * Requires the READ_PHONE_STATE permission. 4868 * 4869 * <p class="note">This is a protected intent that can only be sent by the system. 4870 * @hide 4871 * @removed 4872 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper 4873 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and 4874 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState 4875 * for a given subscription id and field with a ContentObserver or using JobScheduler. 4876 */ 4877 @Deprecated 4878 @SystemApi 4879 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 4880 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE"; 4881 4882 /** 4883 * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService} 4884 * for querying Data Loader Service providers. Data loader service providers register this 4885 * intent filter in their manifests, so that they can be looked up and bound to by 4886 * {@code DataLoaderManagerService}. 4887 * 4888 * <p class="note">This is a protected intent that can only be sent by the system. 4889 * 4890 * Data loader service providers must be privileged apps. 4891 * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such 4892 * data loader service provider. 4893 * 4894 * @hide 4895 */ 4896 @SystemApi 4897 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) 4898 public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA"; 4899 4900 /** 4901 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration 4902 * state. 4903 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4904 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4905 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4906 * @see android.telephony.ServiceState#STATE_POWER_OFF 4907 * @hide 4908 * @removed 4909 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}. 4910 */ 4911 @Deprecated 4912 @SystemApi 4913 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState"; 4914 4915 /** 4916 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state. 4917 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4918 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4919 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4920 * @see android.telephony.ServiceState#STATE_POWER_OFF 4921 * @hide 4922 * @removed 4923 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}. 4924 */ 4925 @Deprecated 4926 @SystemApi 4927 public static final String EXTRA_DATA_REG_STATE = "dataRegState"; 4928 4929 /** 4930 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming 4931 * type. 4932 * @hide 4933 * @removed 4934 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}. 4935 */ 4936 @Deprecated 4937 @SystemApi 4938 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType"; 4939 4940 /** 4941 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming 4942 * type. 4943 * @hide 4944 * @removed 4945 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}. 4946 */ 4947 @Deprecated 4948 @SystemApi 4949 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType"; 4950 4951 /** 4952 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4953 * registered voice operator name in long alphanumeric format. 4954 * {@code null} if the operator name is not known or unregistered. 4955 * @hide 4956 * @removed 4957 * @deprecated Use 4958 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}. 4959 */ 4960 @Deprecated 4961 @SystemApi 4962 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long"; 4963 4964 /** 4965 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4966 * registered voice operator name in short alphanumeric format. 4967 * {@code null} if the operator name is not known or unregistered. 4968 * @hide 4969 * @removed 4970 * @deprecated Use 4971 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}. 4972 */ 4973 @Deprecated 4974 @SystemApi 4975 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short"; 4976 4977 /** 4978 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4979 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile 4980 * network. 4981 * @hide 4982 * @removed 4983 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}. 4984 */ 4985 @Deprecated 4986 @SystemApi 4987 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric"; 4988 4989 /** 4990 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4991 * registered data operator name in long alphanumeric format. 4992 * {@code null} if the operator name is not known or unregistered. 4993 * @hide 4994 * @removed 4995 * @deprecated Use 4996 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}. 4997 */ 4998 @Deprecated 4999 @SystemApi 5000 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long"; 5001 5002 /** 5003 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 5004 * registered data operator name in short alphanumeric format. 5005 * {@code null} if the operator name is not known or unregistered. 5006 * @hide 5007 * @removed 5008 * @deprecated Use 5009 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}. 5010 */ 5011 @Deprecated 5012 @SystemApi 5013 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short"; 5014 5015 /** 5016 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 5017 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the 5018 * data operator. 5019 * @hide 5020 * @removed 5021 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}. 5022 */ 5023 @Deprecated 5024 @SystemApi 5025 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric"; 5026 5027 /** 5028 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current 5029 * network selection mode is manual. 5030 * Will be {@code true} if manual mode, {@code false} if automatic mode. 5031 * @hide 5032 * @removed 5033 * @deprecated Use 5034 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}. 5035 */ 5036 @Deprecated 5037 @SystemApi 5038 public static final String EXTRA_MANUAL = "manual"; 5039 5040 /** 5041 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice 5042 * radio technology. 5043 * @hide 5044 * @removed 5045 * @deprecated Use 5046 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}. 5047 */ 5048 @Deprecated 5049 @SystemApi 5050 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology"; 5051 5052 /** 5053 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data 5054 * radio technology. 5055 * @hide 5056 * @removed 5057 * @deprecated Use 5058 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}. 5059 */ 5060 @Deprecated 5061 @SystemApi 5062 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology"; 5063 5064 /** 5065 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service 5066 * support on CDMA network. 5067 * Will be {@code true} if support, {@code false} otherwise. 5068 * @hide 5069 * @removed 5070 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}. 5071 */ 5072 @Deprecated 5073 @SystemApi 5074 public static final String EXTRA_CSS_INDICATOR = "cssIndicator"; 5075 5076 /** 5077 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network 5078 * id. {@code Integer.MAX_VALUE} if unknown. 5079 * @hide 5080 * @removed 5081 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}. 5082 */ 5083 @Deprecated 5084 @SystemApi 5085 public static final String EXTRA_NETWORK_ID = "networkId"; 5086 5087 /** 5088 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id. 5089 * {@code Integer.MAX_VALUE} if unknown. 5090 * @hide 5091 * @removed 5092 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}. 5093 */ 5094 @Deprecated 5095 @SystemApi 5096 public static final String EXTRA_SYSTEM_ID = "systemId"; 5097 5098 /** 5099 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming 5100 * indicator if registered on a CDMA or EVDO system or {@code -1} if not. 5101 * @hide 5102 * @removed 5103 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}. 5104 */ 5105 @Deprecated 5106 @SystemApi 5107 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator"; 5108 5109 /** 5110 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming 5111 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not. 5112 * @hide 5113 * @removed 5114 * @deprecated Use 5115 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}. 5116 */ 5117 @Deprecated 5118 @SystemApi 5119 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator"; 5120 5121 /** 5122 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency 5123 * only mode. 5124 * {@code true} if in emergency only mode, {@code false} otherwise. 5125 * @hide 5126 * @removed 5127 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}. 5128 */ 5129 @Deprecated 5130 @SystemApi 5131 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly"; 5132 5133 /** 5134 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network 5135 * registration state is roaming. 5136 * {@code true} if registration indicates roaming, {@code false} otherwise 5137 * @hide 5138 * @removed 5139 * @deprecated Use 5140 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}. 5141 */ 5142 @Deprecated 5143 @SystemApi 5144 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION = 5145 "isDataRoamingFromRegistration"; 5146 5147 /** 5148 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier 5149 * aggregation is in use. 5150 * {@code true} if carrier aggregation is in use, {@code false} otherwise. 5151 * @hide 5152 * @removed 5153 * @deprecated Use 5154 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}. 5155 */ 5156 @Deprecated 5157 @SystemApi 5158 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation"; 5159 5160 /** 5161 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which 5162 * is reduced from the rsrp threshold while calculating signal strength level. 5163 * @hide 5164 * @removed 5165 */ 5166 @Deprecated 5167 @SystemApi 5168 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; 5169 5170 /** 5171 * The name of the extra used to define the text to be processed, as a 5172 * CharSequence. Note that this may be a styled CharSequence, so you must use 5173 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. 5174 */ 5175 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; 5176 /** 5177 * The name of the boolean extra used to define if the processed text will be used as read-only. 5178 */ 5179 public static final String EXTRA_PROCESS_TEXT_READONLY = 5180 "android.intent.extra.PROCESS_TEXT_READONLY"; 5181 5182 /** 5183 * Broadcast action: reports when a new thermal event has been reached. When the device 5184 * is reaching its maximum temperatue, the thermal level reported 5185 * {@hide} 5186 */ 5187 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5188 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; 5189 5190 /** {@hide} */ 5191 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; 5192 5193 /** 5194 * Thermal state when the device is normal. This state is sent in the 5195 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 5196 * {@hide} 5197 */ 5198 public static final int EXTRA_THERMAL_STATE_NORMAL = 0; 5199 5200 /** 5201 * Thermal state where the device is approaching its maximum threshold. This state is sent in 5202 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 5203 * {@hide} 5204 */ 5205 public static final int EXTRA_THERMAL_STATE_WARNING = 1; 5206 5207 /** 5208 * Thermal state where the device has reached its maximum threshold. This state is sent in the 5209 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 5210 * {@hide} 5211 */ 5212 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; 5213 5214 /** 5215 * Broadcast Action: Indicates the dock in idle state while device is docked. 5216 * 5217 * <p class="note">This is a protected intent that can only be sent 5218 * by the system. 5219 * 5220 * @hide 5221 */ 5222 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE"; 5223 5224 /** 5225 * Broadcast Action: Indicates the dock in active state while device is docked. 5226 * 5227 * <p class="note">This is a protected intent that can only be sent 5228 * by the system. 5229 * 5230 * @hide 5231 */ 5232 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE"; 5233 5234 /** 5235 * Broadcast Action: Indicates that a new device customization has been 5236 * downloaded and applied (packages installed, runtime resource overlays 5237 * enabled, xml files copied, ...), and that it is time for components that 5238 * need to for example clear their caches to do so now. 5239 * 5240 * @hide 5241 */ 5242 @SystemApi 5243 public static final String ACTION_DEVICE_CUSTOMIZATION_READY = 5244 "android.intent.action.DEVICE_CUSTOMIZATION_READY"; 5245 5246 5247 /** 5248 * Activity Action: Display an activity state associated with an unique {@link LocusId}. 5249 * 5250 * <p>For example, a chat app could use the context to resume a conversation between 2 users. 5251 * 5252 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the 5253 * app domain. Should be stable across reboots and backup / restore. 5254 * <p>Output: nothing. 5255 */ 5256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5257 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS"; 5258 5259 /** 5260 * Activity Action: Starts a note-taking activity that can be used to create a note. This action 5261 * can be used to start an activity on the lock screen. Activity should ensure to appropriately 5262 * handle privacy sensitive data and features when launched on the lock screen. See 5263 * {@link android.app.KeyguardManager} for lock screen checks. 5264 */ 5265 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5266 public static final String ACTION_CREATE_NOTE = "android.intent.action.CREATE_NOTE"; 5267 5268 /** 5269 * A boolean extra used with {@link #ACTION_CREATE_NOTE} indicating whether the launched 5270 * note-taking activity should show a UI that is suitable to use with stylus input. 5271 */ 5272 public static final String EXTRA_USE_STYLUS_MODE = "android.intent.extra.USE_STYLUS_MODE"; 5273 5274 /** 5275 * Activity Action: Use with startActivityForResult to start a system activity that captures 5276 * content on the screen to take a screenshot and present it to the user for editing. The 5277 * edited screenshot is saved on device and returned to the calling activity as a {@link Uri} 5278 * through {@link #getData()}. User interaction is required to return the edited screenshot to 5279 * the calling activity. 5280 * 5281 * <p>This intent action requires the permission 5282 * {@link android.Manifest.permission#LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE}. 5283 * 5284 * <p>Callers should query 5285 * {@link StatusBarManager#canLaunchCaptureContentActivityForNote(Activity)} before showing a UI 5286 * element that allows users to trigger this flow. 5287 */ 5288 @RequiresPermission(Manifest.permission.LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE) 5289 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5290 public static final String ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE = 5291 "android.intent.action.LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE"; 5292 5293 /** 5294 * An int extra used by activity started with 5295 * {@link #ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE} to indicate status of the response. 5296 * This extra is used along with result code set to {@link android.app.Activity#RESULT_OK}. 5297 * 5298 * <p>The value for this extra can be one of the following: 5299 * <ul> 5300 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_SUCCESS}</li> 5301 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_FAILED}</li> 5302 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_USER_CANCELED}</li> 5303 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED}</li> 5304 * <li>{@link #CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN}</li> 5305 * </ul> 5306 */ 5307 public static final String EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE = 5308 "android.intent.extra.CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE"; 5309 5310 /** 5311 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5312 * that the request was a success. 5313 * 5314 * <p>This code will only be returned after the user has interacted with the system screenshot 5315 * activity to consent to sharing the data with the note. 5316 * 5317 * <p>The captured screenshot is returned as a {@link Uri} through {@link #getData()}. 5318 */ 5319 public static final int CAPTURE_CONTENT_FOR_NOTE_SUCCESS = 0; 5320 5321 /** 5322 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5323 * that something went wrong. 5324 */ 5325 public static final int CAPTURE_CONTENT_FOR_NOTE_FAILED = 1; 5326 5327 /** 5328 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5329 * that user canceled the content capture flow. 5330 */ 5331 public static final int CAPTURE_CONTENT_FOR_NOTE_USER_CANCELED = 2; 5332 5333 /** 5334 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5335 * that the intent action {@link #ACTION_LAUNCH_CAPTURE_CONTENT_ACTIVITY_FOR_NOTE} was started 5336 * by an activity that is running in a non-supported window mode. 5337 */ 5338 public static final int CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED = 3; 5339 5340 /** 5341 * A response code used with {@link #EXTRA_CAPTURE_CONTENT_FOR_NOTE_STATUS_CODE} to indicate 5342 * that screenshot is blocked by IT admin. 5343 */ 5344 public static final int CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN = 4; 5345 5346 /** @hide */ 5347 @IntDef(value = { 5348 CAPTURE_CONTENT_FOR_NOTE_SUCCESS, CAPTURE_CONTENT_FOR_NOTE_FAILED, 5349 CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED, 5350 CAPTURE_CONTENT_FOR_NOTE_BLOCKED_BY_ADMIN}) 5351 @Retention(RetentionPolicy.SOURCE) 5352 public @interface CaptureContentForNoteStatusCodes {} 5353 5354 /** 5355 * Broadcast Action: Sent to the integrity component when a package 5356 * needs to be verified. The data contains the package URI along with other relevant 5357 * information. 5358 * 5359 * <p class="note"> 5360 * This is a protected intent that can only be sent by the system. 5361 * </p> 5362 * 5363 * @hide 5364 */ 5365 @SystemApi 5366 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 5367 public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION = 5368 "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION"; 5369 5370 /** 5371 * Broadcast Action: Start the foreground service manager. 5372 * 5373 * <p class="note"> 5374 * This is a protected intent that can only be sent by the system. 5375 * </p> 5376 * 5377 * @hide 5378 */ 5379 public static final String ACTION_SHOW_FOREGROUND_SERVICE_MANAGER = 5380 "android.intent.action.SHOW_FOREGROUND_SERVICE_MANAGER"; 5381 5382 /** 5383 * Broadcast Action: Sent to the responsible installer of an archived package when unarchival 5384 * is requested. 5385 * 5386 * @see android.content.pm.PackageInstaller#requestUnarchive 5387 */ 5388 @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING) 5389 @BroadcastBehavior(explicitOnly = true) 5390 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 5391 public static final String ACTION_UNARCHIVE_PACKAGE = "android.intent.action.UNARCHIVE_PACKAGE"; 5392 5393 // --------------------------------------------------------------------- 5394 // --------------------------------------------------------------------- 5395 // Standard intent categories (see addCategory()). 5396 5397 /** 5398 * Set if the activity should be an option for the default action 5399 * (center press) to perform on a piece of data. Setting this will 5400 * hide from the user any activities without it set when performing an 5401 * action on some data. Note that this is normally -not- set in the 5402 * Intent when initiating an action -- it is for use in intent filters 5403 * specified in packages. 5404 */ 5405 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5406 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; 5407 /** 5408 * Activities that can be safely invoked from a browser must support this 5409 * category. For example, if the user is viewing a web page or an e-mail 5410 * and clicks on a link in the text, the Intent generated execute that 5411 * link will require the BROWSABLE category, so that only activities 5412 * supporting this category will be considered as possible actions. By 5413 * supporting this category, you are promising that there is nothing 5414 * damaging (without user intervention) that can happen by invoking any 5415 * matching Intent. 5416 */ 5417 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5418 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; 5419 /** 5420 * Categories for activities that can participate in voice interaction. 5421 * An activity that supports this category must be prepared to run with 5422 * no UI shown at all (though in some case it may have a UI shown), and 5423 * rely on {@link android.app.VoiceInteractor} to interact with the user. 5424 */ 5425 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5426 public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; 5427 /** 5428 * Set if the activity should be considered as an alternative action to 5429 * the data the user is currently viewing. See also 5430 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that 5431 * applies to the selection in a list of items. 5432 * 5433 * <p>Supporting this category means that you would like your activity to be 5434 * displayed in the set of alternative things the user can do, usually as 5435 * part of the current activity's options menu. You will usually want to 5436 * include a specific label in the <intent-filter> of this action 5437 * describing to the user what it does. 5438 * 5439 * <p>The action of IntentFilter with this category is important in that it 5440 * describes the specific action the target will perform. This generally 5441 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather 5442 * a specific name such as "com.android.camera.action.CROP. Only one 5443 * alternative of any particular action will be shown to the user, so using 5444 * a specific action like this makes sure that your alternative will be 5445 * displayed while also allowing other applications to provide their own 5446 * overrides of that particular action. 5447 */ 5448 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5449 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; 5450 /** 5451 * Set if the activity should be considered as an alternative selection 5452 * action to the data the user has currently selected. This is like 5453 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list 5454 * of items from which the user can select, giving them alternatives to the 5455 * default action that will be performed on it. 5456 */ 5457 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5458 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; 5459 /** 5460 * Intended to be used as a tab inside of a containing TabActivity. 5461 */ 5462 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5463 public static final String CATEGORY_TAB = "android.intent.category.TAB"; 5464 /** 5465 * Should be displayed in the top-level launcher. 5466 */ 5467 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5468 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; 5469 /** 5470 * Indicates an activity optimized for Leanback mode, and that should 5471 * be displayed in the Leanback launcher. 5472 */ 5473 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5474 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; 5475 /** 5476 * Indicates the preferred entry-point activity when an application is launched from a Car 5477 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a 5478 * fallback, or exclude the application entirely. 5479 * @hide 5480 */ 5481 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5482 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER"; 5483 /** 5484 * Used to indicate that the activity can be used in communal mode. 5485 * @hide 5486 */ 5487 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5488 public static final String CATEGORY_COMMUNAL_MODE = "android.intent.category.COMMUNAL_MODE"; 5489 /** 5490 * Indicates a Leanback settings activity to be displayed in the Leanback launcher. 5491 * @hide 5492 */ 5493 @SystemApi 5494 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; 5495 /** 5496 * Provides information about the package it is in; typically used if 5497 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide 5498 * a front-door to the user without having to be shown in the all apps list. 5499 */ 5500 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5501 public static final String CATEGORY_INFO = "android.intent.category.INFO"; 5502 /** 5503 * This is the home activity, that is the first activity that is displayed 5504 * when the device boots. 5505 */ 5506 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5507 public static final String CATEGORY_HOME = "android.intent.category.HOME"; 5508 /** 5509 * This is the home activity that is displayed when the device is finished setting up and ready 5510 * for use. 5511 * @hide 5512 */ 5513 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5514 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; 5515 /** 5516 * The home activity shown on secondary displays that support showing home activities. 5517 */ 5518 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5519 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME"; 5520 /** 5521 * This is the setup wizard activity, that is the first activity that is displayed 5522 * when the user sets up the device for the first time. 5523 * @hide 5524 */ 5525 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5526 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; 5527 /** 5528 * This is the home activity, that is the activity that serves as the launcher app 5529 * from there the user can start other apps. Often components with lower/higher 5530 * priority intent filters handle the home intent, for example SetupWizard, to 5531 * setup the device and we need to be able to distinguish the home app from these 5532 * setup helpers. 5533 * @hide 5534 */ 5535 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5536 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP"; 5537 /** 5538 * This activity is a preference panel. 5539 */ 5540 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5541 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; 5542 /** 5543 * This activity is a development preference panel. 5544 */ 5545 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5546 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; 5547 /** 5548 * Capable of running inside a parent activity container. 5549 */ 5550 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5551 public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; 5552 /** 5553 * This activity allows the user to browse and download new applications. 5554 */ 5555 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5556 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; 5557 /** 5558 * This activity may be exercised by the monkey or other automated test tools. 5559 */ 5560 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5561 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; 5562 /** 5563 * To be used as a test (not part of the normal user experience). 5564 */ 5565 public static final String CATEGORY_TEST = "android.intent.category.TEST"; 5566 /** 5567 * To be used as a unit test (run through the Test Harness). 5568 */ 5569 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; 5570 /** 5571 * To be used as a sample code example (not part of the normal user 5572 * experience). 5573 */ 5574 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; 5575 5576 /** 5577 * Used to indicate that an intent only wants URIs that can be opened with 5578 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs 5579 * must support at least the columns defined in {@link OpenableColumns} when 5580 * queried. 5581 * 5582 * @see #ACTION_GET_CONTENT 5583 * @see #ACTION_OPEN_DOCUMENT 5584 * @see #ACTION_CREATE_DOCUMENT 5585 */ 5586 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5587 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; 5588 5589 /** 5590 * Used to indicate that an intent filter can accept files which are not necessarily 5591 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but 5592 * at least streamable via 5593 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} 5594 * using one of the stream types exposed via 5595 * {@link ContentResolver#getStreamTypes(Uri, String)}. 5596 * 5597 * @see #ACTION_SEND 5598 * @see #ACTION_SEND_MULTIPLE 5599 */ 5600 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5601 public static final String CATEGORY_TYPED_OPENABLE = 5602 "android.intent.category.TYPED_OPENABLE"; 5603 5604 /** 5605 * To be used as code under test for framework instrumentation tests. 5606 */ 5607 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = 5608 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; 5609 /** 5610 * An activity to run when device is inserted into a car dock. 5611 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5612 * information, see {@link android.app.UiModeManager}. 5613 */ 5614 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5615 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; 5616 /** 5617 * An activity to run when device is inserted into a desk dock. 5618 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5619 * information, see {@link android.app.UiModeManager}. 5620 */ 5621 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5622 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; 5623 /** 5624 * An activity to run when device is inserted into a analog (low end) dock. 5625 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5626 * information, see {@link android.app.UiModeManager}. 5627 */ 5628 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5629 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; 5630 5631 /** 5632 * An activity to run when device is inserted into a digital (high end) dock. 5633 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5634 * information, see {@link android.app.UiModeManager}. 5635 */ 5636 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5637 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK"; 5638 5639 /** 5640 * Used to indicate that the activity can be used in a car environment. 5641 */ 5642 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5643 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; 5644 5645 /** 5646 * An activity to use for the launcher when the device is placed in a VR Headset viewer. 5647 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5648 * information, see {@link android.app.UiModeManager}. 5649 */ 5650 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5651 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; 5652 5653 /** 5654 * The accessibility shortcut is a global gesture for users with disabilities to trigger an 5655 * important for them accessibility feature to help developers determine whether they want to 5656 * make their activity a shortcut target. 5657 * <p> 5658 * An activity of interest to users with accessibility needs may request to be the target of 5659 * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category, 5660 * which will be dispatched by the system when the user activates the shortcut when it is 5661 * configured to point at this target. 5662 * </p> 5663 * <p> 5664 * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must 5665 * also do two things: 5666 * <ul> 5667 * <ol> 5668 * Specify that it handles the <code>android.intent.action.MAIN</code> 5669 * {@link android.content.Intent} 5670 * with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>. 5671 * </ol> 5672 * <ol> 5673 * Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the 5674 * manifest when declaring the activity. 5675 * </ol> 5676 * </ul> 5677 * If either of these items is missing, the system will ignore the accessibility shortcut 5678 * target. Following is an example declaration: 5679 * </p> 5680 * <pre> 5681 * <activity android:name=".MainActivity" 5682 * . . . 5683 * <intent-filter> 5684 * <action android:name="android.intent.action.MAIN" /> 5685 * <category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /> 5686 * </intent-filter> 5687 * <meta-data android:name="android.accessibilityshortcut.target" 5688 * android:resource="@xml/accessibilityshortcut" /> 5689 * </activity> 5690 * </pre> 5691 * <p> This is a sample XML file configuring a accessibility shortcut target: </p> 5692 * <pre> 5693 * <accessibility-shortcut-target 5694 * android:description="@string/shortcut_target_description" 5695 * android:summary="@string/shortcut_target_summary" 5696 * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" 5697 * android:htmlDescription="@string/shortcut_target_html_description" 5698 * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /> 5699 * </pre> 5700 * <p> 5701 * Both description and summary are necessary. The system will ignore the accessibility 5702 * shortcut target if they are missing. The animated image and html description are supported 5703 * to help users understand how to use the shortcut target. The settings activity is a 5704 * component name that allows the user to modify the settings for this accessibility shortcut 5705 * target. 5706 * </p> 5707 */ 5708 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5709 public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET = 5710 "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET"; 5711 // --------------------------------------------------------------------- 5712 // --------------------------------------------------------------------- 5713 // Application launch intent categories (see addCategory()). 5714 5715 /** 5716 * Used with {@link #ACTION_MAIN} to launch the browser application. 5717 * The activity should be able to browse the Internet. 5718 * <p>NOTE: This should not be used as the primary key of an Intent, 5719 * since it will not result in the app launching with the correct 5720 * action and category. Instead, use this with 5721 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5722 * Intent with this category in the selector.</p> 5723 */ 5724 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5725 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; 5726 5727 /** 5728 * Used with {@link #ACTION_MAIN} to launch the calculator application. 5729 * The activity should be able to perform standard arithmetic operations. 5730 * <p>NOTE: This should not be used as the primary key of an Intent, 5731 * since it will not result in the app launching with the correct 5732 * action and category. Instead, use this with 5733 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5734 * Intent with this category in the selector.</p> 5735 */ 5736 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5737 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; 5738 5739 /** 5740 * Used with {@link #ACTION_MAIN} to launch the calendar application. 5741 * The activity should be able to view and manipulate calendar entries. 5742 * <p>NOTE: This should not be used as the primary key of an Intent, 5743 * since it will not result in the app launching with the correct 5744 * action and category. Instead, use this with 5745 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5746 * Intent with this category in the selector.</p> 5747 */ 5748 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5749 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; 5750 5751 /** 5752 * Used with {@link #ACTION_MAIN} to launch the contacts application. 5753 * The activity should be able to view and manipulate address book entries. 5754 * <p>NOTE: This should not be used as the primary key of an Intent, 5755 * since it will not result in the app launching with the correct 5756 * action and category. Instead, use this with 5757 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5758 * Intent with this category in the selector.</p> 5759 */ 5760 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5761 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; 5762 5763 /** 5764 * Used with {@link #ACTION_MAIN} to launch the email application. 5765 * The activity should be able to send and receive email. 5766 * <p>NOTE: This should not be used as the primary key of an Intent, 5767 * since it will not result in the app launching with the correct 5768 * action and category. Instead, use this with 5769 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5770 * Intent with this category in the selector.</p> 5771 */ 5772 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5773 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; 5774 5775 /** 5776 * Used with {@link #ACTION_MAIN} to launch the gallery application. 5777 * The activity should be able to view and manipulate image and video files 5778 * stored on the device. 5779 * <p>NOTE: This should not be used as the primary key of an Intent, 5780 * since it will not result in the app launching with the correct 5781 * action and category. Instead, use this with 5782 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5783 * Intent with this category in the selector.</p> 5784 */ 5785 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5786 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; 5787 5788 /** 5789 * Used with {@link #ACTION_MAIN} to launch the maps application. 5790 * The activity should be able to show the user's current location and surroundings. 5791 * <p>NOTE: This should not be used as the primary key of an Intent, 5792 * since it will not result in the app launching with the correct 5793 * action and category. Instead, use this with 5794 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5795 * Intent with this category in the selector.</p> 5796 */ 5797 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5798 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; 5799 5800 /** 5801 * Used with {@link #ACTION_MAIN} to launch the messaging application. 5802 * The activity should be able to send and receive text messages. 5803 * <p>NOTE: This should not be used as the primary key of an Intent, 5804 * since it will not result in the app launching with the correct 5805 * action and category. Instead, use this with 5806 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5807 * Intent with this category in the selector.</p> 5808 */ 5809 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5810 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; 5811 5812 /** 5813 * Used with {@link #ACTION_MAIN} to launch the music application. 5814 * The activity should be able to play, browse, or manipulate music files 5815 * stored on the device. 5816 * <p>NOTE: This should not be used as the primary key of an Intent, 5817 * since it will not result in the app launching with the correct 5818 * action and category. Instead, use this with 5819 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5820 * Intent with this category in the selector.</p> 5821 */ 5822 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5823 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; 5824 5825 /** 5826 * Used with {@link #ACTION_MAIN} to launch the files application. 5827 * The activity should be able to browse and manage files stored on the device. 5828 * <p>NOTE: This should not be used as the primary key of an Intent, 5829 * since it will not result in the app launching with the correct 5830 * action and category. Instead, use this with 5831 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5832 * Intent with this category in the selector.</p> 5833 */ 5834 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5835 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES"; 5836 5837 /** 5838 * Used with {@link #ACTION_MAIN} to launch the weather application. 5839 * The activity should be able to give the user information about the weather 5840 * <p>NOTE: This should not be used as the primary key of an Intent, 5841 * since it will not result in the app launching with the correct 5842 * action and category. Instead, use this with 5843 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5844 * Intent with this category in the selector.</p> 5845 */ 5846 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5847 public static final String CATEGORY_APP_WEATHER = "android.intent.category.APP_WEATHER"; 5848 5849 /** 5850 * Used with {@link #ACTION_MAIN} to launch the fitness application. 5851 * The activity should be able to give the user fitness information and manage workouts 5852 * <p>NOTE: This should not be used as the primary key of an Intent, 5853 * since it will not result in the app launching with the correct 5854 * action and category. Instead, use this with 5855 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5856 * Intent with this category in the selector.</p> 5857 */ 5858 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5859 public static final String CATEGORY_APP_FITNESS = "android.intent.category.APP_FITNESS"; 5860 5861 // --------------------------------------------------------------------- 5862 // --------------------------------------------------------------------- 5863 // Standard extra data keys. 5864 5865 /** 5866 * The initial data to place in a newly created record. Use with 5867 * {@link #ACTION_INSERT}. The data here is a Map containing the same 5868 * fields as would be given to the underlying ContentProvider.insert() 5869 * call. 5870 */ 5871 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; 5872 5873 /** 5874 * A constant CharSequence that is associated with the Intent, used with 5875 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that 5876 * this may be a styled CharSequence, so you must use 5877 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to 5878 * retrieve it. 5879 */ 5880 public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; 5881 5882 /** 5883 * A constant String that is associated with the Intent, used with 5884 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} 5885 * as HTML formatted text. Note that you <em>must</em> also supply 5886 * {@link #EXTRA_TEXT}. 5887 */ 5888 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; 5889 5890 /** 5891 * A content: URI holding a stream of data associated with the Intent, 5892 * used with {@link #ACTION_SEND} to supply the data being sent. 5893 */ 5894 public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; 5895 5896 /** 5897 * A String[] holding e-mail addresses that should be delivered to. 5898 */ 5899 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; 5900 5901 /** 5902 * A String[] holding e-mail addresses that should be carbon copied. 5903 */ 5904 public static final String EXTRA_CC = "android.intent.extra.CC"; 5905 5906 /** 5907 * A String[] holding e-mail addresses that should be blind carbon copied. 5908 */ 5909 public static final String EXTRA_BCC = "android.intent.extra.BCC"; 5910 5911 /** 5912 * A constant string holding the desired subject line of a message. 5913 */ 5914 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; 5915 5916 /** 5917 * An Intent describing the choices you would like shown with 5918 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. 5919 */ 5920 public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; 5921 5922 /** 5923 * An int representing the user ID to be used. 5924 * 5925 * @hide 5926 */ 5927 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; 5928 5929 /** 5930 * An int representing the task id to be retrieved. This is used when a launch from recents is 5931 * intercepted by another action such as credentials confirmation to remember which task should 5932 * be resumed when complete. 5933 * 5934 * @hide 5935 */ 5936 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; 5937 5938 /** 5939 * A String[] holding attribution tags when used with 5940 * {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5941 * and ACTION_MANAGE_PERMISSION_USAGE 5942 * 5943 * E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc. 5944 */ 5945 public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS"; 5946 5947 /** 5948 * A long representing the start timestamp (epoch time in millis) of the permission usage 5949 * when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5950 * and ACTION_MANAGE_PERMISSION_USAGE 5951 */ 5952 public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME"; 5953 5954 /** 5955 * A long representing the end timestamp (epoch time in millis) of the permission usage when 5956 * used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5957 * and ACTION_MANAGE_PERMISSION_USAGE 5958 */ 5959 public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME"; 5960 5961 /** 5962 * A boolean extra, when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5963 * and {@link #ACTION_MANAGE_PERMISSION_USAGE}, 5964 * that specifies whether the permission usage system UI is showing attribution information 5965 * for the chosen entry. 5966 * 5967 * <p> The extra can only be true if application has specified attributionsAreUserVisible 5968 * in its manifest. </p> 5969 * 5970 * <p> Applications can use this extra to improve their permission usage explanation 5971 * experience. </p> 5972 * @hide 5973 */ 5974 @SystemApi 5975 public static final String EXTRA_SHOWING_ATTRIBUTION = 5976 "android.intent.extra.SHOWING_ATTRIBUTION"; 5977 5978 /** 5979 * An Intent[] describing additional, alternate choices you would like shown with 5980 * {@link #ACTION_CHOOSER}. 5981 * 5982 * <p>An app may be capable of providing several different payload types to complete a 5983 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos 5984 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer 5985 * several different supported sending mechanisms for sharing, such as the actual "image/*" 5986 * photo data or a hosted link where the photos can be viewed.</p> 5987 * 5988 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the 5989 * first/primary/preferred intent in the set. Additional intents specified in 5990 * this extra are ordered; by default intents that appear earlier in the array will be 5991 * preferred over intents that appear later in the array as matches for the same 5992 * target component. To alter this preference, a calling app may also supply 5993 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> 5994 */ 5995 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; 5996 5997 /** 5998 * A {@link ComponentName ComponentName[]} describing components that should be filtered out 5999 * and omitted from a list of components presented to the user. 6000 * 6001 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components 6002 * in this array if it otherwise would have shown them. Useful for omitting specific targets 6003 * from your own package or other apps from your organization if the idea of sending to those 6004 * targets would be redundant with other app functionality. Filtered components will not 6005 * be able to present targets from an associated <code>ChooserTargetService</code>.</p> 6006 */ 6007 public static final String EXTRA_EXCLUDE_COMPONENTS 6008 = "android.intent.extra.EXCLUDE_COMPONENTS"; 6009 6010 /** 6011 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} 6012 * describing additional high-priority deep-link targets for the chooser to present to the user. 6013 * 6014 * <p>Targets provided in this way will be presented inline with all other targets provided 6015 * by services from other apps. They will be prioritized before other service targets, but 6016 * after those targets provided by sources that the user has manually pinned to the front. 6017 * You can provide up to two targets on this extra (the limit of two targets 6018 * starts in Android 10).</p> 6019 * 6020 * @see #ACTION_CHOOSER 6021 */ 6022 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; 6023 6024 /** 6025 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection 6026 * from the chooser activity presented by {@link #ACTION_CHOOSER}. 6027 * 6028 * <p>An app preparing an action for another app to complete may wish to allow the user to 6029 * disambiguate between several options for completing the action based on the chosen target 6030 * or otherwise refine the action before it is invoked. 6031 * </p> 6032 * 6033 * <p>When sent, this IntentSender may be filled in with the following extras:</p> 6034 * <ul> 6035 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> 6036 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's 6037 * chosen target beyond the first</li> 6038 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity 6039 * should fill in and send once the disambiguation is complete</li> 6040 * </ul> 6041 */ 6042 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER 6043 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; 6044 6045 /** 6046 * A Parcelable[] of {@link ChooserAction} objects to provide the Android Sharesheet with 6047 * app-specific actions to be presented to the user when invoking {@link #ACTION_CHOOSER}. 6048 * You can provide as many as five custom actions. 6049 */ 6050 public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS = 6051 "android.intent.extra.CHOOSER_CUSTOM_ACTIONS"; 6052 6053 /** 6054 * Optional argument to be used with {@link #ACTION_CHOOSER}. 6055 * A {@link ChooserAction} to allow the user to modify what is being shared in some way. This 6056 * may be integrated into the content preview on sharesheets that have a preview UI. 6057 */ 6058 public static final String EXTRA_CHOOSER_MODIFY_SHARE_ACTION = 6059 "android.intent.extra.CHOOSER_MODIFY_SHARE_ACTION"; 6060 6061 /** 6062 * Optional integer extra to be used with {@link #ACTION_CHOOSER} to describe conteng being 6063 * shared. 6064 * <p> 6065 * If provided, sharesheets may customize their UI presentation to include a more precise 6066 * description of the content being shared. 6067 * 6068 * @see #CHOOSER_CONTENT_TYPE_ALBUM 6069 * @see #createChooser(Intent, CharSequence) 6070 */ 6071 @FlaggedApi(android.service.chooser.Flags.FLAG_CHOOSER_ALBUM_TEXT) 6072 public static final String EXTRA_CHOOSER_CONTENT_TYPE_HINT = 6073 "android.intent.extra.CHOOSER_CONTENT_TYPE_HINT"; 6074 6075 /** @hide */ 6076 @IntDef(prefix = {"CHOOSER_CONTENT_TYPE_"}, value = { 6077 CHOOSER_CONTENT_TYPE_ALBUM, 6078 }) 6079 @Retention(RetentionPolicy.SOURCE) 6080 public @interface ChooserContentType {} 6081 6082 /** 6083 * Indicates that the content being shared with {@link #ACTION_SEND} represents an album 6084 * (e.g. containing photos). 6085 * 6086 * @see #EXTRA_CHOOSER_CONTENT_TYPE_HINT 6087 */ 6088 @FlaggedApi(android.service.chooser.Flags.FLAG_CHOOSER_ALBUM_TEXT) 6089 public static final int CHOOSER_CONTENT_TYPE_ALBUM = 1; 6090 6091 /** 6092 * Optional argument used to provide a {@link ContentProvider} {@link Uri} to an 6093 * {@link #ACTION_CHOOSER} Intent which allows additional toggleable items to be included 6094 * in the sharing UI. 6095 * <p> 6096 * For example, this could be used to show photos being shared in the context of the user's 6097 * entire photo roll, with the option to change the set of photos being shared. 6098 * <p> 6099 * When this is provided in an {@link #ACTION_CHOOSER} Intent with an {@link #ACTION_SEND} or 6100 * {@link #ACTION_SEND_MULTIPLE} target Intent, the sharesheet will query (see 6101 * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)}) this URI to 6102 * retrieve a set of additional items available for selection. The set of items returned by the 6103 * content provider is expected to contain all the items from the {@link #EXTRA_STREAM} 6104 * argument, in their relative order, which will be marked as selected. The URI's authority 6105 * must be different from any shared items URI provided in {@link #EXTRA_STREAM} or returned by 6106 * the provider. 6107 * 6108 * <p>The {@link Bundle} argument of the 6109 * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)} 6110 * method will contains the original intent Chooser has been launched with under the 6111 * {@link #EXTRA_INTENT} key as a context for the current sharing session. The returned 6112 * {@link android.database.Cursor} should contain: 6113 * <ul> 6114 * <li>{@link android.service.chooser.AdditionalContentContract.Columns#URI} column for the item 6115 * URI.</li> 6116 * <li>Optional columns {@link MediaStore.MediaColumns#WIDTH} and 6117 * {@link MediaStore.MediaColumns#HEIGHT} for the dimensions of the preview image. 6118 * These columns can also be returned for each {@link #EXTRA_STREAM} item metadata 6119 * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)} call.</li> 6120 * <li>Optional {@link AdditionalContentContract.CursorExtraKeys#POSITION} extra that 6121 * specifies the cursor starting position; the item at this position is expected to match the 6122 * item specified by {@link #EXTRA_CHOOSER_FOCUSED_ITEM_POSITION}.</li></ul></p> 6123 * 6124 * <p>When the user makes a selection change, 6125 * {@link ContentProvider#call(String, String, Bundle)} method will be invoked with the "method" 6126 * argument set to 6127 * {@link android.service.chooser.AdditionalContentContract.MethodNames#ON_SELECTION_CHANGED}, 6128 * the "arg" argument set to this argument's value, and the "extras" {@link Bundle} argument 6129 * containing {@link #EXTRA_INTENT} key containing the original intent Chooser has been launched 6130 * with but with the modified target intent --Chooser will modify the target intent according to 6131 * the selection changes made by the user. 6132 * Applications may implement this method to change any of the following Chooser arguments by 6133 * returning new values in the result bundle: 6134 * {@link #EXTRA_CHOOSER_TARGETS}, 6135 * {@link #EXTRA_ALTERNATE_INTENTS}, 6136 * {@link #EXTRA_CHOOSER_CUSTOM_ACTIONS}, 6137 * {@link #EXTRA_CHOOSER_MODIFY_SHARE_ACTION}, 6138 * {@link #EXTRA_METADATA_TEXT}, 6139 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}, 6140 * {@link #EXTRA_CHOOSER_RESULT_INTENT_SENDER}. 6141 * </p> 6142 */ 6143 @FlaggedApi(android.service.chooser.Flags.FLAG_CHOOSER_PAYLOAD_TOGGLING) 6144 public static final String EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI = 6145 "android.intent.extra.CHOOSER_ADDITIONAL_CONTENT_URI"; 6146 6147 /** 6148 * Optional argument to be used with {@link #EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI}, used in 6149 * combination with {@link #EXTRA_CHOOSER_ADDITIONAL_CONTENT_URI}. 6150 * An integer, zero-based index into {@link #EXTRA_STREAM} argument indicating the item that 6151 * should be focused by the Chooser in preview. 6152 */ 6153 @FlaggedApi(android.service.chooser.Flags.FLAG_CHOOSER_PAYLOAD_TOGGLING) 6154 public static final String EXTRA_CHOOSER_FOCUSED_ITEM_POSITION = 6155 "android.intent.extra.CHOOSER_FOCUSED_ITEM_POSITION"; 6156 6157 /** 6158 * An {@code ArrayList} of {@code String} annotations describing content for 6159 * {@link #ACTION_CHOOSER}. 6160 * 6161 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a 6162 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> 6163 * 6164 * <p>Annotations should describe the major components or topics of the content. It is up to 6165 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be 6166 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to 6167 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon 6168 * character. Performance on customized annotations can suffer, if they are rarely used for 6169 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the 6170 * following annotations when applicable.</p> 6171 * <ul> 6172 * <li>"product" represents that the topic of the content is mainly about products, e.g., 6173 * health & beauty, and office supplies.</li> 6174 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g., 6175 * happy, and sad.</li> 6176 * <li>"person" represents that the topic of the content is mainly about persons, e.g., 6177 * face, finger, standing, and walking.</li> 6178 * <li>"child" represents that the topic of the content is mainly about children, e.g., 6179 * child, and baby.</li> 6180 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li> 6181 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li> 6182 * <li>"party" represents that the topic of the content is mainly about parties.</li> 6183 * <li>"animal" represent that the topic of the content is mainly about animals.</li> 6184 * <li>"plant" represents that the topic of the content is mainly about plants, e.g., 6185 * flowers.</li> 6186 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li> 6187 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g. 6188 * sunglasses, jewelry, handbags and clothing.</li> 6189 * <li>"material" represents that the topic of the content is mainly about materials, e.g., 6190 * paper, and silk.</li> 6191 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like 6192 * cars, and boats.</li> 6193 * <li>"document" represents that the topic of the content is mainly about documents, e.g. 6194 * posters.</li> 6195 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts 6196 * and designs of houses.</li> 6197 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g., 6198 * Christmas and Thanksgiving.</li> 6199 * </ul> 6200 */ 6201 public static final String EXTRA_CONTENT_ANNOTATIONS 6202 = "android.intent.extra.CONTENT_ANNOTATIONS"; 6203 6204 /** 6205 * A {@link ResultReceiver} used to return data back to the sender. 6206 * 6207 * <p>Used to complete an app-specific 6208 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> 6209 * 6210 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent 6211 * used to start a {@link #ACTION_CHOOSER} activity this extra will be 6212 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent 6213 * when the user selects a target component from the chooser. It is up to the recipient 6214 * to send a result to this ResultReceiver to signal that disambiguation is complete 6215 * and that the chooser should invoke the user's choice.</p> 6216 * 6217 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent 6218 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser 6219 * to match and fill in the final Intent or ChooserTarget before starting it. 6220 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from 6221 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to 6222 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> 6223 * 6224 * <p>The result code passed to the ResultReceiver should be 6225 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's 6226 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if 6227 * the chooser should finish without starting a target.</p> 6228 */ 6229 public static final String EXTRA_RESULT_RECEIVER 6230 = "android.intent.extra.RESULT_RECEIVER"; 6231 6232 /** 6233 * A CharSequence dialog title to provide to the user when used with a 6234 * {@link #ACTION_CHOOSER}. 6235 */ 6236 public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; 6237 6238 /** 6239 * A Parcelable[] of {@link Intent} or 6240 * {@link android.content.pm.LabeledIntent} objects as set with 6241 * {@link #putExtra(String, Parcelable[])} to place 6242 * at the front of the list of choices, when shown to the user with an 6243 * {@link #ACTION_CHOOSER}. You can choose up to two additional activities 6244 * to show before the app suggestions (the limit of two additional activities starts in 6245 * Android 10). 6246 */ 6247 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; 6248 6249 /** 6250 * A CharSequence of additional text describing the content being shared. This text will be 6251 * displayed to the user as a part of the sharesheet when included in an 6252 * {@link #ACTION_CHOOSER} {@link Intent}. 6253 * 6254 * <p>e.g. When sharing a photo, metadata could inform the user that location data is included 6255 * in the photo they are sharing.</p> 6256 */ 6257 @FlaggedApi(FLAG_ENABLE_SHARESHEET_METADATA_EXTRA) 6258 public static final String EXTRA_METADATA_TEXT = "android.intent.extra.METADATA_TEXT"; 6259 6260 /** 6261 * A {@link IntentSender} to start after instant app installation success. 6262 * @hide 6263 */ 6264 @SystemApi 6265 public static final String EXTRA_INSTANT_APP_SUCCESS = 6266 "android.intent.extra.INSTANT_APP_SUCCESS"; 6267 6268 /** 6269 * A {@link IntentSender} to start after instant app installation failure. 6270 * @hide 6271 */ 6272 @SystemApi 6273 public static final String EXTRA_INSTANT_APP_FAILURE = 6274 "android.intent.extra.INSTANT_APP_FAILURE"; 6275 6276 /** 6277 * The host name that triggered an instant app resolution. 6278 * @hide 6279 */ 6280 @SystemApi 6281 public static final String EXTRA_INSTANT_APP_HOSTNAME = 6282 "android.intent.extra.INSTANT_APP_HOSTNAME"; 6283 6284 /** 6285 * An opaque token to track instant app resolution. 6286 * @hide 6287 */ 6288 @SystemApi 6289 public static final String EXTRA_INSTANT_APP_TOKEN = 6290 "android.intent.extra.INSTANT_APP_TOKEN"; 6291 6292 /** 6293 * The action that triggered an instant application resolution. 6294 * @hide 6295 */ 6296 @SystemApi 6297 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION"; 6298 6299 /** 6300 * An array of {@link Bundle}s containing details about resolved instant apps.. 6301 * @hide 6302 */ 6303 @SystemApi 6304 public static final String EXTRA_INSTANT_APP_BUNDLES = 6305 "android.intent.extra.INSTANT_APP_BUNDLES"; 6306 6307 /** 6308 * A {@link Bundle} of metadata that describes the instant application that needs to be 6309 * installed. This data is populated from the response to 6310 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered 6311 * instant application resolver. 6312 * @hide 6313 */ 6314 @SystemApi 6315 public static final String EXTRA_INSTANT_APP_EXTRAS = 6316 "android.intent.extra.INSTANT_APP_EXTRAS"; 6317 6318 /** 6319 * A boolean value indicating that the instant app resolver was unable to state with certainty 6320 * that it did or did not have an app for the sanitized {@link Intent} defined at 6321 * {@link #EXTRA_INTENT}. 6322 * @hide 6323 */ 6324 @SystemApi 6325 public static final String EXTRA_UNKNOWN_INSTANT_APP = 6326 "android.intent.extra.UNKNOWN_INSTANT_APP"; 6327 6328 /** 6329 * The version code of the app to install components from. 6330 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE). 6331 * @hide 6332 */ 6333 @Deprecated 6334 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; 6335 6336 /** 6337 * The version code of the app to install components from. 6338 * @hide 6339 */ 6340 @SystemApi 6341 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE"; 6342 6343 /** 6344 * The app that triggered the instant app installation. 6345 * @hide 6346 */ 6347 @SystemApi 6348 public static final String EXTRA_CALLING_PACKAGE 6349 = "android.intent.extra.CALLING_PACKAGE"; 6350 6351 /** 6352 * Optional calling app provided bundle containing additional launch information the 6353 * installer may use. 6354 * @hide 6355 */ 6356 @SystemApi 6357 public static final String EXTRA_VERIFICATION_BUNDLE 6358 = "android.intent.extra.VERIFICATION_BUNDLE"; 6359 6360 /** 6361 * A Bundle forming a mapping of potential target package names to different extras Bundles 6362 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with 6363 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not 6364 * be currently installed on the device. 6365 * 6366 * <p>An application may choose to provide alternate extras for the case where a user 6367 * selects an activity from a predetermined set of target packages. If the activity 6368 * the user selects from the chooser belongs to a package with its package name as 6369 * a key in this bundle, the corresponding extras for that package will be merged with 6370 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement 6371 * extra has the same key as an extra already present in the intent it will overwrite 6372 * the extra from the intent.</p> 6373 * 6374 * <p><em>Examples:</em> 6375 * <ul> 6376 * <li>An application may offer different {@link #EXTRA_TEXT} to an application 6377 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query 6378 * parameters for that target.</li> 6379 * <li>An application may offer additional metadata for known targets of a given intent 6380 * to pass along information only relevant to that target such as account or content 6381 * identifiers already known to that application.</li> 6382 * </ul></p> 6383 */ 6384 public static final String EXTRA_REPLACEMENT_EXTRAS = 6385 "android.intent.extra.REPLACEMENT_EXTRAS"; 6386 6387 /** 6388 * An {@link IntentSender} that will be notified if a user successfully chooses a target 6389 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender 6390 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the 6391 * {@link ComponentName} of the chosen component. 6392 * 6393 * <p>In some situations this callback may never come, for example if the user abandons 6394 * the chooser, switches to another task or any number of other reasons. Apps should not 6395 * be written assuming that this callback will always occur.</p> 6396 */ 6397 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = 6398 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; 6399 6400 /** 6401 * An {@link IntentSender} that will be notified when a user successfully chooses a target 6402 * component or initiates an action such as copy or edit within an {@link #ACTION_CHOOSER} 6403 * activity. The IntentSender will have the extra {@link #EXTRA_CHOOSER_RESULT} describing 6404 * the result. 6405 */ 6406 @FlaggedApi(android.service.chooser.Flags.FLAG_ENABLE_CHOOSER_RESULT) 6407 public static final String EXTRA_CHOOSER_RESULT_INTENT_SENDER = 6408 "android.intent.extra.CHOOSER_RESULT_INTENT_SENDER"; 6409 6410 /** 6411 * A {@link ChooserResult} which describes how the sharing session completed. 6412 * <p> 6413 * An instance is supplied to the optional IntentSender provided to 6414 * {@link #createChooser(Intent, CharSequence, IntentSender)} when the session completes. 6415 */ 6416 @FlaggedApi(android.service.chooser.Flags.FLAG_ENABLE_CHOOSER_RESULT) 6417 public static final String EXTRA_CHOOSER_RESULT = "android.intent.extra.CHOOSER_RESULT"; 6418 6419 /** 6420 * The {@link ComponentName} chosen by the user to complete an action. 6421 * 6422 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER 6423 */ 6424 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; 6425 6426 /** 6427 * A {@link android.view.KeyEvent} object containing the event that 6428 * triggered the creation of the Intent it is in. 6429 */ 6430 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; 6431 6432 /** 6433 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user 6434 * before shutting down. 6435 * 6436 * {@hide} 6437 */ 6438 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; 6439 6440 /** 6441 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is 6442 * requested by the user. 6443 * 6444 * {@hide} 6445 */ 6446 public static final String EXTRA_USER_REQUESTED_SHUTDOWN = 6447 "android.intent.extra.USER_REQUESTED_SHUTDOWN"; 6448 6449 /** 6450 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 6451 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action 6452 * of restarting the application. 6453 */ 6454 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; 6455 6456 /** 6457 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6458 * intents to signal that the application was removed with the user-initiated action. 6459 */ 6460 public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED"; 6461 6462 /** 6463 * A String holding the phone number originally entered in 6464 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual 6465 * number to call in a {@link android.content.Intent#ACTION_CALL}. 6466 */ 6467 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; 6468 6469 /** 6470 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} 6471 * intents to supply the uid the package had been assigned. Also an optional 6472 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 6473 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same 6474 * purpose. 6475 */ 6476 public static final String EXTRA_UID = "android.intent.extra.UID"; 6477 6478 /** 6479 * String array of package names. 6480 */ 6481 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; 6482 6483 /** 6484 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6485 * intents to indicate whether this represents a full uninstall (removing 6486 * both the code and its data) or a partial uninstall (leaving its data, 6487 * implying that this is an update). 6488 */ 6489 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; 6490 6491 /** 6492 * @hide 6493 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6494 * intents to indicate that at this point the package has been removed for 6495 * all users on the device. 6496 */ 6497 public static final String EXTRA_REMOVED_FOR_ALL_USERS 6498 = "android.intent.extra.REMOVED_FOR_ALL_USERS"; 6499 6500 /** 6501 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6502 * intents to indicate that this is a replacement of the package, so this 6503 * broadcast will immediately be followed by an add broadcast for a 6504 * different version of the same package. 6505 */ 6506 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING"; 6507 6508 /** 6509 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_ADDED} and 6510 * {@link android.content.Intent#ACTION_PACKAGE_REMOVED} intents to indicate that 6511 * the package is being archived. Either by removing the existing APK, or by installing 6512 * a package without an APK. 6513 */ 6514 @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING) 6515 public static final String EXTRA_ARCHIVAL = "android.intent.extra.ARCHIVAL"; 6516 6517 /** 6518 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6519 * intents to indicate that this is a system update uninstall. 6520 * @hide 6521 */ 6522 public static final String EXTRA_SYSTEM_UPDATE_UNINSTALL = 6523 "android.intent.extra.SYSTEM_UPDATE_UNINSTALL"; 6524 6525 /** 6526 * Used as an int extra field in {@link android.app.AlarmManager} pending intents 6527 * to tell the application being invoked how many pending alarms are being 6528 * delivered with the intent. For one-shot alarms this will always be 1. 6529 * For recurring alarms, this might be greater than 1 if the device was 6530 * asleep or powered off at the time an earlier alarm would have been 6531 * delivered. 6532 * 6533 * <p>Note: You must supply a <b>mutable</b> {@link android.app.PendingIntent} to 6534 * {@code AlarmManager} while setting your alarms to be able to read this value on receiving 6535 * them. <em>Mutability of pending intents must be explicitly specified by apps targeting 6536 * {@link Build.VERSION_CODES#S} or higher</em>. 6537 * 6538 * @see android.app.PendingIntent#FLAG_MUTABLE 6539 * 6540 */ 6541 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; 6542 6543 /** 6544 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} 6545 * intents to request the dock state. Possible values are 6546 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, 6547 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or 6548 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or 6549 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or 6550 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. 6551 */ 6552 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; 6553 6554 /** 6555 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6556 * to represent that the phone is not in any dock. 6557 */ 6558 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; 6559 6560 /** 6561 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6562 * to represent that the phone is in a desk dock. 6563 */ 6564 public static final int EXTRA_DOCK_STATE_DESK = 1; 6565 6566 /** 6567 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6568 * to represent that the phone is in a car dock. 6569 */ 6570 public static final int EXTRA_DOCK_STATE_CAR = 2; 6571 6572 /** 6573 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6574 * to represent that the phone is in a analog (low end) dock. 6575 */ 6576 public static final int EXTRA_DOCK_STATE_LE_DESK = 3; 6577 6578 /** 6579 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6580 * to represent that the phone is in a digital (high end) dock. 6581 */ 6582 public static final int EXTRA_DOCK_STATE_HE_DESK = 4; 6583 6584 /** 6585 * Boolean that can be supplied as meta-data with a dock activity, to 6586 * indicate that the dock should take over the home key when it is active. 6587 */ 6588 public static final String METADATA_DOCK_HOME = "android.dock_home"; 6589 6590 /** 6591 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing 6592 * the bug report. 6593 */ 6594 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; 6595 6596 /** 6597 * Used in the extra field in the remote intent. It's a string token passed with the 6598 * remote intent. 6599 */ 6600 public static final String EXTRA_REMOTE_INTENT_TOKEN = 6601 "android.intent.extra.remote_intent_token"; 6602 6603 /** 6604 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field 6605 * will contain only the first name in the list. 6606 */ 6607 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = 6608 "android.intent.extra.changed_component_name"; 6609 6610 /** 6611 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, 6612 * and contains a string array of all of the components that have changed. If 6613 * the state of the overall package has changed, then it will contain an entry 6614 * with the package name itself. 6615 */ 6616 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = 6617 "android.intent.extra.changed_component_name_list"; 6618 6619 /** 6620 * This field is part of 6621 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 6622 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, 6623 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, 6624 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} 6625 * and contains a string array of all of the components that have changed. 6626 */ 6627 public static final String EXTRA_CHANGED_PACKAGE_LIST = 6628 "android.intent.extra.changed_package_list"; 6629 6630 /** 6631 * This field is part of 6632 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 6633 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 6634 * and contains an integer array of uids of all of the components 6635 * that have changed. 6636 */ 6637 public static final String EXTRA_CHANGED_UID_LIST = 6638 "android.intent.extra.changed_uid_list"; 6639 6640 /** 6641 * This field is part of 6642 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, 6643 * and only present if the packages were quarantined. 6644 * @hide 6645 */ 6646 public static final String EXTRA_QUARANTINED = 6647 "android.intent.extra.quarantined"; 6648 6649 /** 6650 * An integer denoting a bitwise combination of restrictions set on distracting packages via 6651 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)} 6652 * 6653 * @hide 6654 * @see PackageManager.DistractionRestriction 6655 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 6656 */ 6657 public static final String EXTRA_DISTRACTION_RESTRICTIONS = 6658 "android.intent.extra.distraction_restrictions"; 6659 6660 /** 6661 * @hide 6662 * Magic extra system code can use when binding, to give a label for 6663 * who it is that has bound to a service. This is an integer giving 6664 * a framework string resource that can be displayed to the user. 6665 */ 6666 public static final String EXTRA_CLIENT_LABEL = 6667 "android.intent.extra.client_label"; 6668 6669 /** 6670 * @hide 6671 * Magic extra system code can use when binding, to give a PendingIntent object 6672 * that can be launched for the user to disable the system's use of this 6673 * service. 6674 */ 6675 public static final String EXTRA_CLIENT_INTENT = 6676 "android.intent.extra.client_intent"; 6677 6678 /** 6679 * Extra used to indicate that an intent should only return data that is on 6680 * the local device. This is a boolean extra; the default is false. If true, 6681 * an implementation should only allow the user to select data that is 6682 * already on the device, not requiring it be downloaded from a remote 6683 * service when opened. 6684 * 6685 * @see #ACTION_GET_CONTENT 6686 * @see #ACTION_OPEN_DOCUMENT 6687 * @see #ACTION_OPEN_DOCUMENT_TREE 6688 * @see #ACTION_CREATE_DOCUMENT 6689 */ 6690 public static final String EXTRA_LOCAL_ONLY = 6691 "android.intent.extra.LOCAL_ONLY"; 6692 6693 /** 6694 * Extra used to indicate that an intent can allow the user to select and 6695 * return multiple items. This is a boolean extra; the default is false. If 6696 * true, an implementation is allowed to present the user with a UI where 6697 * they can pick multiple items that are all returned to the caller. When 6698 * this happens, they should be returned as the {@link #getClipData()} part 6699 * of the result Intent. 6700 * 6701 * @see #ACTION_GET_CONTENT 6702 * @see #ACTION_OPEN_DOCUMENT 6703 */ 6704 public static final String EXTRA_ALLOW_MULTIPLE = 6705 "android.intent.extra.ALLOW_MULTIPLE"; 6706 6707 /** 6708 * The user ID integer carried with broadcast intents related to addition, 6709 * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED}, 6710 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. 6711 * 6712 * @hide 6713 */ 6714 @SystemApi 6715 @SuppressLint("ActionValue") 6716 public static final String EXTRA_USER_HANDLE = 6717 "android.intent.extra.user_handle"; 6718 6719 /** 6720 * The {@link UserHandle} carried with intents. 6721 */ 6722 public static final String EXTRA_USER = 6723 "android.intent.extra.USER"; 6724 6725 /** 6726 * Extra used in the response from a BroadcastReceiver that handles 6727 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is 6728 * <code>ArrayList<RestrictionEntry></code>. 6729 */ 6730 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; 6731 6732 /** 6733 * Extra sent in the intent to the BroadcastReceiver that handles 6734 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing 6735 * the restrictions as key/value pairs. 6736 */ 6737 public static final String EXTRA_RESTRICTIONS_BUNDLE = 6738 "android.intent.extra.restrictions_bundle"; 6739 6740 /** 6741 * Extra used in the response from a BroadcastReceiver that handles 6742 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. 6743 */ 6744 public static final String EXTRA_RESTRICTIONS_INTENT = 6745 "android.intent.extra.restrictions_intent"; 6746 6747 /** 6748 * Extra used to communicate a set of acceptable MIME types. The type of the 6749 * extra is {@code String[]}. Values may be a combination of concrete MIME 6750 * types (such as "image/png") and/or partial MIME types (such as 6751 * "audio/*"). 6752 * 6753 * @see #ACTION_GET_CONTENT 6754 * @see #ACTION_OPEN_DOCUMENT 6755 */ 6756 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; 6757 6758 /** 6759 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that 6760 * this shutdown is only for the user space of the system, not a complete shutdown. 6761 * When this is true, hardware devices can use this information to determine that 6762 * they shouldn't do a complete shutdown of their device since this is not a 6763 * complete shutdown down to the kernel, but only user space restarting. 6764 * The default if not supplied is false. 6765 */ 6766 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY 6767 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; 6768 6769 /** 6770 * Optional extra specifying a time in milliseconds. The timebase depends on the Intent 6771 * including this extra. The value must be non-negative. 6772 * <p> 6773 * Type: long 6774 * </p> 6775 */ 6776 public static final String EXTRA_TIME = "android.intent.extra.TIME"; 6777 6778 /** 6779 * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device. 6780 * 6781 * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones. 6782 */ 6783 @SuppressLint("ActionValue") 6784 public static final String EXTRA_TIMEZONE = "time-zone"; 6785 6786 /** 6787 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the 6788 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, 6789 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and 6790 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative. 6791 * 6792 * @hide for internal use only. 6793 */ 6794 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = 6795 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; 6796 /** @hide */ 6797 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; 6798 /** @hide */ 6799 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; 6800 /** @hide */ 6801 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; 6802 6803 /** 6804 * Intent extra: the reason that the operation associated with this intent is being performed. 6805 * 6806 * <p>Type: String 6807 * @hide 6808 */ 6809 @SystemApi 6810 public static final String EXTRA_REASON = "android.intent.extra.REASON"; 6811 6812 /** 6813 * Intent extra: Whether to show the wipe progress UI or to skip it. 6814 * 6815 * <p>Type: boolean 6816 * @hide 6817 */ 6818 public static final String EXTRA_SHOW_WIPE_PROGRESS = "android.intent.extra.SHOW_WIPE_PROGRESS"; 6819 6820 /** 6821 * {@hide} 6822 * This extra will be send together with {@link #ACTION_FACTORY_RESET} 6823 */ 6824 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; 6825 6826 /** 6827 * {@hide} 6828 * This extra will be set to true when the user choose to wipe the data on eSIM during factory 6829 * reset for the device with eSIM. This extra will be sent together with 6830 * {@link #ACTION_FACTORY_RESET} 6831 */ 6832 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; 6833 6834 /** 6835 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM 6836 * activation request. 6837 * TODO: Add information about the structure and response data used with the pending intent. 6838 * @hide 6839 */ 6840 public static final String EXTRA_SIM_ACTIVATION_RESPONSE = 6841 "android.intent.extra.SIM_ACTIVATION_RESPONSE"; 6842 6843 /** 6844 * Optional index with semantics depending on the intent action. 6845 * 6846 * <p>The value must be an integer greater or equal to 0. 6847 * @see #ACTION_QUICK_VIEW 6848 */ 6849 public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; 6850 6851 /** 6852 * Tells the quick viewer to show additional UI actions suitable for the passed Uris, 6853 * such as opening in other apps, sharing, opening, editing, printing, deleting, 6854 * casting, etc. 6855 * 6856 * <p>The value is boolean. By default false. 6857 * @see #ACTION_QUICK_VIEW 6858 * @removed 6859 */ 6860 @Deprecated 6861 public static final String EXTRA_QUICK_VIEW_ADVANCED = 6862 "android.intent.extra.QUICK_VIEW_ADVANCED"; 6863 6864 /** 6865 * An optional extra of {@code String[]} indicating which quick view features should be made 6866 * available to the user in the quick view UI while handing a 6867 * {@link Intent#ACTION_QUICK_VIEW} intent. 6868 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer. 6869 * Quick viewer can implement features not listed below. 6870 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW}, 6871 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE}, 6872 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND}, 6873 * {@link QuickViewConstants#FEATURE_PRINT}. 6874 * <p> 6875 * Requirements: 6876 * <li>Quick viewer shouldn't show a feature if the feature is absent in 6877 * {@link #EXTRA_QUICK_VIEW_FEATURES}. 6878 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow 6879 * internal policies. 6880 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a 6881 * requirement that the feature be shown. Quick viewer may, according to its own policies, 6882 * disable or hide features. 6883 * 6884 * @see #ACTION_QUICK_VIEW 6885 */ 6886 public static final String EXTRA_QUICK_VIEW_FEATURES = 6887 "android.intent.extra.QUICK_VIEW_FEATURES"; 6888 6889 /** 6890 * Optional boolean extra indicating whether quiet mode has been switched on or off. 6891 * When a profile goes into quiet mode, all apps in the profile are killed and the 6892 * profile user is stopped. Widgets originating from the profile are masked, and app 6893 * launcher icons are grayed out. 6894 */ 6895 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; 6896 6897 /** 6898 * Optional CharSequence extra to provide a search query. 6899 * The format of this query is dependent on the receiving application. 6900 * 6901 * <p>Applicable to {@link Intent} with actions: 6902 * <ul> 6903 * <li>{@link Intent#ACTION_GET_CONTENT}</li> 6904 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li> 6905 * </ul> 6906 */ 6907 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY"; 6908 6909 /** 6910 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} 6911 * intents to specify the resource type granted. Possible values are 6912 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or 6913 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. 6914 * 6915 * @hide 6916 */ 6917 public static final String EXTRA_MEDIA_RESOURCE_TYPE = 6918 "android.intent.extra.MEDIA_RESOURCE_TYPE"; 6919 6920 /** 6921 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify 6922 * whether to show the chooser or not when there is only one application available 6923 * to choose from. 6924 */ 6925 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = 6926 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; 6927 6928 /** 6929 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6930 * to represent that a video codec is allowed to use. 6931 * 6932 * @hide 6933 */ 6934 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; 6935 6936 /** 6937 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6938 * to represent that a audio codec is allowed to use. 6939 * 6940 * @hide 6941 */ 6942 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; 6943 6944 /** 6945 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}. 6946 * 6947 * <p> 6948 * Type: {@link LocusId} 6949 * </p> 6950 */ 6951 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID"; 6952 6953 /** 6954 * Used as an int array extra field in 6955 * {@link android.content.Intent#ACTION_PACKAGE_REMOVED_INTERNAL} 6956 * intents to indicate that visibility allow list of this removed package. 6957 * 6958 * @hide 6959 */ 6960 public static final String EXTRA_VISIBILITY_ALLOW_LIST = 6961 "android.intent.extra.VISIBILITY_ALLOW_LIST"; 6962 6963 /** 6964 * A boolean extra used with {@link #ACTION_PACKAGE_DATA_CLEARED} which indicates if the intent 6965 * is broadcast as part of a restore operation. 6966 * 6967 * @hide 6968 */ 6969 public static final String EXTRA_IS_RESTORE = 6970 "android.intent.extra.IS_RESTORE"; 6971 6972 // --------------------------------------------------------------------- 6973 // --------------------------------------------------------------------- 6974 // Intent flags (see mFlags variable). 6975 6976 /** @hide */ 6977 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6978 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, 6979 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) 6980 @Retention(RetentionPolicy.SOURCE) 6981 public @interface GrantUriMode {} 6982 6983 /** @hide */ 6984 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6985 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) 6986 @Retention(RetentionPolicy.SOURCE) 6987 public @interface AccessUriMode {} 6988 6989 /** 6990 * Test if given mode flags specify an access mode, which must be at least 6991 * read and/or write. 6992 * 6993 * @hide 6994 */ isAccessUriMode(int modeFlags)6995 public static boolean isAccessUriMode(int modeFlags) { 6996 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION 6997 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; 6998 } 6999 7000 /** @hide */ 7001 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 7002 FLAG_GRANT_READ_URI_PERMISSION, 7003 FLAG_GRANT_WRITE_URI_PERMISSION, 7004 FLAG_FROM_BACKGROUND, 7005 FLAG_DEBUG_LOG_RESOLUTION, 7006 FLAG_EXCLUDE_STOPPED_PACKAGES, 7007 FLAG_INCLUDE_STOPPED_PACKAGES, 7008 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, 7009 FLAG_GRANT_PREFIX_URI_PERMISSION, 7010 FLAG_DEBUG_TRIAGED_MISSING, 7011 FLAG_IGNORE_EPHEMERAL, 7012 FLAG_ACTIVITY_MATCH_EXTERNAL, 7013 FLAG_ACTIVITY_NO_HISTORY, 7014 FLAG_ACTIVITY_SINGLE_TOP, 7015 FLAG_ACTIVITY_NEW_TASK, 7016 FLAG_ACTIVITY_MULTIPLE_TASK, 7017 FLAG_ACTIVITY_CLEAR_TOP, 7018 FLAG_ACTIVITY_FORWARD_RESULT, 7019 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 7020 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 7021 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 7022 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 7023 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 7024 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 7025 FLAG_ACTIVITY_NEW_DOCUMENT, 7026 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 7027 FLAG_ACTIVITY_NO_USER_ACTION, 7028 FLAG_ACTIVITY_REORDER_TO_FRONT, 7029 FLAG_ACTIVITY_NO_ANIMATION, 7030 FLAG_ACTIVITY_CLEAR_TASK, 7031 FLAG_ACTIVITY_TASK_ON_HOME, 7032 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 7033 FLAG_ACTIVITY_LAUNCH_ADJACENT, 7034 FLAG_ACTIVITY_REQUIRE_NON_BROWSER, 7035 FLAG_ACTIVITY_REQUIRE_DEFAULT, 7036 FLAG_RECEIVER_REGISTERED_ONLY, 7037 FLAG_RECEIVER_REPLACE_PENDING, 7038 FLAG_RECEIVER_FOREGROUND, 7039 FLAG_RECEIVER_NO_ABORT, 7040 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 7041 FLAG_RECEIVER_BOOT_UPGRADE, 7042 FLAG_RECEIVER_INCLUDE_BACKGROUND, 7043 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 7044 FLAG_RECEIVER_FROM_SHELL, 7045 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 7046 FLAG_RECEIVER_OFFLOAD, 7047 FLAG_RECEIVER_OFFLOAD_FOREGROUND, 7048 }) 7049 @Retention(RetentionPolicy.SOURCE) 7050 public @interface Flags {} 7051 7052 /** @hide */ 7053 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 7054 FLAG_FROM_BACKGROUND, 7055 FLAG_DEBUG_LOG_RESOLUTION, 7056 FLAG_EXCLUDE_STOPPED_PACKAGES, 7057 FLAG_INCLUDE_STOPPED_PACKAGES, 7058 FLAG_DEBUG_TRIAGED_MISSING, 7059 FLAG_IGNORE_EPHEMERAL, 7060 FLAG_ACTIVITY_MATCH_EXTERNAL, 7061 FLAG_ACTIVITY_NO_HISTORY, 7062 FLAG_ACTIVITY_SINGLE_TOP, 7063 FLAG_ACTIVITY_NEW_TASK, 7064 FLAG_ACTIVITY_MULTIPLE_TASK, 7065 FLAG_ACTIVITY_CLEAR_TOP, 7066 FLAG_ACTIVITY_FORWARD_RESULT, 7067 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 7068 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 7069 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 7070 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 7071 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 7072 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 7073 FLAG_ACTIVITY_NEW_DOCUMENT, 7074 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 7075 FLAG_ACTIVITY_NO_USER_ACTION, 7076 FLAG_ACTIVITY_REORDER_TO_FRONT, 7077 FLAG_ACTIVITY_NO_ANIMATION, 7078 FLAG_ACTIVITY_CLEAR_TASK, 7079 FLAG_ACTIVITY_TASK_ON_HOME, 7080 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 7081 FLAG_ACTIVITY_LAUNCH_ADJACENT, 7082 FLAG_RECEIVER_REGISTERED_ONLY, 7083 FLAG_RECEIVER_REPLACE_PENDING, 7084 FLAG_RECEIVER_FOREGROUND, 7085 FLAG_RECEIVER_NO_ABORT, 7086 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 7087 FLAG_RECEIVER_BOOT_UPGRADE, 7088 FLAG_RECEIVER_INCLUDE_BACKGROUND, 7089 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 7090 FLAG_RECEIVER_FROM_SHELL, 7091 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 7092 FLAG_RECEIVER_OFFLOAD, 7093 FLAG_RECEIVER_OFFLOAD_FOREGROUND, 7094 }) 7095 @Retention(RetentionPolicy.SOURCE) 7096 public @interface MutableFlags {} 7097 7098 /** 7099 * If set, the recipient of this Intent will be granted permission to 7100 * perform read operations on the URI in the Intent's data and any URIs 7101 * specified in its ClipData. When applying to an Intent's ClipData, 7102 * all URIs as well as recursive traversals through data or other ClipData 7103 * in Intent items will be granted; only the grant flags of the top-level 7104 * Intent are used. 7105 */ 7106 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; 7107 /** 7108 * If set, the recipient of this Intent will be granted permission to 7109 * perform write operations on the URI in the Intent's data and any URIs 7110 * specified in its ClipData. When applying to an Intent's ClipData, 7111 * all URIs as well as recursive traversals through data or other ClipData 7112 * in Intent items will be granted; only the grant flags of the top-level 7113 * Intent are used. 7114 */ 7115 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; 7116 /** 7117 * Can be set by the caller to indicate that this Intent is coming from 7118 * a background operation, not from direct user interaction. 7119 */ 7120 public static final int FLAG_FROM_BACKGROUND = 0x00000004; 7121 /** 7122 * A flag you can enable for debugging: when set, log messages will be 7123 * printed during the resolution of this intent to show you what has 7124 * been found to create the final resolved list. 7125 */ 7126 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; 7127 /** 7128 * If set, this intent will not match any components in packages that 7129 * are currently 7130 * {@linkplain android.content.pm.ApplicationInfo#FLAG_STOPPED stopped}. 7131 * If this is not set, then the default behavior is to include such 7132 * applications in the result. 7133 */ 7134 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; 7135 /** 7136 * If set, this intent will always match any components in packages that 7137 * are currently 7138 * {@linkplain android.content.pm.ApplicationInfo#FLAG_STOPPED stopped}. 7139 * This is the default behavior when 7140 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these 7141 * flags are set, this one wins (it allows overriding of exclude for 7142 * places where the framework may automatically set the exclude flag, 7143 * such as broadcasts). 7144 */ 7145 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; 7146 7147 /** 7148 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 7149 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be 7150 * persisted across device reboots until explicitly revoked with 7151 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the 7152 * grant for possible persisting; the receiving application must call 7153 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to 7154 * actually persist. 7155 * 7156 * @see ContentResolver#takePersistableUriPermission(Uri, int) 7157 * @see ContentResolver#releasePersistableUriPermission(Uri, int) 7158 * @see ContentResolver#getPersistedUriPermissions() 7159 * @see ContentResolver#getOutgoingPersistedUriPermissions() 7160 */ 7161 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; 7162 7163 /** 7164 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 7165 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant 7166 * applies to any URI that is a prefix match against the original granted 7167 * URI. (Without this flag, the URI must match exactly for access to be 7168 * granted.) Another URI is considered a prefix match only when scheme, 7169 * authority, and all path segments defined by the prefix are an exact 7170 * match. 7171 */ 7172 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; 7173 7174 /** 7175 * Flag used to automatically match intents based on their Direct Boot 7176 * awareness and the current user state. 7177 * <p> 7178 * Since the default behavior is to automatically apply the current user 7179 * state, this is effectively a sentinel value that doesn't change the 7180 * output of any queries based on its presence or absence. 7181 * <p> 7182 * Instead, this value can be useful in conjunction with 7183 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()} 7184 * to detect when a caller is relying on implicit automatic matching, 7185 * instead of confirming the explicit behavior they want. 7186 */ 7187 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100; 7188 7189 /** {@hide} */ 7190 @Deprecated 7191 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO; 7192 7193 /** 7194 * Internal flag used to indicate ephemeral applications should not be 7195 * considered when resolving the intent. 7196 * 7197 * @hide 7198 */ 7199 public static final int FLAG_IGNORE_EPHEMERAL = 0x80000000; 7200 7201 /** 7202 * If set, the new activity is not kept in the history stack. As soon as 7203 * the user navigates away from it, the activity is finished. This may also 7204 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory 7205 * noHistory} attribute. 7206 * 7207 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} 7208 * is never invoked when the current activity starts a new activity which 7209 * sets a result and finishes. 7210 */ 7211 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; 7212 /** 7213 * If set, the activity will not be launched if it is already running 7214 * at the top of the history stack. See 7215 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes"> 7216 * Tasks and Back Stack</a> for more information. 7217 */ 7218 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; 7219 /** 7220 * If set, this activity will become the start of a new task on this 7221 * history stack. A task (from the activity that started it to the 7222 * next task activity) defines an atomic group of activities that the 7223 * user can move to. Tasks can be moved to the foreground and background; 7224 * all of the activities inside of a particular task always remain in 7225 * the same order. See 7226 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 7227 * Stack</a> for more information about tasks. 7228 * 7229 * <p>This flag is generally used by activities that want 7230 * to present a "launcher" style behavior: they give the user a list of 7231 * separate things that can be done, which otherwise run completely 7232 * independently of the activity launching them. 7233 * 7234 * <p>When using this flag, if a task is already running for the activity 7235 * you are now starting, then a new activity will not be started; instead, 7236 * the current task will simply be brought to the front of the screen with 7237 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag 7238 * to disable this behavior. 7239 * 7240 * <p>This flag can not be used when the caller is requesting a result from 7241 * the activity being launched. 7242 */ 7243 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; 7244 /** 7245 * This flag is used to create a new task and launch an activity into it. 7246 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} 7247 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would 7248 * search through existing tasks for ones matching this Intent. Only if no such 7249 * task is found would a new task be created. When paired with 7250 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip 7251 * the search for a matching task and unconditionally start a new task. 7252 * 7253 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this 7254 * flag unless you are implementing your own 7255 * top-level application launcher.</strong> Used in conjunction with 7256 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the 7257 * behavior of bringing an existing task to the foreground. When set, 7258 * a new task is <em>always</em> started to host the Activity for the 7259 * Intent, regardless of whether there is already an existing task running 7260 * the same thing. 7261 * 7262 * <p><strong>Because the default system does not include graphical task management, 7263 * you should not use this flag unless you provide some way for a user to 7264 * return back to the tasks you have launched.</strong> 7265 * 7266 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for 7267 * creating new document tasks. 7268 * 7269 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or 7270 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. 7271 * 7272 * <p>See 7273 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 7274 * Stack</a> for more information about tasks. 7275 * 7276 * @see #FLAG_ACTIVITY_NEW_DOCUMENT 7277 * @see #FLAG_ACTIVITY_NEW_TASK 7278 */ 7279 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; 7280 /** 7281 * If set, and the activity being launched is already running in the 7282 * current task, then instead of launching a new instance of that activity, 7283 * all of the other activities on top of it will be closed and this Intent 7284 * will be delivered to the (now on top) old activity as a new Intent. 7285 * 7286 * <p>For example, consider a task consisting of the activities: A, B, C, D. 7287 * If D calls startActivity() with an Intent that resolves to the component 7288 * of activity B, then C and D will be finished and B receive the given 7289 * Intent, resulting in the stack now being: A, B. 7290 * 7291 * <p>The currently running instance of activity B in the above example will 7292 * either receive the new intent you are starting here in its 7293 * onNewIntent() method, or be itself finished and restarted with the 7294 * new intent. If it has declared its launch mode to be "multiple" (the 7295 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in 7296 * the same intent, then it will be finished and re-created; for all other 7297 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this 7298 * Intent will be delivered to the current instance's onNewIntent(). 7299 * 7300 * <p>This launch mode can also be used to good effect in conjunction with 7301 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity 7302 * of a task, it will bring any currently running instance of that task 7303 * to the foreground, and then clear it to its root state. This is 7304 * especially useful, for example, when launching an activity from the 7305 * notification manager. 7306 * 7307 * <p>See 7308 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 7309 * Stack</a> for more information about tasks. 7310 */ 7311 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; 7312 /** 7313 * If set and this intent is being used to launch a new activity from an 7314 * existing one, then the reply target of the existing activity will be 7315 * transferred to the new activity. This way, the new activity can call 7316 * {@link android.app.Activity#setResult} and have that result sent back to 7317 * the reply target of the original activity. 7318 */ 7319 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; 7320 /** 7321 * If set and this intent is being used to launch a new activity from an 7322 * existing one, the current activity will not be counted as the top 7323 * activity for deciding whether the new intent should be delivered to 7324 * the top instead of starting a new one. The previous activity will 7325 * be used as the top, with the assumption being that the current activity 7326 * will finish itself immediately. 7327 */ 7328 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; 7329 /** 7330 * If set, the new activity is not kept in the list of recently launched 7331 * activities. 7332 */ 7333 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; 7334 /** 7335 * This flag is not normally set by application code, but set for you by 7336 * the system as described in the 7337 * {@link android.R.styleable#AndroidManifestActivity_launchMode 7338 * launchMode} documentation for the singleTask mode. 7339 */ 7340 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; 7341 /** 7342 * If set, and this activity is either being started in a new task or 7343 * bringing to the top an existing task, then it will be launched as 7344 * the front door of the task. This will result in the application of 7345 * any affinities needed to have that task in the proper state (either 7346 * moving activities to or from it), or simply resetting that task to 7347 * its initial state if needed. 7348 * 7349 * @see android.R.attr#allowTaskReparenting 7350 * @see android.R.attr#clearTaskOnLaunch 7351 * @see android.R.attr#finishOnTaskLaunch 7352 */ 7353 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; 7354 /** 7355 * This flag is not normally set by application code, but set for you by 7356 * the system if this activity is being launched from history. 7357 */ 7358 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; 7359 /** 7360 * @deprecated As of API 21 this performs identically to 7361 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. 7362 */ 7363 @Deprecated 7364 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; 7365 /** 7366 * This flag is used to open a document into a new task rooted at the activity launched 7367 * by this Intent. Through the use of this flag, or its equivalent attribute, 7368 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity 7369 * containing different documents will appear in the recent tasks list. 7370 * 7371 * <p>The use of the activity attribute form of this, 7372 * {@link android.R.attr#documentLaunchMode}, is 7373 * preferred over the Intent flag described here. The attribute form allows the 7374 * Activity to specify multiple document behavior for all launchers of the Activity 7375 * whereas using this flag requires each Intent that launches the Activity to specify it. 7376 * 7377 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for 7378 * it is kept after the activity is finished is different than the use of 7379 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if 7380 * this flag is being used to create a new recents entry, then by default that entry 7381 * will be removed once the activity is finished. You can modify this behavior with 7382 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. 7383 * 7384 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link 7385 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the 7386 * equivalent of the Activity manifest specifying {@link 7387 * android.R.attr#documentLaunchMode}="intoExisting". When used with 7388 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying 7389 * {@link android.R.attr#documentLaunchMode}="always". The flag is ignored even in 7390 * conjunction with {@link #FLAG_ACTIVITY_MULTIPLE_TASK} when the Activity manifest specifies 7391 * {@link android.R.attr#documentLaunchMode}="never". 7392 * 7393 * Refer to {@link android.R.attr#documentLaunchMode} for more information. 7394 * 7395 * @see android.R.attr#documentLaunchMode 7396 * @see #FLAG_ACTIVITY_MULTIPLE_TASK 7397 */ 7398 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; 7399 /** 7400 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} 7401 * callback from occurring on the current frontmost activity before it is 7402 * paused as the newly-started activity is brought to the front. 7403 * 7404 * <p>Typically, an activity can rely on that callback to indicate that an 7405 * explicit user action has caused their activity to be moved out of the 7406 * foreground. The callback marks an appropriate point in the activity's 7407 * lifecycle for it to dismiss any notifications that it intends to display 7408 * "until the user has seen them," such as a blinking LED. 7409 * 7410 * <p>If an activity is ever started via any non-user-driven events such as 7411 * phone-call receipt or an alarm handler, this flag should be passed to {@link 7412 * Context#startActivity Context.startActivity}, ensuring that the pausing 7413 * activity does not think the user has acknowledged its notification. 7414 */ 7415 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; 7416 /** 7417 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7418 * this flag will cause the launched activity to be brought to the front of its 7419 * task's history stack if it is already running. 7420 * 7421 * <p>For example, consider a task consisting of four activities: A, B, C, D. 7422 * If D calls startActivity() with an Intent that resolves to the component 7423 * of activity B, then B will be brought to the front of the history stack, 7424 * with this resulting order: A, C, D, B. 7425 * 7426 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also 7427 * specified. 7428 */ 7429 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; 7430 /** 7431 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7432 * this flag will prevent the system from applying an activity transition 7433 * animation to go to the next activity state. This doesn't mean an 7434 * animation will never run -- if another activity change happens that doesn't 7435 * specify this flag before the activity started here is displayed, then 7436 * that transition will be used. This flag can be put to good use 7437 * when you are going to do a series of activity operations but the 7438 * animation seen by the user shouldn't be driven by the first activity 7439 * change but rather a later one. 7440 */ 7441 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; 7442 /** 7443 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7444 * this flag will cause any existing task that would be associated with the 7445 * activity to be cleared before the activity is started. That is, the activity 7446 * becomes the new root of an otherwise empty task, and any old activities 7447 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 7448 */ 7449 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; 7450 /** 7451 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7452 * this flag will cause a newly launching task to be placed on top of the current 7453 * home activity task (if there is one). That is, pressing back from the task 7454 * will always return the user to home even if that was not the last activity they 7455 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 7456 */ 7457 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; 7458 /** 7459 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will 7460 * have its entry in recent tasks removed when the user closes it (with back 7461 * or however else it may finish()). If you would like to instead allow the 7462 * document to be kept in recents so that it can be re-launched, you can use 7463 * this flag. When set and the task's activity is finished, the recents 7464 * entry will remain in the interface for the user to re-launch it, like a 7465 * recents entry for a top-level application. 7466 * <p> 7467 * The receiving activity can override this request with 7468 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling 7469 * {@link android.app.Activity#finishAndRemoveTask() 7470 * Activity.finishAndRemoveTask()}. 7471 */ 7472 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; 7473 7474 /** 7475 * This flag is only used for split-screen multi-window mode. The new activity will be displayed 7476 * adjacent to the one launching it. This can only be used in conjunction with 7477 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is 7478 * required if you want a new instance of an existing activity to be created. 7479 */ 7480 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; 7481 7482 7483 /** 7484 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7485 * this flag will attempt to launch an instant app if no full app on the device can already 7486 * handle the intent. 7487 * <p> 7488 * When attempting to resolve instant apps externally, the following {@link Intent} properties 7489 * are supported: 7490 * <ul> 7491 * <li>{@link Intent#setAction(String)}</li> 7492 * <li>{@link Intent#addCategory(String)}</li> 7493 * <li>{@link Intent#setData(Uri)}</li> 7494 * <li>{@link Intent#setType(String)}</li> 7495 * <li>{@link Intent#setPackage(String)}</li> 7496 * <li>{@link Intent#addFlags(int)}</li> 7497 * </ul> 7498 * <p> 7499 * In the case that no instant app can be found, the installer will be launched to notify the 7500 * user that the intent could not be resolved. On devices that do not support instant apps, 7501 * the flag will be ignored. 7502 */ 7503 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800; 7504 7505 /** 7506 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 7507 * flag will only launch the intent if it resolves to a result that is not a browser. If no such 7508 * result exists, an {@link ActivityNotFoundException} will be thrown. 7509 */ 7510 public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400; 7511 7512 /** 7513 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 7514 * flag will only launch the intent if it resolves to a single result. If no such result exists 7515 * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException} 7516 * will be thrown. 7517 */ 7518 public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200; 7519 7520 /** 7521 * If set, when sending a broadcast only registered receivers will be 7522 * called -- no BroadcastReceiver components will be launched. 7523 */ 7524 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 7525 /** 7526 * If set, when sending a broadcast the new broadcast will replace 7527 * any existing pending broadcast that matches it. Matching is defined 7528 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning 7529 * true for the intents of the two broadcasts. When a match is found, 7530 * the new broadcast (and receivers associated with it) will replace the 7531 * existing one in the pending broadcast list, remaining at the same 7532 * position in the list. 7533 * 7534 * <p>This flag is most typically used with sticky broadcasts, which 7535 * only care about delivering the most recent values of the broadcast 7536 * to their receivers. 7537 */ 7538 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; 7539 /** 7540 * If set, when sending a broadcast the recipient is allowed to run at 7541 * foreground priority, with a shorter timeout interval. During normal 7542 * broadcasts the receivers are not automatically hoisted out of the 7543 * background priority class. 7544 */ 7545 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; 7546 /** 7547 * If set, when sending a broadcast the recipient will be run on the offload queue. 7548 * 7549 * @hide 7550 */ 7551 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000; 7552 /** 7553 * If set, when sending a broadcast the recipient will run on the system dedicated queue. 7554 * 7555 * @hide 7556 */ 7557 public static final int FLAG_RECEIVER_OFFLOAD_FOREGROUND = 0x00000800; 7558 7559 /** 7560 * If this is an ordered broadcast, don't allow receivers to abort the broadcast. 7561 * They can still propagate results through to later receivers, but they can not prevent 7562 * later receivers from seeing the broadcast. 7563 */ 7564 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; 7565 /** 7566 * If set, when sending a broadcast <i>before the system has fully booted up 7567 * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only 7568 * registered receivers will be called -- no BroadcastReceiver components 7569 * will be launched. Sticky intent state will be recorded properly even 7570 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} 7571 * is specified in the broadcast intent, this flag is unnecessary. 7572 * 7573 * <p>This flag is only for use by system services (even services from mainline modules) as a 7574 * convenience to avoid having to implement a more complex mechanism around detection 7575 * of boot completion. 7576 * 7577 * <p>This is useful to system server mainline modules 7578 * 7579 * @hide 7580 */ 7581 @SystemApi 7582 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; 7583 /** 7584 * Set when this broadcast is for a boot upgrade, a special mode that 7585 * allows the broadcast to be sent before the system is ready and launches 7586 * the app process with no providers running in it. 7587 * @hide 7588 */ 7589 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; 7590 /** 7591 * If set, the broadcast will always go to manifest receivers in background (cached 7592 * or not running) apps, regardless of whether that would be done by default. By 7593 * default they will only receive broadcasts if the broadcast has specified an 7594 * explicit component or package name. 7595 * 7596 * NOTE: dumpstate uses this flag numerically, so when its value is changed 7597 * the broadcast code there must also be changed to match. 7598 * 7599 * @hide 7600 */ 7601 @SystemApi 7602 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; 7603 /** 7604 * If set, the broadcast will never go to manifest receivers in background (cached 7605 * or not running) apps, regardless of whether that would be done by default. By 7606 * default they will receive broadcasts if the broadcast has specified an 7607 * explicit component or package name. 7608 * @hide 7609 */ 7610 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; 7611 /** 7612 * If set, this broadcast is being sent from the shell. 7613 * @hide 7614 */ 7615 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; 7616 7617 /** 7618 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps 7619 * will not receive broadcasts. 7620 * 7621 * <em>This flag has no effect when used by an Instant App.</em> 7622 */ 7623 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000; 7624 7625 /** 7626 * @hide Flags that can't be changed with PendingIntent. 7627 */ 7628 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION 7629 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 7630 | FLAG_GRANT_PREFIX_URI_PERMISSION; 7631 7632 /** 7633 * Local flag indicating this instance was created by copy constructor. 7634 */ 7635 private static final int LOCAL_FLAG_FROM_COPY = 1 << 0; 7636 7637 /** 7638 * Local flag indicating this instance was created from a {@link Parcel}. 7639 */ 7640 private static final int LOCAL_FLAG_FROM_PARCEL = 1 << 1; 7641 7642 /** 7643 * Local flag indicating this instance was delivered through a protected 7644 * component, such as an activity that requires a signature permission, or a 7645 * protected broadcast. Note that this flag <em>cannot</em> be recursively 7646 * applied to any contained instances, since a malicious app may have 7647 * controlled them via {@link #fillIn(Intent, int)}. 7648 */ 7649 private static final int LOCAL_FLAG_FROM_PROTECTED_COMPONENT = 1 << 2; 7650 7651 /** 7652 * Local flag indicating this instance had unfiltered extras copied into it. This could be 7653 * from either {@link #putExtras(Intent)} when an unparceled Intent is provided or {@link 7654 * #putExtras(Bundle)} when the provided Bundle has not been unparceled. 7655 */ 7656 private static final int LOCAL_FLAG_UNFILTERED_EXTRAS = 1 << 3; 7657 7658 /** 7659 * Local flag indicating this instance was created from a {@link Uri}. 7660 */ 7661 private static final int LOCAL_FLAG_FROM_URI = 1 << 4; 7662 7663 /** 7664 * Local flag indicating this instance was created by the system. 7665 */ 7666 /** @hide */ 7667 public static final int LOCAL_FLAG_FROM_SYSTEM = 1 << 5; 7668 7669 /** @hide */ 7670 @IntDef(flag = true, prefix = { "EXTENDED_FLAG_" }, value = { 7671 EXTENDED_FLAG_FILTER_MISMATCH, 7672 }) 7673 @Retention(RetentionPolicy.SOURCE) 7674 public @interface ExtendedFlags {} 7675 7676 /** 7677 * This flag is not normally set by application code, but set for you by the system if 7678 * an external intent does not match the receiving component's intent filter. 7679 * 7680 * @hide 7681 */ 7682 @TestApi 7683 public static final int EXTENDED_FLAG_FILTER_MISMATCH = 1 << 0; 7684 7685 // --------------------------------------------------------------------- 7686 // --------------------------------------------------------------------- 7687 // toUri() and parseUri() options. 7688 7689 /** @hide */ 7690 @IntDef(flag = true, prefix = {"URI_"}, value = { 7691 URI_ALLOW_UNSAFE, 7692 URI_ANDROID_APP_SCHEME, 7693 URI_INTENT_SCHEME, 7694 }) 7695 @Retention(RetentionPolicy.SOURCE) 7696 public @interface UriFlags {} 7697 7698 /** 7699 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 7700 * always has the "intent:" scheme. This syntax can be used when you want 7701 * to later disambiguate between URIs that are intended to describe an 7702 * Intent vs. all others that should be treated as raw URIs. When used 7703 * with {@link #parseUri}, any other scheme will result in a generic 7704 * VIEW action for that raw URI. 7705 */ 7706 public static final int URI_INTENT_SCHEME = 1<<0; 7707 7708 /** 7709 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 7710 * always has the "android-app:" scheme. This is a variation of 7711 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an 7712 * http/https URI being delivered to a specific package name. The format 7713 * is: 7714 * 7715 * <pre class="prettyprint"> 7716 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> 7717 * 7718 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, 7719 * you must also include a scheme; including a path also requires both a host and a scheme. 7720 * The final #Intent; fragment can be used without a scheme, host, or path. 7721 * Note that this can not be 7722 * used with intents that have a {@link #setSelector}, since the base intent 7723 * will always have an explicit package name.</p> 7724 * 7725 * <p>Some examples of how this scheme maps to Intent objects:</p> 7726 * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> 7727 * <colgroup align="left" /> 7728 * <colgroup align="left" /> 7729 * <thead> 7730 * <tr><th>URI</th> <th>Intent</th></tr> 7731 * </thead> 7732 * 7733 * <tbody> 7734 * <tr><td><code>android-app://com.example.app</code></td> 7735 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7736 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> 7737 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7738 * </table></td> 7739 * </tr> 7740 * <tr><td><code>android-app://com.example.app/http/example.com</code></td> 7741 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7742 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 7743 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> 7744 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7745 * </table></td> 7746 * </tr> 7747 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> 7748 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7749 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 7750 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 7751 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7752 * </table></td> 7753 * </tr> 7754 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> 7755 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7756 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7757 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7758 * </table></td> 7759 * </tr> 7760 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> 7761 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7762 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7763 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 7764 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7765 * </table></td> 7766 * </tr> 7767 * <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> 7768 * <td><table border="" style="margin:0" > 7769 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7770 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7771 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> 7772 * </table></td> 7773 * </tr> 7774 * </tbody> 7775 * </table> 7776 */ 7777 public static final int URI_ANDROID_APP_SCHEME = 1<<1; 7778 7779 /** 7780 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing 7781 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, 7782 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, 7783 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the 7784 * generated Intent can not cause unexpected data access to happen. 7785 * 7786 * <p>If you do not trust the source of the URI being parsed, you should still do further 7787 * processing to protect yourself from it. In particular, when using it to start an 7788 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities 7789 * that can handle it.</p> 7790 */ 7791 public static final int URI_ALLOW_UNSAFE = 1<<2; 7792 7793 // --------------------------------------------------------------------- 7794 7795 private String mAction; 7796 private Uri mData; 7797 private String mType; 7798 private String mIdentifier; 7799 private String mPackage; 7800 private ComponentName mComponent; 7801 private int mFlags; 7802 /** Set of in-process flags which are never parceled */ 7803 private int mLocalFlags; 7804 private int mExtendedFlags; 7805 private ArraySet<String> mCategories; 7806 @UnsupportedAppUsage 7807 private Bundle mExtras; 7808 private Rect mSourceBounds; 7809 private Intent mSelector; 7810 private ClipData mClipData; 7811 private int mContentUserHint = UserHandle.USER_CURRENT; 7812 /** Token to track instant app launches. Local only; do not copy cross-process. */ 7813 private String mLaunchToken; 7814 private Intent mOriginalIntent; // Used for the experimental "component alias" feature. 7815 7816 // --------------------------------------------------------------------- 7817 7818 private static final int COPY_MODE_ALL = 0; 7819 private static final int COPY_MODE_FILTER = 1; 7820 private static final int COPY_MODE_HISTORY = 2; 7821 7822 /** @hide */ 7823 @IntDef(prefix = { "COPY_MODE_" }, value = { 7824 COPY_MODE_ALL, 7825 COPY_MODE_FILTER, 7826 COPY_MODE_HISTORY 7827 }) 7828 @Retention(RetentionPolicy.SOURCE) 7829 public @interface CopyMode {} 7830 7831 /** 7832 * Create an empty intent. 7833 */ Intent()7834 public Intent() { 7835 } 7836 7837 /** 7838 * Copy constructor. 7839 */ Intent(Intent o)7840 public Intent(Intent o) { 7841 this(o, COPY_MODE_ALL); 7842 } 7843 Intent(Intent o, @CopyMode int copyMode)7844 private Intent(Intent o, @CopyMode int copyMode) { 7845 this.mAction = o.mAction; 7846 this.mData = o.mData; 7847 this.mType = o.mType; 7848 this.mIdentifier = o.mIdentifier; 7849 this.mPackage = o.mPackage; 7850 this.mComponent = o.mComponent; 7851 this.mOriginalIntent = o.mOriginalIntent; 7852 7853 if (o.mCategories != null) { 7854 this.mCategories = new ArraySet<>(o.mCategories); 7855 } 7856 7857 // Inherit flags from the original, plus mark that we were 7858 // created by this copy constructor 7859 this.mLocalFlags = o.mLocalFlags; 7860 this.mLocalFlags |= LOCAL_FLAG_FROM_COPY; 7861 7862 if (copyMode != COPY_MODE_FILTER) { 7863 this.mFlags = o.mFlags; 7864 this.mExtendedFlags = o.mExtendedFlags; 7865 this.mContentUserHint = o.mContentUserHint; 7866 this.mLaunchToken = o.mLaunchToken; 7867 if (o.mSourceBounds != null) { 7868 this.mSourceBounds = new Rect(o.mSourceBounds); 7869 } 7870 if (o.mSelector != null) { 7871 this.mSelector = new Intent(o.mSelector); 7872 } 7873 7874 if (copyMode != COPY_MODE_HISTORY) { 7875 if (o.mExtras != null) { 7876 this.mExtras = new Bundle(o.mExtras); 7877 } 7878 if (o.mClipData != null) { 7879 this.mClipData = new ClipData(o.mClipData); 7880 } 7881 } else { 7882 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) { 7883 this.mExtras = Bundle.STRIPPED; 7884 } 7885 7886 // Also set "stripped" clip data when we ever log mClipData in the (broadcast) 7887 // history. 7888 } 7889 } 7890 } 7891 7892 @Override clone()7893 public Object clone() { 7894 return new Intent(this); 7895 } 7896 7897 /** 7898 * Make a clone of only the parts of the Intent that are relevant for 7899 * filter matching: the action, data, type, component, and categories. 7900 */ cloneFilter()7901 public @NonNull Intent cloneFilter() { 7902 return new Intent(this, COPY_MODE_FILTER); 7903 } 7904 7905 /** 7906 * Create an intent with a given action. All other fields (data, type, 7907 * class) are null. Note that the action <em>must</em> be in a 7908 * namespace because Intents are used globally in the system -- for 7909 * example the system VIEW action is android.intent.action.VIEW; an 7910 * application's custom action would be something like 7911 * com.google.app.myapp.CUSTOM_ACTION. 7912 * 7913 * @param action The Intent action, such as ACTION_VIEW. 7914 */ Intent(String action)7915 public Intent(String action) { 7916 setAction(action); 7917 } 7918 7919 /** 7920 * Create an intent with a given action and for a given data url. Note 7921 * that the action <em>must</em> be in a namespace because Intents are 7922 * used globally in the system -- for example the system VIEW action is 7923 * android.intent.action.VIEW; an application's custom action would be 7924 * something like com.google.app.myapp.CUSTOM_ACTION. 7925 * 7926 * <p><em>Note: scheme and host name matching in the Android framework is 7927 * case-sensitive, unlike the formal RFC. As a result, 7928 * you should always ensure that you write your Uri with these elements 7929 * using lower case letters, and normalize any Uris you receive from 7930 * outside of Android to ensure the scheme and host is lower case.</em></p> 7931 * 7932 * @param action The Intent action, such as ACTION_VIEW. 7933 * @param uri The Intent data URI. 7934 */ Intent(String action, Uri uri)7935 public Intent(String action, Uri uri) { 7936 setAction(action); 7937 mData = uri; 7938 } 7939 7940 /** 7941 * Create an intent for a specific component. All other fields (action, data, 7942 * type, class) are null, though they can be modified later with explicit 7943 * calls. This provides a convenient way to create an intent that is 7944 * intended to execute a hard-coded class name, rather than relying on the 7945 * system to find an appropriate class for you; see {@link #setComponent} 7946 * for more information on the repercussions of this. 7947 * 7948 * @param packageContext A Context of the application package implementing 7949 * this class. 7950 * @param cls The component class that is to be used for the intent. 7951 * 7952 * @see #setClass 7953 * @see #setComponent 7954 * @see #Intent(String, android.net.Uri , Context, Class) 7955 */ Intent(Context packageContext, Class<?> cls)7956 public Intent(Context packageContext, Class<?> cls) { 7957 mComponent = new ComponentName(packageContext, cls); 7958 } 7959 7960 /** 7961 * Create an intent for a specific component with a specified action and data. 7962 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to 7963 * construct the Intent and then calling {@link #setClass} to set its 7964 * class. 7965 * 7966 * <p><em>Note: scheme and host name matching in the Android framework is 7967 * case-sensitive, unlike the formal RFC. As a result, 7968 * you should always ensure that you write your Uri with these elements 7969 * using lower case letters, and normalize any Uris you receive from 7970 * outside of Android to ensure the scheme and host is lower case.</em></p> 7971 * 7972 * @param action The Intent action, such as ACTION_VIEW. 7973 * @param uri The Intent data URI. 7974 * @param packageContext A Context of the application package implementing 7975 * this class. 7976 * @param cls The component class that is to be used for the intent. 7977 * 7978 * @see #Intent(String, android.net.Uri) 7979 * @see #Intent(Context, Class) 7980 * @see #setClass 7981 * @see #setComponent 7982 */ Intent(String action, Uri uri, Context packageContext, Class<?> cls)7983 public Intent(String action, Uri uri, 7984 Context packageContext, Class<?> cls) { 7985 setAction(action); 7986 mData = uri; 7987 mComponent = new ComponentName(packageContext, cls); 7988 } 7989 7990 /** 7991 * Create an intent to launch the main (root) activity of a task. This 7992 * is the Intent that is started when the application's is launched from 7993 * Home. For anything else that wants to launch an application in the 7994 * same way, it is important that they use an Intent structured the same 7995 * way, and can use this function to ensure this is the case. 7996 * 7997 * <p>The returned Intent has the given Activity component as its explicit 7998 * component, {@link #ACTION_MAIN} as its action, and includes the 7999 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 8000 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 8001 * to do that through {@link #addFlags(int)} on the returned Intent. 8002 * 8003 * @param mainActivity The main activity component that this Intent will 8004 * launch. 8005 * @return Returns a newly created Intent that can be used to launch the 8006 * activity as a main application entry. 8007 * 8008 * @see #setClass 8009 * @see #setComponent 8010 */ makeMainActivity(ComponentName mainActivity)8011 public static Intent makeMainActivity(ComponentName mainActivity) { 8012 Intent intent = new Intent(ACTION_MAIN); 8013 intent.setComponent(mainActivity); 8014 intent.addCategory(CATEGORY_LAUNCHER); 8015 return intent; 8016 } 8017 8018 /** 8019 * Make an Intent for the main activity of an application, without 8020 * specifying a specific activity to run but giving a selector to find 8021 * the activity. This results in a final Intent that is structured 8022 * the same as when the application is launched from 8023 * Home. For anything else that wants to launch an application in the 8024 * same way, it is important that they use an Intent structured the same 8025 * way, and can use this function to ensure this is the case. 8026 * 8027 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the 8028 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 8029 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 8030 * to do that through {@link #addFlags(int)} on the returned Intent. 8031 * 8032 * @param selectorAction The action name of the Intent's selector. 8033 * @param selectorCategory The name of a category to add to the Intent's 8034 * selector. 8035 * @return Returns a newly created Intent that can be used to launch the 8036 * activity as a main application entry. 8037 * 8038 * @see #setSelector(Intent) 8039 */ makeMainSelectorActivity(String selectorAction, String selectorCategory)8040 public static Intent makeMainSelectorActivity(String selectorAction, 8041 String selectorCategory) { 8042 Intent intent = new Intent(ACTION_MAIN); 8043 intent.addCategory(CATEGORY_LAUNCHER); 8044 Intent selector = new Intent(); 8045 selector.setAction(selectorAction); 8046 selector.addCategory(selectorCategory); 8047 intent.setSelector(selector); 8048 return intent; 8049 } 8050 8051 /** 8052 * Make an Intent that can be used to re-launch an application's task 8053 * in its base state. This is like {@link #makeMainActivity(ComponentName)}, 8054 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and 8055 * {@link #FLAG_ACTIVITY_CLEAR_TASK}. 8056 * 8057 * @param mainActivity The activity component that is the root of the 8058 * task; this is the activity that has been published in the application's 8059 * manifest as the main launcher icon. 8060 * 8061 * @return Returns a newly created Intent that can be used to relaunch the 8062 * activity's task in its root state. 8063 */ makeRestartActivityTask(ComponentName mainActivity)8064 public static Intent makeRestartActivityTask(ComponentName mainActivity) { 8065 Intent intent = makeMainActivity(mainActivity); 8066 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 8067 | Intent.FLAG_ACTIVITY_CLEAR_TASK); 8068 return intent; 8069 } 8070 8071 /** 8072 * Call {@link #parseUri} with 0 flags. 8073 * @deprecated Use {@link #parseUri} instead. 8074 */ 8075 @Deprecated getIntent(String uri)8076 public static Intent getIntent(String uri) throws URISyntaxException { 8077 return parseUri(uri, 0); 8078 } 8079 8080 /** 8081 * Create an intent from a URI. This URI may encode the action, 8082 * category, and other intent fields, if it was returned by 8083 * {@link #toUri}. If the Intent was not generate by toUri(), its data 8084 * will be the entire URI and its action will be ACTION_VIEW. 8085 * 8086 * <p>The URI given here must not be relative -- that is, it must include 8087 * the scheme and full path. 8088 * 8089 * @param uri The URI to turn into an Intent. 8090 * @param flags Additional processing flags. 8091 * 8092 * @return Intent The newly created Intent object. 8093 * 8094 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax 8095 * it bad (as parsed by the Uri class) or the Intent data within the 8096 * URI is invalid. 8097 * 8098 * @see #toUri 8099 */ parseUri(String uri, @UriFlags int flags)8100 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException { 8101 Intent intent = parseUriInternal(uri, flags); 8102 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 8103 return intent; 8104 } 8105 8106 /** 8107 * @see #parseUri(String, int) 8108 */ parseUriInternal(String uri, @UriFlags int flags)8109 private static Intent parseUriInternal(String uri, @UriFlags int flags) 8110 throws URISyntaxException { 8111 int i = 0; 8112 try { 8113 final boolean androidApp = uri.startsWith("android-app:"); 8114 8115 // Validate intent scheme if requested. 8116 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { 8117 if (!uri.startsWith("intent:") && !androidApp) { 8118 Intent intent = new Intent(ACTION_VIEW); 8119 try { 8120 intent.setData(Uri.parse(uri)); 8121 } catch (IllegalArgumentException e) { 8122 throw new URISyntaxException(uri, e.getMessage()); 8123 } 8124 return intent; 8125 } 8126 } 8127 8128 i = uri.lastIndexOf("#"); 8129 // simple case 8130 if (i == -1) { 8131 if (!androidApp) { 8132 return new Intent(ACTION_VIEW, Uri.parse(uri)); 8133 } 8134 8135 // old format Intent URI 8136 } else if (!uri.startsWith("#Intent;", i)) { 8137 if (!androidApp) { 8138 return getIntentOld(uri, flags); 8139 } else { 8140 i = -1; 8141 } 8142 } 8143 8144 // new format 8145 Intent intent = new Intent(ACTION_VIEW); 8146 Intent baseIntent = intent; 8147 boolean explicitAction = false; 8148 boolean inSelector = false; 8149 8150 // fetch data part, if present 8151 String scheme = null; 8152 String data; 8153 if (i >= 0) { 8154 data = uri.substring(0, i); 8155 i += 8; // length of "#Intent;" 8156 } else { 8157 data = uri; 8158 } 8159 8160 // loop over contents of Intent, all name=value; 8161 while (i >= 0 && !uri.startsWith("end", i)) { 8162 int eq = uri.indexOf('=', i); 8163 if (eq < 0) eq = i-1; 8164 int semi = uri.indexOf(';', i); 8165 if (semi < 0) { 8166 throw new URISyntaxException(uri, "uri end not found"); 8167 } 8168 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : ""; 8169 8170 // action 8171 if (uri.startsWith("action=", i)) { 8172 intent.setAction(value); 8173 if (!inSelector) { 8174 explicitAction = true; 8175 } 8176 } 8177 8178 // categories 8179 else if (uri.startsWith("category=", i)) { 8180 intent.addCategory(value); 8181 } 8182 8183 // type 8184 else if (uri.startsWith("type=", i)) { 8185 intent.mType = value; 8186 } 8187 8188 // identifier 8189 else if (uri.startsWith("identifier=", i)) { 8190 intent.mIdentifier = value; 8191 } 8192 8193 // launch flags 8194 else if (uri.startsWith("launchFlags=", i)) { 8195 intent.mFlags = decodeInteger(value); 8196 if ((flags& URI_ALLOW_UNSAFE) == 0) { 8197 intent.mFlags &= ~IMMUTABLE_FLAGS; 8198 } 8199 } 8200 8201 // extended flags 8202 else if (uri.startsWith("extendedLaunchFlags=", i)) { 8203 intent.mExtendedFlags = decodeInteger(value); 8204 } 8205 8206 // package 8207 else if (uri.startsWith("package=", i)) { 8208 intent.mPackage = value; 8209 } 8210 8211 // component 8212 else if (uri.startsWith("component=", i)) { 8213 intent.mComponent = ComponentName.unflattenFromString(value); 8214 } 8215 8216 // scheme 8217 else if (uri.startsWith("scheme=", i)) { 8218 if (inSelector) { 8219 intent.mData = Uri.parse(value + ":"); 8220 } else { 8221 scheme = value; 8222 } 8223 } 8224 8225 // source bounds 8226 else if (uri.startsWith("sourceBounds=", i)) { 8227 intent.mSourceBounds = Rect.unflattenFromString(value); 8228 } 8229 8230 // selector 8231 else if (semi == (i+3) && uri.startsWith("SEL", i)) { 8232 intent = new Intent(); 8233 inSelector = true; 8234 } 8235 8236 // extra 8237 else { 8238 String key = Uri.decode(uri.substring(i + 2, eq)); 8239 // create Bundle if it doesn't already exist 8240 if (intent.mExtras == null) intent.mExtras = new Bundle(); 8241 Bundle b = intent.mExtras; 8242 // add EXTRA 8243 if (uri.startsWith("S.", i)) b.putString(key, value); 8244 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); 8245 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); 8246 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); 8247 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); 8248 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); 8249 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); 8250 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); 8251 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); 8252 else throw new URISyntaxException(uri, "unknown EXTRA type", i); 8253 } 8254 8255 // move to the next item 8256 i = semi + 1; 8257 } 8258 8259 if (inSelector) { 8260 // The Intent had a selector; fix it up. 8261 if (baseIntent.mPackage == null) { 8262 baseIntent.setSelector(intent); 8263 } 8264 intent = baseIntent; 8265 } 8266 8267 if (data != null) { 8268 if (data.startsWith("intent:")) { 8269 data = data.substring(7); 8270 if (scheme != null) { 8271 data = scheme + ':' + data; 8272 } 8273 } else if (data.startsWith("android-app:")) { 8274 if (data.charAt(12) == '/' && data.charAt(13) == '/') { 8275 // Correctly formed android-app, first part is package name. 8276 int end = data.indexOf('/', 14); 8277 if (end < 0) { 8278 // All we have is a package name. 8279 intent.mPackage = Uri.decodeIfNeeded(data.substring(14)); 8280 if (!explicitAction) { 8281 intent.setAction(ACTION_MAIN); 8282 } 8283 data = ""; 8284 } else { 8285 // Target the Intent at the given package name always. 8286 String authority = null; 8287 intent.mPackage = Uri.decodeIfNeeded(data.substring(14, end)); 8288 int newEnd; 8289 if ((end+1) < data.length()) { 8290 if ((newEnd=data.indexOf('/', end+1)) >= 0) { 8291 // Found a scheme, remember it. 8292 scheme = Uri.decodeIfNeeded(data.substring(end + 1, newEnd)); 8293 end = newEnd; 8294 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { 8295 // Found a authority, remember it. 8296 authority = Uri.decodeIfNeeded( 8297 data.substring(end + 1, newEnd)); 8298 end = newEnd; 8299 } 8300 } else { 8301 // All we have is a scheme. 8302 scheme = Uri.decodeIfNeeded(data.substring(end + 1)); 8303 } 8304 } 8305 if (scheme == null) { 8306 // If there was no scheme, then this just targets the package. 8307 if (!explicitAction) { 8308 intent.setAction(ACTION_MAIN); 8309 } 8310 data = ""; 8311 } else if (authority == null) { 8312 data = scheme + ":"; 8313 } else { 8314 data = scheme + "://" + authority + data.substring(end); 8315 } 8316 } 8317 } else { 8318 data = ""; 8319 } 8320 } 8321 8322 if (data.length() > 0) { 8323 try { 8324 intent.mData = Uri.parse(data); 8325 } catch (IllegalArgumentException e) { 8326 throw new URISyntaxException(uri, e.getMessage()); 8327 } 8328 } 8329 } 8330 8331 return intent; 8332 8333 } catch (IndexOutOfBoundsException e) { 8334 throw new URISyntaxException(uri, "illegal Intent URI format", i); 8335 } 8336 } 8337 8338 public static Intent getIntentOld(String uri) throws URISyntaxException { 8339 Intent intent = getIntentOld(uri, 0); 8340 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 8341 return intent; 8342 } 8343 8344 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException { 8345 Intent intent; 8346 8347 int i = uri.lastIndexOf('#'); 8348 if (i >= 0) { 8349 String action = null; 8350 final int intentFragmentStart = i; 8351 boolean isIntentFragment = false; 8352 8353 i++; 8354 8355 if (uri.regionMatches(i, "action(", 0, 7)) { 8356 isIntentFragment = true; 8357 i += 7; 8358 int j = uri.indexOf(')', i); 8359 action = uri.substring(i, j); 8360 i = j + 1; 8361 } 8362 8363 intent = new Intent(action); 8364 8365 if (uri.regionMatches(i, "categories(", 0, 11)) { 8366 isIntentFragment = true; 8367 i += 11; 8368 int j = uri.indexOf(')', i); 8369 while (i < j) { 8370 int sep = uri.indexOf('!', i); 8371 if (sep < 0 || sep > j) sep = j; 8372 if (i < sep) { 8373 intent.addCategory(uri.substring(i, sep)); 8374 } 8375 i = sep + 1; 8376 } 8377 i = j + 1; 8378 } 8379 8380 if (uri.regionMatches(i, "type(", 0, 5)) { 8381 isIntentFragment = true; 8382 i += 5; 8383 int j = uri.indexOf(')', i); 8384 intent.mType = uri.substring(i, j); 8385 i = j + 1; 8386 } 8387 8388 if (uri.regionMatches(i, "launchFlags(", 0, 12)) { 8389 isIntentFragment = true; 8390 i += 12; 8391 int j = uri.indexOf(')', i); 8392 intent.mFlags = decodeInteger(uri.substring(i, j)); 8393 if ((flags& URI_ALLOW_UNSAFE) == 0) { 8394 intent.mFlags &= ~IMMUTABLE_FLAGS; 8395 } 8396 i = j + 1; 8397 } 8398 8399 if (uri.regionMatches(i, "component(", 0, 10)) { 8400 isIntentFragment = true; 8401 i += 10; 8402 int j = uri.indexOf(')', i); 8403 int sep = uri.indexOf('!', i); 8404 if (sep >= 0 && sep < j) { 8405 String pkg = uri.substring(i, sep); 8406 String cls = uri.substring(sep + 1, j); 8407 intent.mComponent = new ComponentName(pkg, cls); 8408 } 8409 i = j + 1; 8410 } 8411 8412 if (uri.regionMatches(i, "extras(", 0, 7)) { 8413 isIntentFragment = true; 8414 i += 7; 8415 8416 final int closeParen = uri.indexOf(')', i); 8417 if (closeParen == -1) throw new URISyntaxException(uri, 8418 "EXTRA missing trailing ')'", i); 8419 8420 while (i < closeParen) { 8421 // fetch the key value 8422 int j = uri.indexOf('=', i); 8423 if (j <= i + 1 || i >= closeParen) { 8424 throw new URISyntaxException(uri, "EXTRA missing '='", i); 8425 } 8426 char type = uri.charAt(i); 8427 i++; 8428 String key = uri.substring(i, j); 8429 i = j + 1; 8430 8431 // get type-value 8432 j = uri.indexOf('!', i); 8433 if (j == -1 || j >= closeParen) j = closeParen; 8434 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); 8435 String value = uri.substring(i, j); 8436 i = j; 8437 8438 // create Bundle if it doesn't already exist 8439 if (intent.mExtras == null) intent.mExtras = new Bundle(); 8440 8441 // add item to bundle 8442 try { 8443 switch (type) { 8444 case 'S': 8445 intent.mExtras.putString(key, Uri.decode(value)); 8446 break; 8447 case 'B': 8448 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); 8449 break; 8450 case 'b': 8451 intent.mExtras.putByte(key, Byte.parseByte(value)); 8452 break; 8453 case 'c': 8454 intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); 8455 break; 8456 case 'd': 8457 intent.mExtras.putDouble(key, Double.parseDouble(value)); 8458 break; 8459 case 'f': 8460 intent.mExtras.putFloat(key, Float.parseFloat(value)); 8461 break; 8462 case 'i': 8463 intent.mExtras.putInt(key, Integer.parseInt(value)); 8464 break; 8465 case 'l': 8466 intent.mExtras.putLong(key, Long.parseLong(value)); 8467 break; 8468 case 's': 8469 intent.mExtras.putShort(key, Short.parseShort(value)); 8470 break; 8471 default: 8472 throw new URISyntaxException(uri, "EXTRA has unknown type", i); 8473 } 8474 } catch (NumberFormatException e) { 8475 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); 8476 } 8477 8478 char ch = uri.charAt(i); 8479 if (ch == ')') break; 8480 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); 8481 i++; 8482 } 8483 } 8484 8485 if (isIntentFragment) { 8486 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); 8487 } else { 8488 intent.mData = Uri.parse(uri); 8489 } 8490 8491 if (intent.mAction == null) { 8492 // By default, if no action is specified, then use VIEW. 8493 intent.mAction = ACTION_VIEW; 8494 } 8495 8496 } else { 8497 intent = new Intent(ACTION_VIEW, Uri.parse(uri)); 8498 } 8499 8500 return intent; 8501 } 8502 decodeInteger(String value)8503 private static Integer decodeInteger(String value) { 8504 try { 8505 return Integer.decode(value); 8506 } catch (NumberFormatException e) { 8507 try { 8508 if (value != null && value.startsWith("0x")) { 8509 // In toUriInner, we do "0x".append(Integer.toHexString). 8510 // Sometimes "decode" fails to parse, e.g. 0x90000000. 8511 return Integer.parseUnsignedInt(value.substring(2), 16); 8512 } 8513 } catch (NumberFormatException ignored) { 8514 // ignored, throw the original exception 8515 } 8516 throw e; 8517 } 8518 } 8519 8520 /** @hide */ 8521 public interface CommandOptionHandler { 8522 boolean handleOption(String opt, ShellCommand cmd); 8523 } 8524 8525 /** @hide */ 8526 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 8527 @SuppressWarnings("AndroidFrameworkEfficientCollections") parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)8528 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) 8529 throws URISyntaxException { 8530 Intent intent = new Intent(); 8531 Intent baseIntent = intent; 8532 boolean hasIntentInfo = false; 8533 8534 Uri data = null; 8535 String type = null; 8536 8537 String opt; 8538 while ((opt=cmd.getNextOption()) != null) { 8539 switch (opt) { 8540 case "-a": 8541 intent.setAction(cmd.getNextArgRequired()); 8542 if (intent == baseIntent) { 8543 hasIntentInfo = true; 8544 } 8545 break; 8546 case "-d": 8547 data = Uri.parse(cmd.getNextArgRequired()); 8548 if (intent == baseIntent) { 8549 hasIntentInfo = true; 8550 } 8551 break; 8552 case "-t": 8553 type = cmd.getNextArgRequired(); 8554 if (intent == baseIntent) { 8555 hasIntentInfo = true; 8556 } 8557 break; 8558 case "-i": 8559 intent.setIdentifier(cmd.getNextArgRequired()); 8560 if (intent == baseIntent) { 8561 hasIntentInfo = true; 8562 } 8563 break; 8564 case "-c": 8565 intent.addCategory(cmd.getNextArgRequired()); 8566 if (intent == baseIntent) { 8567 hasIntentInfo = true; 8568 } 8569 break; 8570 case "-e": 8571 case "--es": { 8572 String key = cmd.getNextArgRequired(); 8573 String value = cmd.getNextArgRequired(); 8574 intent.putExtra(key, value); 8575 } 8576 break; 8577 case "--esn": { 8578 String key = cmd.getNextArgRequired(); 8579 intent.putExtra(key, (String) null); 8580 } 8581 break; 8582 case "--ei": { 8583 String key = cmd.getNextArgRequired(); 8584 String value = cmd.getNextArgRequired(); 8585 intent.putExtra(key, decodeInteger(value)); 8586 } 8587 break; 8588 case "--eu": { 8589 String key = cmd.getNextArgRequired(); 8590 String value = cmd.getNextArgRequired(); 8591 intent.putExtra(key, Uri.parse(value)); 8592 } 8593 break; 8594 case "--ecn": { 8595 String key = cmd.getNextArgRequired(); 8596 String value = cmd.getNextArgRequired(); 8597 ComponentName cn = ComponentName.unflattenFromString(value); 8598 if (cn == null) 8599 throw new IllegalArgumentException("Bad component name: " + value); 8600 intent.putExtra(key, cn); 8601 } 8602 break; 8603 case "--eia": { 8604 String key = cmd.getNextArgRequired(); 8605 String value = cmd.getNextArgRequired(); 8606 String[] strings = value.split(","); 8607 int[] list = new int[strings.length]; 8608 for (int i = 0; i < strings.length; i++) { 8609 list[i] = decodeInteger(strings[i]); 8610 } 8611 intent.putExtra(key, list); 8612 } 8613 break; 8614 case "--eial": { 8615 String key = cmd.getNextArgRequired(); 8616 String value = cmd.getNextArgRequired(); 8617 String[] strings = value.split(","); 8618 ArrayList<Integer> list = new ArrayList<>(strings.length); 8619 for (int i = 0; i < strings.length; i++) { 8620 list.add(decodeInteger(strings[i])); 8621 } 8622 intent.putExtra(key, list); 8623 } 8624 break; 8625 case "--el": { 8626 String key = cmd.getNextArgRequired(); 8627 String value = cmd.getNextArgRequired(); 8628 intent.putExtra(key, Long.valueOf(value)); 8629 } 8630 break; 8631 case "--ela": { 8632 String key = cmd.getNextArgRequired(); 8633 String value = cmd.getNextArgRequired(); 8634 String[] strings = value.split(","); 8635 long[] list = new long[strings.length]; 8636 for (int i = 0; i < strings.length; i++) { 8637 list[i] = Long.valueOf(strings[i]); 8638 } 8639 intent.putExtra(key, list); 8640 hasIntentInfo = true; 8641 } 8642 break; 8643 case "--elal": { 8644 String key = cmd.getNextArgRequired(); 8645 String value = cmd.getNextArgRequired(); 8646 String[] strings = value.split(","); 8647 ArrayList<Long> list = new ArrayList<>(strings.length); 8648 for (int i = 0; i < strings.length; i++) { 8649 list.add(Long.valueOf(strings[i])); 8650 } 8651 intent.putExtra(key, list); 8652 hasIntentInfo = true; 8653 } 8654 break; 8655 case "--ef": { 8656 String key = cmd.getNextArgRequired(); 8657 String value = cmd.getNextArgRequired(); 8658 intent.putExtra(key, Float.valueOf(value)); 8659 hasIntentInfo = true; 8660 } 8661 break; 8662 case "--efa": { 8663 String key = cmd.getNextArgRequired(); 8664 String value = cmd.getNextArgRequired(); 8665 String[] strings = value.split(","); 8666 float[] list = new float[strings.length]; 8667 for (int i = 0; i < strings.length; i++) { 8668 list[i] = Float.valueOf(strings[i]); 8669 } 8670 intent.putExtra(key, list); 8671 hasIntentInfo = true; 8672 } 8673 break; 8674 case "--efal": { 8675 String key = cmd.getNextArgRequired(); 8676 String value = cmd.getNextArgRequired(); 8677 String[] strings = value.split(","); 8678 ArrayList<Float> list = new ArrayList<>(strings.length); 8679 for (int i = 0; i < strings.length; i++) { 8680 list.add(Float.valueOf(strings[i])); 8681 } 8682 intent.putExtra(key, list); 8683 hasIntentInfo = true; 8684 } 8685 break; 8686 case "--ed": { 8687 String key = cmd.getNextArgRequired(); 8688 String value = cmd.getNextArgRequired(); 8689 intent.putExtra(key, Double.valueOf(value)); 8690 hasIntentInfo = true; 8691 } 8692 break; 8693 case "--eda": { 8694 String key = cmd.getNextArgRequired(); 8695 String value = cmd.getNextArgRequired(); 8696 String[] strings = value.split(","); 8697 double[] list = new double[strings.length]; 8698 for (int i = 0; i < strings.length; i++) { 8699 list[i] = Double.valueOf(strings[i]); 8700 } 8701 intent.putExtra(key, list); 8702 hasIntentInfo = true; 8703 } 8704 break; 8705 case "--edal": { 8706 String key = cmd.getNextArgRequired(); 8707 String value = cmd.getNextArgRequired(); 8708 String[] strings = value.split(","); 8709 ArrayList<Double> list = new ArrayList<>(strings.length); 8710 for (int i = 0; i < strings.length; i++) { 8711 list.add(Double.valueOf(strings[i])); 8712 } 8713 intent.putExtra(key, list); 8714 hasIntentInfo = true; 8715 } 8716 break; 8717 case "--esa": { 8718 String key = cmd.getNextArgRequired(); 8719 String value = cmd.getNextArgRequired(); 8720 // Split on commas unless they are preceeded by an escape. 8721 // The escape character must be escaped for the string and 8722 // again for the regex, thus four escape characters become one. 8723 String[] strings = value.split("(?<!\\\\),"); 8724 intent.putExtra(key, strings); 8725 hasIntentInfo = true; 8726 } 8727 break; 8728 case "--esal": { 8729 String key = cmd.getNextArgRequired(); 8730 String value = cmd.getNextArgRequired(); 8731 // Split on commas unless they are preceeded by an escape. 8732 // The escape character must be escaped for the string and 8733 // again for the regex, thus four escape characters become one. 8734 String[] strings = value.split("(?<!\\\\),"); 8735 ArrayList<String> list = new ArrayList<>(strings.length); 8736 for (int i = 0; i < strings.length; i++) { 8737 list.add(strings[i]); 8738 } 8739 intent.putExtra(key, list); 8740 hasIntentInfo = true; 8741 } 8742 break; 8743 case "--ez": { 8744 String key = cmd.getNextArgRequired(); 8745 String value = cmd.getNextArgRequired().toLowerCase(); 8746 // Boolean.valueOf() results in false for anything that is not "true", which is 8747 // error-prone in shell commands 8748 boolean arg; 8749 if ("true".equals(value) || "t".equals(value)) { 8750 arg = true; 8751 } else if ("false".equals(value) || "f".equals(value)) { 8752 arg = false; 8753 } else { 8754 try { 8755 arg = decodeInteger(value) != 0; 8756 } catch (NumberFormatException ex) { 8757 throw new IllegalArgumentException("Invalid boolean value: " + value); 8758 } 8759 } 8760 8761 intent.putExtra(key, arg); 8762 } 8763 break; 8764 case "-n": { 8765 String str = cmd.getNextArgRequired(); 8766 ComponentName cn = ComponentName.unflattenFromString(str); 8767 if (cn == null) 8768 throw new IllegalArgumentException("Bad component name: " + str); 8769 intent.setComponent(cn); 8770 if (intent == baseIntent) { 8771 hasIntentInfo = true; 8772 } 8773 } 8774 break; 8775 case "-p": { 8776 String str = cmd.getNextArgRequired(); 8777 intent.setPackage(str); 8778 if (intent == baseIntent) { 8779 hasIntentInfo = true; 8780 } 8781 } 8782 break; 8783 case "-f": 8784 String str = cmd.getNextArgRequired(); 8785 intent.setFlags(decodeInteger(str).intValue()); 8786 break; 8787 case "--grant-read-uri-permission": 8788 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 8789 break; 8790 case "--grant-write-uri-permission": 8791 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 8792 break; 8793 case "--grant-persistable-uri-permission": 8794 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); 8795 break; 8796 case "--grant-prefix-uri-permission": 8797 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); 8798 break; 8799 case "--exclude-stopped-packages": 8800 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); 8801 break; 8802 case "--include-stopped-packages": 8803 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); 8804 break; 8805 case "--debug-log-resolution": 8806 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); 8807 break; 8808 case "--activity-brought-to-front": 8809 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); 8810 break; 8811 case "--activity-clear-top": 8812 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 8813 break; 8814 case "--activity-clear-when-task-reset": 8815 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 8816 break; 8817 case "--activity-exclude-from-recents": 8818 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 8819 break; 8820 case "--activity-launched-from-history": 8821 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); 8822 break; 8823 case "--activity-multiple-task": 8824 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 8825 break; 8826 case "--activity-no-animation": 8827 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 8828 break; 8829 case "--activity-no-history": 8830 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 8831 break; 8832 case "--activity-no-user-action": 8833 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); 8834 break; 8835 case "--activity-previous-is-top": 8836 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); 8837 break; 8838 case "--activity-reorder-to-front": 8839 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 8840 break; 8841 case "--activity-reset-task-if-needed": 8842 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 8843 break; 8844 case "--activity-single-top": 8845 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 8846 break; 8847 case "--activity-clear-task": 8848 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 8849 break; 8850 case "--activity-task-on-home": 8851 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); 8852 break; 8853 case "--activity-match-external": 8854 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL); 8855 break; 8856 case "--receiver-registered-only": 8857 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); 8858 break; 8859 case "--receiver-replace-pending": 8860 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); 8861 break; 8862 case "--receiver-foreground": 8863 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 8864 break; 8865 case "--receiver-no-abort": 8866 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); 8867 break; 8868 case "--receiver-include-background": 8869 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 8870 break; 8871 case "--selector": 8872 intent.setDataAndType(data, type); 8873 intent = new Intent(); 8874 break; 8875 default: 8876 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { 8877 // Okay, caller handled this option. 8878 } else { 8879 throw new IllegalArgumentException("Unknown option: " + opt); 8880 } 8881 break; 8882 } 8883 } 8884 intent.setDataAndType(data, type); 8885 8886 final boolean hasSelector = intent != baseIntent; 8887 if (hasSelector) { 8888 // A selector was specified; fix up. 8889 baseIntent.setSelector(intent); 8890 intent = baseIntent; 8891 } 8892 8893 String arg = cmd.getNextArg(); 8894 baseIntent = null; 8895 if (arg == null) { 8896 if (hasSelector) { 8897 // If a selector has been specified, and no arguments 8898 // have been supplied for the main Intent, then we can 8899 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't 8900 // need to have a component name specified yet, the 8901 // selector will take care of that. 8902 baseIntent = new Intent(Intent.ACTION_MAIN); 8903 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8904 } 8905 } else if (arg.indexOf(':') >= 0) { 8906 // The argument is a URI. Fully parse it, and use that result 8907 // to fill in any data not specified so far. 8908 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME 8909 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); 8910 } else if (arg.indexOf('/') >= 0) { 8911 // The argument is a component name. Build an Intent to launch 8912 // it. 8913 baseIntent = new Intent(Intent.ACTION_MAIN); 8914 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8915 baseIntent.setComponent(ComponentName.unflattenFromString(arg)); 8916 } else { 8917 // Assume the argument is a package name. 8918 baseIntent = new Intent(Intent.ACTION_MAIN); 8919 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8920 baseIntent.setPackage(arg); 8921 } 8922 if (baseIntent != null) { 8923 Bundle extras = intent.getExtras(); 8924 intent.replaceExtras((Bundle)null); 8925 Bundle uriExtras = baseIntent.getExtras(); 8926 baseIntent.replaceExtras((Bundle)null); 8927 if (intent.getAction() != null && baseIntent.getCategories() != null) { 8928 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); 8929 for (String c : cats) { 8930 baseIntent.removeCategory(c); 8931 } 8932 } 8933 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); 8934 if (extras == null) { 8935 extras = uriExtras; 8936 } else if (uriExtras != null) { 8937 uriExtras.putAll(extras); 8938 extras = uriExtras; 8939 } 8940 intent.replaceExtras(extras); 8941 hasIntentInfo = true; 8942 } 8943 8944 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); 8945 return intent; 8946 } 8947 8948 /** @hide */ 8949 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) printIntentArgsHelp(PrintWriter pw, String prefix)8950 public static void printIntentArgsHelp(PrintWriter pw, String prefix) { 8951 final String[] lines = new String[] { 8952 "<INTENT> specifications include these flags and arguments:", 8953 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]", 8954 " [-c <CATEGORY> [-c <CATEGORY>] ...]", 8955 " [-n <COMPONENT_NAME>]", 8956 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", 8957 " [--esn <EXTRA_KEY> ...]", 8958 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", 8959 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", 8960 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", 8961 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", 8962 " [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]", 8963 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", 8964 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", 8965 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8966 " (multiple extras passed as Integer[])", 8967 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8968 " (multiple extras passed as List<Integer>)", 8969 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8970 " (multiple extras passed as Long[])", 8971 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8972 " (multiple extras passed as List<Long>)", 8973 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8974 " (multiple extras passed as Float[])", 8975 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8976 " (multiple extras passed as List<Float>)", 8977 " [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]", 8978 " (multiple extras passed as Double[])", 8979 " [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]", 8980 " (multiple extras passed as List<Double>)", 8981 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8982 " (multiple extras passed as String[]; to embed a comma into a string,", 8983 " escape it using \"\\,\")", 8984 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8985 " (multiple extras passed as List<String>; to embed a comma into a string,", 8986 " escape it using \"\\,\")", 8987 " [-f <FLAG>]", 8988 " [--grant-read-uri-permission] [--grant-write-uri-permission]", 8989 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", 8990 " [--debug-log-resolution] [--exclude-stopped-packages]", 8991 " [--include-stopped-packages]", 8992 " [--activity-brought-to-front] [--activity-clear-top]", 8993 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", 8994 " [--activity-launched-from-history] [--activity-multiple-task]", 8995 " [--activity-no-animation] [--activity-no-history]", 8996 " [--activity-no-user-action] [--activity-previous-is-top]", 8997 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", 8998 " [--activity-single-top] [--activity-clear-task]", 8999 " [--activity-task-on-home] [--activity-match-external]", 9000 " [--receiver-registered-only] [--receiver-replace-pending]", 9001 " [--receiver-foreground] [--receiver-no-abort]", 9002 " [--receiver-include-background]", 9003 " [--selector]", 9004 " [<URI> | <PACKAGE> | <COMPONENT>]" 9005 }; 9006 for (String line : lines) { 9007 pw.print(prefix); 9008 pw.println(line); 9009 } 9010 } 9011 9012 /** 9013 * Retrieve the general action to be performed, such as 9014 * {@link #ACTION_VIEW}. The action describes the general way the rest of 9015 * the information in the intent should be interpreted -- most importantly, 9016 * what to do with the data returned by {@link #getData}. 9017 * 9018 * @return The action of this intent or null if none is specified. 9019 * 9020 * @see #setAction 9021 */ getAction()9022 public @Nullable String getAction() { 9023 return mAction; 9024 } 9025 9026 /** 9027 * Retrieve data this intent is operating on. This URI specifies the name 9028 * of the data; often it uses the content: scheme, specifying data in a 9029 * content provider. Other schemes may be handled by specific activities, 9030 * such as http: by the web browser. 9031 * 9032 * @return The URI of the data this intent is targeting or null. 9033 * 9034 * @see #getScheme 9035 * @see #setData 9036 */ getData()9037 public @Nullable Uri getData() { 9038 return mData; 9039 } 9040 9041 /** 9042 * The same as {@link #getData()}, but returns the URI as an encoded 9043 * String. 9044 */ getDataString()9045 public @Nullable String getDataString() { 9046 return mData != null ? mData.toString() : null; 9047 } 9048 9049 /** 9050 * Return the scheme portion of the intent's data. If the data is null or 9051 * does not include a scheme, null is returned. Otherwise, the scheme 9052 * prefix without the final ':' is returned, i.e. "http". 9053 * 9054 * <p>This is the same as calling getData().getScheme() (and checking for 9055 * null data). 9056 * 9057 * @return The scheme of this intent. 9058 * 9059 * @see #getData 9060 */ getScheme()9061 public @Nullable String getScheme() { 9062 return mData != null ? mData.getScheme() : null; 9063 } 9064 9065 /** 9066 * Retrieve any explicit MIME type included in the intent. This is usually 9067 * null, as the type is determined by the intent data. 9068 * 9069 * @return If a type was manually set, it is returned; else null is 9070 * returned. 9071 * 9072 * @see #resolveType(ContentResolver) 9073 * @see #setType 9074 */ getType()9075 public @Nullable String getType() { 9076 return mType; 9077 } 9078 9079 9080 /** 9081 * @hide For the experimental component alias feature. Do not use, unless you know what it is. 9082 */ 9083 @Nullable getOriginalIntent()9084 public Intent getOriginalIntent() { 9085 return mOriginalIntent; 9086 } 9087 9088 /** 9089 * @hide For the experimental component alias feature. Do not use, unless you know what it is. 9090 */ setOriginalIntent(@ullable Intent originalIntent)9091 public void setOriginalIntent(@Nullable Intent originalIntent) { 9092 mOriginalIntent = originalIntent; 9093 } 9094 9095 /** 9096 * Return the MIME data type of this intent. If the type field is 9097 * explicitly set, that is simply returned. Otherwise, if the data is set, 9098 * the type of that data is returned. If neither fields are set, a null is 9099 * returned. 9100 * 9101 * @return The MIME type of this intent. 9102 * 9103 * @see #getType 9104 * @see #resolveType(ContentResolver) 9105 */ resolveType(@onNull Context context)9106 public @Nullable String resolveType(@NonNull Context context) { 9107 return resolveType(context.getContentResolver()); 9108 } 9109 9110 /** 9111 * Return the MIME data type of this intent. If the type field is 9112 * explicitly set, that is simply returned. Otherwise, if the data is set, 9113 * the type of that data is returned. If neither fields are set, a null is 9114 * returned. 9115 * 9116 * @param resolver A ContentResolver that can be used to determine the MIME 9117 * type of the intent's data. 9118 * 9119 * @return The MIME type of this intent. 9120 * 9121 * @see #getType 9122 * @see #resolveType(Context) 9123 */ resolveType(@onNull ContentResolver resolver)9124 public @Nullable String resolveType(@NonNull ContentResolver resolver) { 9125 if (mType != null) { 9126 return mType; 9127 } 9128 if (mData != null) { 9129 if ("content".equals(mData.getScheme())) { 9130 return resolver.getType(mData); 9131 } 9132 } 9133 return null; 9134 } 9135 9136 /** 9137 * Return the MIME data type of this intent, only if it will be needed for 9138 * intent resolution. This is not generally useful for application code; 9139 * it is used by the frameworks for communicating with back-end system 9140 * services. 9141 * 9142 * @param resolver A ContentResolver that can be used to determine the MIME 9143 * type of the intent's data. 9144 * 9145 * @return The MIME type of this intent, or null if it is unknown or not 9146 * needed. 9147 */ resolveTypeIfNeeded(@onNull ContentResolver resolver)9148 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) { 9149 // Match logic in PackageManagerService#applyEnforceIntentFilterMatching(...) 9150 if (mComponent != null && (Process.myUid() == Process.ROOT_UID 9151 || Process.myUid() == Process.SYSTEM_UID 9152 || mComponent.getPackageName().equals(ActivityThread.currentPackageName()))) { 9153 return mType; 9154 } 9155 return resolveType(resolver); 9156 } 9157 9158 /** 9159 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity 9160 * of the Intent to distinguish it from other Intents. 9161 * 9162 * @return The identifier of this intent or null if none is specified. 9163 * 9164 * @see #setIdentifier 9165 */ getIdentifier()9166 public @Nullable String getIdentifier() { 9167 return mIdentifier; 9168 } 9169 9170 /** 9171 * Check if a category exists in the intent. 9172 * 9173 * @param category The category to check. 9174 * 9175 * @return boolean True if the intent contains the category, else false. 9176 * 9177 * @see #getCategories 9178 * @see #addCategory 9179 */ hasCategory(String category)9180 public boolean hasCategory(String category) { 9181 return mCategories != null && mCategories.contains(category); 9182 } 9183 9184 /** 9185 * Return the set of all categories in the intent. If there are no categories, 9186 * returns NULL. 9187 * 9188 * @return The set of categories you can examine. Do not modify! 9189 * 9190 * @see #hasCategory 9191 * @see #addCategory 9192 */ getCategories()9193 public Set<String> getCategories() { 9194 return mCategories; 9195 } 9196 9197 /** 9198 * Return the specific selector associated with this Intent. If there is 9199 * none, returns null. See {@link #setSelector} for more information. 9200 * 9201 * @see #setSelector 9202 */ getSelector()9203 public @Nullable Intent getSelector() { 9204 return mSelector; 9205 } 9206 9207 /** 9208 * Return the {@link ClipData} associated with this Intent. If there is 9209 * none, returns null. See {@link #setClipData} for more information. 9210 * 9211 * @see #setClipData 9212 */ getClipData()9213 public @Nullable ClipData getClipData() { 9214 return mClipData; 9215 } 9216 9217 /** @hide */ getContentUserHint()9218 public int getContentUserHint() { 9219 return mContentUserHint; 9220 } 9221 9222 /** @hide */ getLaunchToken()9223 public String getLaunchToken() { 9224 return mLaunchToken; 9225 } 9226 9227 /** @hide */ setLaunchToken(String launchToken)9228 public void setLaunchToken(String launchToken) { 9229 mLaunchToken = launchToken; 9230 } 9231 9232 /** 9233 * Sets the ClassLoader that will be used when unmarshalling 9234 * any Parcelable values from the extras of this Intent. 9235 * 9236 * @param loader a ClassLoader, or null to use the default loader 9237 * at the time of unmarshalling. 9238 */ setExtrasClassLoader(@ullable ClassLoader loader)9239 public void setExtrasClassLoader(@Nullable ClassLoader loader) { 9240 if (mExtras != null) { 9241 mExtras.setClassLoader(loader); 9242 } 9243 } 9244 9245 /** 9246 * Returns true if an extra value is associated with the given name. 9247 * @param name the extra's name 9248 * @return true if the given extra is present. 9249 */ hasExtra(String name)9250 public boolean hasExtra(String name) { 9251 return mExtras != null && mExtras.containsKey(name); 9252 } 9253 9254 /** 9255 * Returns true if the Intent's extras contain a parcelled file descriptor. 9256 * @return true if the Intent contains a parcelled file descriptor. 9257 */ hasFileDescriptors()9258 public boolean hasFileDescriptors() { 9259 return mExtras != null && mExtras.hasFileDescriptors(); 9260 } 9261 9262 /** {@hide} */ 9263 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) setAllowFds(boolean allowFds)9264 public void setAllowFds(boolean allowFds) { 9265 if (mExtras != null) { 9266 mExtras.setAllowFds(allowFds); 9267 } 9268 } 9269 9270 /** {@hide} */ setDefusable(boolean defusable)9271 public void setDefusable(boolean defusable) { 9272 if (mExtras != null) { 9273 mExtras.setDefusable(defusable); 9274 } 9275 } 9276 9277 /** 9278 * Retrieve extended data from the intent. 9279 * 9280 * @param name The name of the desired item. 9281 * 9282 * @return the value of an item previously added with putExtra(), 9283 * or null if none was found. 9284 * 9285 * @deprecated 9286 * @hide 9287 */ 9288 @Deprecated 9289 @UnsupportedAppUsage getExtra(String name)9290 public Object getExtra(String name) { 9291 return getExtra(name, null); 9292 } 9293 9294 /** 9295 * Retrieve extended data from the intent. 9296 * 9297 * @param name The name of the desired item. 9298 * @param defaultValue the value to be returned if no value of the desired 9299 * type is stored with the given name. 9300 * 9301 * @return the value of an item previously added with putExtra(), 9302 * or the default value if none was found. 9303 * 9304 * @see #putExtra(String, boolean) 9305 */ getBooleanExtra(String name, boolean defaultValue)9306 public boolean getBooleanExtra(String name, boolean defaultValue) { 9307 return mExtras == null ? defaultValue : 9308 mExtras.getBoolean(name, defaultValue); 9309 } 9310 9311 /** 9312 * Retrieve extended data from the intent. 9313 * 9314 * @param name The name of the desired item. 9315 * @param defaultValue the value to be returned if no value of the desired 9316 * type is stored with the given name. 9317 * 9318 * @return the value of an item previously added with putExtra(), 9319 * or the default value if none was found. 9320 * 9321 * @see #putExtra(String, byte) 9322 */ getByteExtra(String name, byte defaultValue)9323 public byte getByteExtra(String name, byte defaultValue) { 9324 return mExtras == null ? defaultValue : 9325 mExtras.getByte(name, defaultValue); 9326 } 9327 9328 /** 9329 * Retrieve extended data from the intent. 9330 * 9331 * @param name The name of the desired item. 9332 * @param defaultValue the value to be returned if no value of the desired 9333 * type is stored with the given name. 9334 * 9335 * @return the value of an item previously added with putExtra(), 9336 * or the default value if none was found. 9337 * 9338 * @see #putExtra(String, short) 9339 */ getShortExtra(String name, short defaultValue)9340 public short getShortExtra(String name, short defaultValue) { 9341 return mExtras == null ? defaultValue : 9342 mExtras.getShort(name, defaultValue); 9343 } 9344 9345 /** 9346 * Retrieve extended data from the intent. 9347 * 9348 * @param name The name of the desired item. 9349 * @param defaultValue the value to be returned if no value of the desired 9350 * type is stored with the given name. 9351 * 9352 * @return the value of an item previously added with putExtra(), 9353 * or the default value if none was found. 9354 * 9355 * @see #putExtra(String, char) 9356 */ getCharExtra(String name, char defaultValue)9357 public char getCharExtra(String name, char defaultValue) { 9358 return mExtras == null ? defaultValue : 9359 mExtras.getChar(name, defaultValue); 9360 } 9361 9362 /** 9363 * Retrieve extended data from the intent. 9364 * 9365 * @param name The name of the desired item. 9366 * @param defaultValue the value to be returned if no value of the desired 9367 * type is stored with the given name. 9368 * 9369 * @return the value of an item previously added with putExtra(), 9370 * or the default value if none was found. 9371 * 9372 * @see #putExtra(String, int) 9373 */ getIntExtra(String name, int defaultValue)9374 public int getIntExtra(String name, int defaultValue) { 9375 return mExtras == null ? defaultValue : 9376 mExtras.getInt(name, defaultValue); 9377 } 9378 9379 /** 9380 * Retrieve extended data from the intent. 9381 * 9382 * @param name The name of the desired item. 9383 * @param defaultValue the value to be returned if no value of the desired 9384 * type is stored with the given name. 9385 * 9386 * @return the value of an item previously added with putExtra(), 9387 * or the default value if none was found. 9388 * 9389 * @see #putExtra(String, long) 9390 */ getLongExtra(String name, long defaultValue)9391 public long getLongExtra(String name, long defaultValue) { 9392 return mExtras == null ? defaultValue : 9393 mExtras.getLong(name, defaultValue); 9394 } 9395 9396 /** 9397 * Retrieve extended data from the intent. 9398 * 9399 * @param name The name of the desired item. 9400 * @param defaultValue the value to be returned if no value of the desired 9401 * type is stored with the given name. 9402 * 9403 * @return the value of an item previously added with putExtra(), 9404 * or the default value if no such item is present 9405 * 9406 * @see #putExtra(String, float) 9407 */ getFloatExtra(String name, float defaultValue)9408 public float getFloatExtra(String name, float defaultValue) { 9409 return mExtras == null ? defaultValue : 9410 mExtras.getFloat(name, defaultValue); 9411 } 9412 9413 /** 9414 * Retrieve extended data from the intent. 9415 * 9416 * @param name The name of the desired item. 9417 * @param defaultValue the value to be returned if no value of the desired 9418 * type is stored with the given name. 9419 * 9420 * @return the value of an item previously added with putExtra(), 9421 * or the default value if none was found. 9422 * 9423 * @see #putExtra(String, double) 9424 */ getDoubleExtra(String name, double defaultValue)9425 public double getDoubleExtra(String name, double defaultValue) { 9426 return mExtras == null ? defaultValue : 9427 mExtras.getDouble(name, defaultValue); 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 value was found. 9437 * 9438 * @see #putExtra(String, String) 9439 */ getStringExtra(String name)9440 public @Nullable String getStringExtra(String name) { 9441 return mExtras == null ? null : mExtras.getString(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 value was found. 9451 * 9452 * @see #putExtra(String, CharSequence) 9453 */ getCharSequenceExtra(String name)9454 public @Nullable CharSequence getCharSequenceExtra(String name) { 9455 return mExtras == null ? null : mExtras.getCharSequence(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 Parcelable value was found. 9465 * 9466 * @deprecated Use the type-safer {@link #getParcelableExtra(String, Class)} starting from 9467 * Android {@link Build.VERSION_CODES#TIRAMISU}. 9468 * 9469 * @see #putExtra(String, Parcelable) 9470 */ 9471 @Deprecated getParcelableExtra(String name)9472 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) { 9473 return mExtras == null ? null : mExtras.<T>getParcelable(name); 9474 } 9475 9476 /** 9477 * Retrieve extended data from the intent. 9478 * 9479 * @param name The name of the desired item. 9480 * @param clazz The type of the object expected. 9481 * 9482 * @return the value of an item previously added with putExtra(), 9483 * or null if no Parcelable value was found. 9484 * 9485 * @see #putExtra(String, Parcelable) 9486 */ getParcelableExtra(@ullable String name, @NonNull Class<T> clazz)9487 public @Nullable <T> T getParcelableExtra(@Nullable String name, @NonNull Class<T> clazz) { 9488 return mExtras == null ? null : mExtras.getParcelable(name, clazz); 9489 } 9490 9491 /** 9492 * Retrieve extended data from the intent. 9493 * 9494 * @param name The name of the desired item. 9495 * 9496 * @return the value of an item previously added with putExtra(), 9497 * or null if no Parcelable[] value was found. 9498 * 9499 * @deprecated Use the type-safer {@link #getParcelableArrayExtra(String, Class)} starting from 9500 * Android {@link Build.VERSION_CODES#TIRAMISU}. 9501 * 9502 * @see #putExtra(String, Parcelable[]) 9503 */ 9504 @Deprecated getParcelableArrayExtra(String name)9505 public @Nullable Parcelable[] getParcelableArrayExtra(String name) { 9506 return mExtras == null ? null : mExtras.getParcelableArray(name); 9507 } 9508 9509 /** 9510 * Retrieve extended data from the intent. 9511 * 9512 * @param name The name of the desired item. 9513 * @param clazz The type of the items inside the array. This is only verified when unparceling. 9514 * 9515 * @return the value of an item previously added with putExtra(), 9516 * or null if no Parcelable[] value was found. 9517 * 9518 * @see #putExtra(String, Parcelable[]) 9519 */ 9520 @SuppressLint({"ArrayReturn", "NullableCollection"}) getParcelableArrayExtra(@ullable String name, @NonNull Class<T> clazz)9521 public @Nullable <T> T[] getParcelableArrayExtra(@Nullable String name, 9522 @NonNull Class<T> clazz) { 9523 return mExtras == null ? null : mExtras.getParcelableArray(name, clazz); 9524 } 9525 9526 /** 9527 * Retrieve extended data from the intent. 9528 * 9529 * @param name The name of the desired item. 9530 * 9531 * @return the value of an item previously added with 9532 * putParcelableArrayListExtra(), or null if no 9533 * ArrayList<Parcelable> value was found. 9534 * 9535 * @deprecated Use the type-safer {@link #getParcelableArrayListExtra(String, Class)} starting 9536 * from Android {@link Build.VERSION_CODES#TIRAMISU}. 9537 * 9538 * @see #putParcelableArrayListExtra(String, ArrayList) 9539 */ 9540 @Deprecated getParcelableArrayListExtra(String name)9541 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { 9542 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); 9543 } 9544 9545 /** 9546 * Retrieve extended data from the intent. 9547 * 9548 * @param name The name of the desired item. 9549 * @param clazz The type of the items inside the array list. This is only verified when 9550 * unparceling. 9551 * 9552 * @return the value of an item previously added with 9553 * putParcelableArrayListExtra(), or null if no 9554 * ArrayList<Parcelable> value was found. 9555 * 9556 * @see #putParcelableArrayListExtra(String, ArrayList) 9557 */ 9558 @SuppressLint({"ConcreteCollection", "NullableCollection"}) getParcelableArrayListExtra(@ullable String name, @NonNull Class<? extends T> clazz)9559 public @Nullable <T> ArrayList<T> getParcelableArrayListExtra(@Nullable String name, 9560 @NonNull Class<? extends T> clazz) { 9561 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name, clazz); 9562 } 9563 9564 /** 9565 * Retrieve extended data from the intent. 9566 * 9567 * @param name The name of the desired item. 9568 * 9569 * @return the value of an item previously added with putExtra(), 9570 * or null if no Serializable value was found. 9571 * 9572 * @deprecated Use the type-safer {@link #getSerializableExtra(String, Class)} starting from 9573 * Android {@link Build.VERSION_CODES#TIRAMISU}. 9574 * 9575 * @see #putExtra(String, Serializable) 9576 */ getSerializableExtra(String name)9577 public @Nullable Serializable getSerializableExtra(String name) { 9578 return mExtras == null ? null : mExtras.getSerializable(name); 9579 } 9580 9581 /** 9582 * Retrieve extended data from the intent. 9583 * 9584 * @param name The name of the desired item. 9585 * @param clazz The type of the object expected. 9586 * 9587 * @return the value of an item previously added with putExtra(), 9588 * or null if no Serializable value was found. 9589 * 9590 * @see #putExtra(String, Serializable) 9591 */ getSerializableExtra(@ullable String name, @NonNull Class<T> clazz)9592 public @Nullable <T extends Serializable> T getSerializableExtra(@Nullable String name, 9593 @NonNull Class<T> clazz) { 9594 return mExtras == null ? null : mExtras.getSerializable(name, clazz); 9595 } 9596 9597 /** 9598 * Retrieve extended data from the intent. 9599 * 9600 * @param name The name of the desired item. 9601 * 9602 * @return the value of an item previously added with 9603 * putIntegerArrayListExtra(), or null if no 9604 * ArrayList<Integer> value was found. 9605 * 9606 * @see #putIntegerArrayListExtra(String, ArrayList) 9607 */ getIntegerArrayListExtra(String name)9608 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) { 9609 return mExtras == null ? null : mExtras.getIntegerArrayList(name); 9610 } 9611 9612 /** 9613 * Retrieve extended data from the intent. 9614 * 9615 * @param name The name of the desired item. 9616 * 9617 * @return the value of an item previously added with 9618 * putStringArrayListExtra(), or null if no 9619 * ArrayList<String> value was found. 9620 * 9621 * @see #putStringArrayListExtra(String, ArrayList) 9622 */ getStringArrayListExtra(String name)9623 public @Nullable ArrayList<String> getStringArrayListExtra(String name) { 9624 return mExtras == null ? null : mExtras.getStringArrayList(name); 9625 } 9626 9627 /** 9628 * Retrieve extended data from the intent. 9629 * 9630 * @param name The name of the desired item. 9631 * 9632 * @return the value of an item previously added with 9633 * putCharSequenceArrayListExtra, or null if no 9634 * ArrayList<CharSequence> value was found. 9635 * 9636 * @see #putCharSequenceArrayListExtra(String, ArrayList) 9637 */ getCharSequenceArrayListExtra(String name)9638 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { 9639 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); 9640 } 9641 9642 /** 9643 * Retrieve extended data from the intent. 9644 * 9645 * @param name The name of the desired item. 9646 * 9647 * @return the value of an item previously added with putExtra(), 9648 * or null if no boolean array value was found. 9649 * 9650 * @see #putExtra(String, boolean[]) 9651 */ getBooleanArrayExtra(String name)9652 public @Nullable boolean[] getBooleanArrayExtra(String name) { 9653 return mExtras == null ? null : mExtras.getBooleanArray(name); 9654 } 9655 9656 /** 9657 * Retrieve extended data from the intent. 9658 * 9659 * @param name The name of the desired item. 9660 * 9661 * @return the value of an item previously added with putExtra(), 9662 * or null if no byte array value was found. 9663 * 9664 * @see #putExtra(String, byte[]) 9665 */ getByteArrayExtra(String name)9666 public @Nullable byte[] getByteArrayExtra(String name) { 9667 return mExtras == null ? null : mExtras.getByteArray(name); 9668 } 9669 9670 /** 9671 * Retrieve extended data from the intent. 9672 * 9673 * @param name The name of the desired item. 9674 * 9675 * @return the value of an item previously added with putExtra(), 9676 * or null if no short array value was found. 9677 * 9678 * @see #putExtra(String, short[]) 9679 */ getShortArrayExtra(String name)9680 public @Nullable short[] getShortArrayExtra(String name) { 9681 return mExtras == null ? null : mExtras.getShortArray(name); 9682 } 9683 9684 /** 9685 * Retrieve extended data from the intent. 9686 * 9687 * @param name The name of the desired item. 9688 * 9689 * @return the value of an item previously added with putExtra(), 9690 * or null if no char array value was found. 9691 * 9692 * @see #putExtra(String, char[]) 9693 */ getCharArrayExtra(String name)9694 public @Nullable char[] getCharArrayExtra(String name) { 9695 return mExtras == null ? null : mExtras.getCharArray(name); 9696 } 9697 9698 /** 9699 * Retrieve extended data from the intent. 9700 * 9701 * @param name The name of the desired item. 9702 * 9703 * @return the value of an item previously added with putExtra(), 9704 * or null if no int array value was found. 9705 * 9706 * @see #putExtra(String, int[]) 9707 */ getIntArrayExtra(String name)9708 public @Nullable int[] getIntArrayExtra(String name) { 9709 return mExtras == null ? null : mExtras.getIntArray(name); 9710 } 9711 9712 /** 9713 * Retrieve extended data from the intent. 9714 * 9715 * @param name The name of the desired item. 9716 * 9717 * @return the value of an item previously added with putExtra(), 9718 * or null if no long array value was found. 9719 * 9720 * @see #putExtra(String, long[]) 9721 */ getLongArrayExtra(String name)9722 public @Nullable long[] getLongArrayExtra(String name) { 9723 return mExtras == null ? null : mExtras.getLongArray(name); 9724 } 9725 9726 /** 9727 * Retrieve extended data from the intent. 9728 * 9729 * @param name The name of the desired item. 9730 * 9731 * @return the value of an item previously added with putExtra(), 9732 * or null if no float array value was found. 9733 * 9734 * @see #putExtra(String, float[]) 9735 */ getFloatArrayExtra(String name)9736 public @Nullable float[] getFloatArrayExtra(String name) { 9737 return mExtras == null ? null : mExtras.getFloatArray(name); 9738 } 9739 9740 /** 9741 * Retrieve extended data from the intent. 9742 * 9743 * @param name The name of the desired item. 9744 * 9745 * @return the value of an item previously added with putExtra(), 9746 * or null if no double array value was found. 9747 * 9748 * @see #putExtra(String, double[]) 9749 */ getDoubleArrayExtra(String name)9750 public @Nullable double[] getDoubleArrayExtra(String name) { 9751 return mExtras == null ? null : mExtras.getDoubleArray(name); 9752 } 9753 9754 /** 9755 * Retrieve extended data from the intent. 9756 * 9757 * @param name The name of the desired item. 9758 * 9759 * @return the value of an item previously added with putExtra(), 9760 * or null if no String array value was found. 9761 * 9762 * @see #putExtra(String, String[]) 9763 */ getStringArrayExtra(String name)9764 public @Nullable String[] getStringArrayExtra(String name) { 9765 return mExtras == null ? null : mExtras.getStringArray(name); 9766 } 9767 9768 /** 9769 * Retrieve extended data from the intent. 9770 * 9771 * @param name The name of the desired item. 9772 * 9773 * @return the value of an item previously added with putExtra(), 9774 * or null if no CharSequence array value was found. 9775 * 9776 * @see #putExtra(String, CharSequence[]) 9777 */ getCharSequenceArrayExtra(String name)9778 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) { 9779 return mExtras == null ? null : mExtras.getCharSequenceArray(name); 9780 } 9781 9782 /** 9783 * Retrieve extended data from the intent. 9784 * 9785 * @param name The name of the desired item. 9786 * 9787 * @return the value of an item previously added with putExtra(), 9788 * or null if no Bundle value was found. 9789 * 9790 * @see #putExtra(String, Bundle) 9791 */ getBundleExtra(String name)9792 public @Nullable Bundle getBundleExtra(String name) { 9793 return mExtras == null ? null : mExtras.getBundle(name); 9794 } 9795 9796 /** 9797 * Retrieve extended data from the intent. 9798 * 9799 * @param name The name of the desired item. 9800 * 9801 * @return the value of an item previously added with putExtra(), 9802 * or null if no IBinder value was found. 9803 * 9804 * @see #putExtra(String, IBinder) 9805 * 9806 * @deprecated 9807 * @hide 9808 */ 9809 @Deprecated 9810 @UnsupportedAppUsage getIBinderExtra(String name)9811 public IBinder getIBinderExtra(String name) { 9812 return mExtras == null ? null : mExtras.getIBinder(name); 9813 } 9814 9815 /** 9816 * Retrieve extended data from the intent. 9817 * 9818 * @param name The name of the desired item. 9819 * @param defaultValue The default value to return in case no item is 9820 * associated with the key 'name' 9821 * 9822 * @return the value of an item previously added with putExtra(), 9823 * or defaultValue if none was found. 9824 * 9825 * @see #putExtra 9826 * 9827 * @deprecated 9828 * @hide 9829 */ 9830 @Deprecated 9831 @UnsupportedAppUsage getExtra(String name, Object defaultValue)9832 public Object getExtra(String name, Object defaultValue) { 9833 Object result = defaultValue; 9834 if (mExtras != null) { 9835 Object result2 = mExtras.get(name); 9836 if (result2 != null) { 9837 result = result2; 9838 } 9839 } 9840 9841 return result; 9842 } 9843 9844 /** 9845 * Retrieves a map of extended data from the intent. 9846 * 9847 * @return the map of all extras previously added with putExtra(), 9848 * or null if none have been added. 9849 */ getExtras()9850 public @Nullable Bundle getExtras() { 9851 return (mExtras != null) 9852 ? new Bundle(mExtras) 9853 : null; 9854 } 9855 9856 /** 9857 * Returns the total size of the extras in bytes, or 0 if no extras are present. 9858 * @hide 9859 */ getExtrasTotalSize()9860 public int getExtrasTotalSize() { 9861 return (mExtras != null) 9862 ? mExtras.getSize() 9863 : 0; 9864 } 9865 9866 /** 9867 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or 9868 * return itself as-is. 9869 * @hide 9870 */ canStripForHistory()9871 public boolean canStripForHistory() { 9872 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null); 9873 } 9874 9875 /** 9876 * Call it when the system needs to keep an intent for logging purposes to remove fields 9877 * that are not needed for logging. 9878 * @hide 9879 */ maybeStripForHistory()9880 public Intent maybeStripForHistory() { 9881 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras? 9882 9883 if (!canStripForHistory()) { 9884 return this; 9885 } 9886 return new Intent(this, COPY_MODE_HISTORY); 9887 } 9888 9889 /** 9890 * Retrieve any special flags associated with this intent. You will 9891 * normally just set them with {@link #setFlags} and let the system 9892 * take the appropriate action with them. 9893 * 9894 * @return The currently set flags. 9895 * @see #setFlags 9896 * @see #addFlags 9897 * @see #removeFlags 9898 */ getFlags()9899 public @Flags int getFlags() { 9900 return mFlags; 9901 } 9902 9903 /** 9904 * Retrieve any extended flags associated with this intent. You will 9905 * normally just set them with {@link #setExtendedFlags} and let the system 9906 * take the appropriate action with them. 9907 * 9908 * @return The currently set extended flags. 9909 * @see #addExtendedFlags 9910 * @see #removeExtendedFlags 9911 * 9912 * @hide 9913 */ 9914 @TestApi getExtendedFlags()9915 public @ExtendedFlags int getExtendedFlags() { 9916 return mExtendedFlags; 9917 } 9918 9919 /** @hide */ 9920 @UnsupportedAppUsage isExcludingStopped()9921 public boolean isExcludingStopped() { 9922 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) 9923 == FLAG_EXCLUDE_STOPPED_PACKAGES; 9924 } 9925 9926 /** 9927 * Retrieve the application package name this Intent is limited to. When 9928 * resolving an Intent, if non-null this limits the resolution to only 9929 * components in the given application package. 9930 * 9931 * @return The name of the application package for the Intent. 9932 * 9933 * @see #resolveActivity 9934 * @see #setPackage 9935 */ getPackage()9936 public @Nullable String getPackage() { 9937 return mPackage; 9938 } 9939 9940 /** 9941 * Retrieve the concrete component associated with the intent. When receiving 9942 * an intent, this is the component that was found to best handle it (that is, 9943 * yourself) and will always be non-null; in all other cases it will be 9944 * null unless explicitly set. 9945 * 9946 * @return The name of the application component to handle the intent. 9947 * 9948 * @see #resolveActivity 9949 * @see #setComponent 9950 */ getComponent()9951 public @Nullable ComponentName getComponent() { 9952 return mComponent; 9953 } 9954 9955 /** 9956 * Get the bounds of the sender of this intent, in screen coordinates. This can be 9957 * used as a hint to the receiver for animations and the like. Null means that there 9958 * is no source bounds. 9959 */ getSourceBounds()9960 public @Nullable Rect getSourceBounds() { 9961 return mSourceBounds; 9962 } 9963 9964 /** 9965 * Return the Activity component that should be used to handle this intent. 9966 * The appropriate component is determined based on the information in the 9967 * intent, evaluated as follows: 9968 * 9969 * <p>If {@link #getComponent} returns an explicit class, that is returned 9970 * without any further consideration. 9971 * 9972 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent 9973 * category to be considered. 9974 * 9975 * <p>If {@link #getAction} is non-NULL, the activity must handle this 9976 * action. 9977 * 9978 * <p>If {@link #resolveType} returns non-NULL, the activity must handle 9979 * this type. 9980 * 9981 * <p>If {@link #addCategory} has added any categories, the activity must 9982 * handle ALL of the categories specified. 9983 * 9984 * <p>If {@link #getPackage} is non-NULL, only activity components in 9985 * that application package will be considered. 9986 * 9987 * <p>If there are no activities that satisfy all of these conditions, a 9988 * null string is returned. 9989 * 9990 * <p>If multiple activities are found to satisfy the intent, the one with 9991 * the highest priority will be used. If there are multiple activities 9992 * with the same priority, the system will either pick the best activity 9993 * based on user preference, or resolve to a system class that will allow 9994 * the user to pick an activity and forward from there. 9995 * 9996 * <p>This method is implemented simply by calling 9997 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter 9998 * true.</p> 9999 * <p> This API is called for you as part of starting an activity from an 10000 * intent. You do not normally need to call it yourself.</p> 10001 * 10002 * @param pm The package manager with which to resolve the Intent. 10003 * 10004 * @return Name of the component implementing an activity that can 10005 * display the intent. 10006 * 10007 * @see #setComponent 10008 * @see #getComponent 10009 * @see #resolveActivityInfo 10010 */ resolveActivity(@onNull PackageManager pm)10011 public ComponentName resolveActivity(@NonNull PackageManager pm) { 10012 if (mComponent != null) { 10013 return mComponent; 10014 } 10015 10016 ResolveInfo info = pm.resolveActivity( 10017 this, PackageManager.MATCH_DEFAULT_ONLY); 10018 if (info != null) { 10019 return new ComponentName( 10020 info.activityInfo.applicationInfo.packageName, 10021 info.activityInfo.name); 10022 } 10023 10024 return null; 10025 } 10026 10027 /** 10028 * Resolve the Intent into an {@link ActivityInfo} 10029 * describing the activity that should execute the intent. Resolution 10030 * follows the same rules as described for {@link #resolveActivity}, but 10031 * you get back the completely information about the resolved activity 10032 * instead of just its class name. 10033 * 10034 * @param pm The package manager with which to resolve the Intent. 10035 * @param flags Addition information to retrieve as per 10036 * {@link PackageManager#getActivityInfo(ComponentName, int) 10037 * PackageManager.getActivityInfo()}. 10038 * 10039 * @return PackageManager.ActivityInfo 10040 * 10041 * @see #resolveActivity 10042 */ resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)10043 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm, 10044 @PackageManager.ComponentInfoFlagsBits int flags) { 10045 ActivityInfo ai = null; 10046 if (mComponent != null) { 10047 try { 10048 ai = pm.getActivityInfo(mComponent, flags); 10049 } catch (PackageManager.NameNotFoundException e) { 10050 // ignore 10051 } 10052 } else { 10053 ResolveInfo info = pm.resolveActivity( 10054 this, PackageManager.MATCH_DEFAULT_ONLY | flags); 10055 if (info != null) { 10056 ai = info.activityInfo; 10057 } 10058 } 10059 10060 return ai; 10061 } 10062 10063 /** 10064 * Special function for use by the system to resolve service 10065 * intents to system apps. Throws an exception if there are 10066 * multiple potential matches to the Intent. Returns null if 10067 * there are no matches. 10068 * @hide 10069 */ 10070 @UnsupportedAppUsage resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)10071 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm, 10072 @PackageManager.ComponentInfoFlagsBits int flags) { 10073 if (mComponent != null) { 10074 return mComponent; 10075 } 10076 10077 List<ResolveInfo> results = pm.queryIntentServices(this, flags); 10078 if (results == null) { 10079 return null; 10080 } 10081 ComponentName comp = null; 10082 for (int i=0; i<results.size(); i++) { 10083 ResolveInfo ri = results.get(i); 10084 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { 10085 continue; 10086 } 10087 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, 10088 ri.serviceInfo.name); 10089 if (comp != null) { 10090 throw new IllegalStateException("Multiple system services handle " + this 10091 + ": " + comp + ", " + foundComp); 10092 } 10093 comp = foundComp; 10094 } 10095 return comp; 10096 } 10097 10098 /** 10099 * Set the general action to be performed. 10100 * 10101 * @param action An action name, such as ACTION_VIEW. Application-specific 10102 * actions should be prefixed with the vendor's package name. 10103 * 10104 * @return Returns the same Intent object, for chaining multiple calls 10105 * into a single statement. 10106 * 10107 * @see #getAction 10108 */ setAction(@ullable String action)10109 public @NonNull Intent setAction(@Nullable String action) { 10110 mAction = action != null ? action.intern() : null; 10111 return this; 10112 } 10113 10114 /** 10115 * Set the data this intent is operating on. This method automatically 10116 * clears any type that was previously set by {@link #setType} or 10117 * {@link #setTypeAndNormalize}. 10118 * 10119 * <p><em>Note: scheme matching in the Android framework is 10120 * case-sensitive, unlike the formal RFC. As a result, 10121 * you should always write your Uri with a lower case scheme, 10122 * or use {@link Uri#normalizeScheme} or 10123 * {@link #setDataAndNormalize} 10124 * to ensure that the scheme is converted to lower case.</em> 10125 * 10126 * @param data The Uri of the data this intent is now targeting. 10127 * 10128 * @return Returns the same Intent object, for chaining multiple calls 10129 * into a single statement. 10130 * 10131 * @see #getData 10132 * @see #setDataAndNormalize 10133 * @see android.net.Uri#normalizeScheme() 10134 */ setData(@ullable Uri data)10135 public @NonNull Intent setData(@Nullable Uri data) { 10136 mData = data; 10137 mType = null; 10138 return this; 10139 } 10140 10141 /** 10142 * Normalize and set the data this intent is operating on. 10143 * 10144 * <p>This method automatically clears any type that was 10145 * previously set (for example, by {@link #setType}). 10146 * 10147 * <p>The data Uri is normalized using 10148 * {@link android.net.Uri#normalizeScheme} before it is set, 10149 * so really this is just a convenience method for 10150 * <pre> 10151 * setData(data.normalize()) 10152 * </pre> 10153 * 10154 * @param data The Uri of the data this intent is now targeting. 10155 * 10156 * @return Returns the same Intent object, for chaining multiple calls 10157 * into a single statement. 10158 * 10159 * @see #getData 10160 * @see #setType 10161 * @see android.net.Uri#normalizeScheme 10162 */ setDataAndNormalize(@onNull Uri data)10163 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) { 10164 return setData(data.normalizeScheme()); 10165 } 10166 10167 /** 10168 * Set an explicit MIME data type. 10169 * 10170 * <p>This is used to create intents that only specify a type and not data, 10171 * for example to indicate the type of data to return. 10172 * 10173 * <p>This method automatically clears any data that was 10174 * previously set (for example by {@link #setData}). 10175 * 10176 * <p><em>Note: MIME type matching in the Android framework is 10177 * case-sensitive, unlike formal RFC MIME types. As a result, 10178 * you should always write your MIME types with lower case letters, 10179 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} 10180 * to ensure that it is converted to lower case.</em> 10181 * 10182 * @param type The MIME type of the data being handled by this intent. 10183 * 10184 * @return Returns the same Intent object, for chaining multiple calls 10185 * into a single statement. 10186 * 10187 * @see #getType 10188 * @see #setTypeAndNormalize 10189 * @see #setDataAndType 10190 * @see #normalizeMimeType 10191 */ setType(@ullable String type)10192 public @NonNull Intent setType(@Nullable String type) { 10193 mData = null; 10194 mType = type; 10195 return this; 10196 } 10197 10198 /** 10199 * Normalize and set an explicit MIME data type. 10200 * 10201 * <p>This is used to create intents that only specify a type and not data, 10202 * for example to indicate the type of data to return. 10203 * 10204 * <p>This method automatically clears any data that was 10205 * previously set (for example by {@link #setData}). 10206 * 10207 * <p>The MIME type is normalized using 10208 * {@link #normalizeMimeType} before it is set, 10209 * so really this is just a convenience method for 10210 * <pre> 10211 * setType(Intent.normalizeMimeType(type)) 10212 * </pre> 10213 * 10214 * @param type The MIME type of the data being handled by this intent. 10215 * 10216 * @return Returns the same Intent object, for chaining multiple calls 10217 * into a single statement. 10218 * 10219 * @see #getType 10220 * @see #setData 10221 * @see #normalizeMimeType 10222 */ setTypeAndNormalize(@ullable String type)10223 public @NonNull Intent setTypeAndNormalize(@Nullable String type) { 10224 return setType(normalizeMimeType(type)); 10225 } 10226 10227 /** 10228 * (Usually optional) Set the data for the intent along with an explicit 10229 * MIME data type. This method should very rarely be used -- it allows you 10230 * to override the MIME type that would ordinarily be inferred from the 10231 * data with your own type given here. 10232 * 10233 * <p><em>Note: MIME type and Uri scheme matching in the 10234 * Android framework is case-sensitive, unlike the formal RFC definitions. 10235 * As a result, you should always write these elements with lower case letters, 10236 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or 10237 * {@link #setDataAndTypeAndNormalize} 10238 * to ensure that they are converted to lower case.</em> 10239 * 10240 * @param data The Uri of the data this intent is now targeting. 10241 * @param type The MIME type of the data being handled by this intent. 10242 * 10243 * @return Returns the same Intent object, for chaining multiple calls 10244 * into a single statement. 10245 * 10246 * @see #setType 10247 * @see #setData 10248 * @see #normalizeMimeType 10249 * @see android.net.Uri#normalizeScheme 10250 * @see #setDataAndTypeAndNormalize 10251 */ setDataAndType(@ullable Uri data, @Nullable String type)10252 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) { 10253 mData = data; 10254 mType = type; 10255 return this; 10256 } 10257 10258 /** 10259 * (Usually optional) Normalize and set both the data Uri and an explicit 10260 * MIME data type. This method should very rarely be used -- it allows you 10261 * to override the MIME type that would ordinarily be inferred from the 10262 * data with your own type given here. 10263 * 10264 * <p>The data Uri and the MIME type are normalize using 10265 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} 10266 * before they are set, so really this is just a convenience method for 10267 * <pre> 10268 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) 10269 * </pre> 10270 * 10271 * @param data The Uri of the data this intent is now targeting. 10272 * @param type The MIME type of the data being handled by this intent. 10273 * 10274 * @return Returns the same Intent object, for chaining multiple calls 10275 * into a single statement. 10276 * 10277 * @see #setType 10278 * @see #setData 10279 * @see #setDataAndType 10280 * @see #normalizeMimeType 10281 * @see android.net.Uri#normalizeScheme 10282 */ setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)10283 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) { 10284 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); 10285 } 10286 10287 /** 10288 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent, 10289 * allowing it to be unique from other Intents that would otherwise look the same. In 10290 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two 10291 * Intents are the same as with other fields like {@link #setAction}. However, unlike those 10292 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter}; 10293 * it is as if the identifier has not been set on the Intent. 10294 * 10295 * <p>This can be used, for example, to make this Intent unique from other Intents that 10296 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware 10297 * however that the receiver of the PendingIntent will see whatever you put in here.) The 10298 * structure of this string is completely undefined by the platform, however if you are going 10299 * to be exposing identifier strings across different applications you may need to define 10300 * your own structure if there is no central party defining the contents of this field.</p> 10301 * 10302 * @param identifier The identifier for this Intent. The contents of the string have no 10303 * meaning to the system, except whether they are exactly the same as 10304 * another identifier. 10305 * 10306 * @return Returns the same Intent object, for chaining multiple calls 10307 * into a single statement. 10308 * 10309 * @see #getIdentifier 10310 */ setIdentifier(@ullable String identifier)10311 public @NonNull Intent setIdentifier(@Nullable String identifier) { 10312 mIdentifier = identifier; 10313 return this; 10314 } 10315 10316 /** 10317 * Add a new category to the intent. Categories provide additional detail 10318 * about the action the intent performs. When resolving an intent, only 10319 * activities that provide <em>all</em> of the requested categories will be 10320 * used. 10321 * 10322 * @param category The desired category. This can be either one of the 10323 * predefined Intent categories, or a custom category in your own 10324 * namespace. 10325 * 10326 * @return Returns the same Intent object, for chaining multiple calls 10327 * into a single statement. 10328 * 10329 * @see #hasCategory 10330 * @see #removeCategory 10331 */ addCategory(String category)10332 public @NonNull Intent addCategory(String category) { 10333 if (mCategories == null) { 10334 mCategories = new ArraySet<String>(); 10335 } 10336 mCategories.add(category.intern()); 10337 return this; 10338 } 10339 10340 /** 10341 * Remove a category from an intent. 10342 * 10343 * @param category The category to remove. 10344 * 10345 * @see #addCategory 10346 */ removeCategory(String category)10347 public void removeCategory(String category) { 10348 if (mCategories != null) { 10349 mCategories.remove(category); 10350 if (mCategories.size() == 0) { 10351 mCategories = null; 10352 } 10353 } 10354 } 10355 10356 /** 10357 * Set a selector for this Intent. This is a modification to the kinds of 10358 * things the Intent will match. If the selector is set, it will be used 10359 * when trying to find entities that can handle the Intent, instead of the 10360 * main contents of the Intent. This allows you build an Intent containing 10361 * a generic protocol while targeting it more specifically. 10362 * 10363 * <p>An example of where this may be used is with things like 10364 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an 10365 * Intent that will launch the Browser application. However, the correct 10366 * main entry point of an application is actually {@link #ACTION_MAIN} 10367 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} 10368 * used to specify the actual Activity to launch. If you launch the browser 10369 * with something different, undesired behavior may happen if the user has 10370 * previously or later launches it the normal way, since they do not match. 10371 * Instead, you can build an Intent with the MAIN action (but no ComponentName 10372 * yet specified) and set a selector with {@link #ACTION_MAIN} and 10373 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. 10374 * 10375 * <p>Setting a selector does not impact the behavior of 10376 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the 10377 * desired behavior of a selector -- it does not impact the base meaning 10378 * of the Intent, just what kinds of things will be matched against it 10379 * when determining who can handle it.</p> 10380 * 10381 * <p>You can not use both a selector and {@link #setPackage(String)} on 10382 * the same base Intent.</p> 10383 * 10384 * @param selector The desired selector Intent; set to null to not use 10385 * a special selector. 10386 */ setSelector(@ullable Intent selector)10387 public void setSelector(@Nullable Intent selector) { 10388 if (selector == this) { 10389 throw new IllegalArgumentException( 10390 "Intent being set as a selector of itself"); 10391 } 10392 if (selector != null && mPackage != null) { 10393 throw new IllegalArgumentException( 10394 "Can't set selector when package name is already set"); 10395 } 10396 mSelector = selector; 10397 } 10398 10399 /** 10400 * Set a {@link ClipData} associated with this Intent. This replaces any 10401 * previously set ClipData. 10402 * 10403 * <p>The ClipData in an intent is not used for Intent matching or other 10404 * such operations. Semantically it is like extras, used to transmit 10405 * additional data with the Intent. The main feature of using this over 10406 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} 10407 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI 10408 * items included in the clip data. This is useful, in particular, if 10409 * you want to transmit an Intent containing multiple <code>content:</code> 10410 * URIs for which the recipient may not have global permission to access the 10411 * content provider. 10412 * 10413 * <p>If the ClipData contains items that are themselves Intents, any 10414 * grant flags in those Intents will be ignored. Only the top-level flags 10415 * of the main Intent are respected, and will be applied to all Uri or 10416 * Intent items in the clip (or sub-items of the clip). 10417 * 10418 * <p>The MIME type, label, and icon in the ClipData object are not 10419 * directly used by Intent. Applications should generally rely on the 10420 * MIME type of the Intent itself, not what it may find in the ClipData. 10421 * A common practice is to construct a ClipData for use with an Intent 10422 * with a MIME type of "*/*". 10423 * 10424 * @param clip The new clip to set. May be null to clear the current clip. 10425 */ setClipData(@ullable ClipData clip)10426 public void setClipData(@Nullable ClipData clip) { 10427 mClipData = clip; 10428 } 10429 10430 /** 10431 * This is NOT a secure mechanism to identify the user who sent the intent. 10432 * When the intent is sent to a different user, it is used to fix uris by adding the user ID 10433 * who sent the intent. 10434 * @hide 10435 */ prepareToLeaveUser(int userId)10436 public void prepareToLeaveUser(int userId) { 10437 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. 10438 // We want mContentUserHint to refer to the original user, so don't do anything. 10439 if (mContentUserHint == UserHandle.USER_CURRENT) { 10440 mContentUserHint = userId; 10441 } 10442 } 10443 10444 /** 10445 * Add extended data to the intent. The name must include a package 10446 * prefix, for example the app com.android.contacts would use names 10447 * like "com.android.contacts.ShowAll". 10448 * 10449 * @param name The name of the extra data, with package prefix. 10450 * @param value The boolean data value. 10451 * 10452 * @return Returns the same Intent object, for chaining multiple calls 10453 * into a single statement. 10454 * 10455 * @see #putExtras 10456 * @see #removeExtra 10457 * @see #getBooleanExtra(String, boolean) 10458 */ putExtra(String name, boolean value)10459 public @NonNull Intent putExtra(String name, boolean value) { 10460 if (mExtras == null) { 10461 mExtras = new Bundle(); 10462 } 10463 mExtras.putBoolean(name, value); 10464 return this; 10465 } 10466 10467 /** 10468 * Add extended data to the intent. The name must include a package 10469 * prefix, for example the app com.android.contacts would use names 10470 * like "com.android.contacts.ShowAll". 10471 * 10472 * @param name The name of the extra data, with package prefix. 10473 * @param value The byte data value. 10474 * 10475 * @return Returns the same Intent object, for chaining multiple calls 10476 * into a single statement. 10477 * 10478 * @see #putExtras 10479 * @see #removeExtra 10480 * @see #getByteExtra(String, byte) 10481 */ putExtra(String name, byte value)10482 public @NonNull Intent putExtra(String name, byte value) { 10483 if (mExtras == null) { 10484 mExtras = new Bundle(); 10485 } 10486 mExtras.putByte(name, value); 10487 return this; 10488 } 10489 10490 /** 10491 * Add extended data to the intent. The name must include a package 10492 * prefix, for example the app com.android.contacts would use names 10493 * like "com.android.contacts.ShowAll". 10494 * 10495 * @param name The name of the extra data, with package prefix. 10496 * @param value The char data value. 10497 * 10498 * @return Returns the same Intent object, for chaining multiple calls 10499 * into a single statement. 10500 * 10501 * @see #putExtras 10502 * @see #removeExtra 10503 * @see #getCharExtra(String, char) 10504 */ putExtra(String name, char value)10505 public @NonNull Intent putExtra(String name, char value) { 10506 if (mExtras == null) { 10507 mExtras = new Bundle(); 10508 } 10509 mExtras.putChar(name, value); 10510 return this; 10511 } 10512 10513 /** 10514 * Add extended data to the intent. The name must include a package 10515 * prefix, for example the app com.android.contacts would use names 10516 * like "com.android.contacts.ShowAll". 10517 * 10518 * @param name The name of the extra data, with package prefix. 10519 * @param value The short data value. 10520 * 10521 * @return Returns the same Intent object, for chaining multiple calls 10522 * into a single statement. 10523 * 10524 * @see #putExtras 10525 * @see #removeExtra 10526 * @see #getShortExtra(String, short) 10527 */ putExtra(String name, short value)10528 public @NonNull Intent putExtra(String name, short value) { 10529 if (mExtras == null) { 10530 mExtras = new Bundle(); 10531 } 10532 mExtras.putShort(name, value); 10533 return this; 10534 } 10535 10536 /** 10537 * Add extended data to the intent. The name must include a package 10538 * prefix, for example the app com.android.contacts would use names 10539 * like "com.android.contacts.ShowAll". 10540 * 10541 * @param name The name of the extra data, with package prefix. 10542 * @param value The integer data value. 10543 * 10544 * @return Returns the same Intent object, for chaining multiple calls 10545 * into a single statement. 10546 * 10547 * @see #putExtras 10548 * @see #removeExtra 10549 * @see #getIntExtra(String, int) 10550 */ putExtra(String name, int value)10551 public @NonNull Intent putExtra(String name, int value) { 10552 if (mExtras == null) { 10553 mExtras = new Bundle(); 10554 } 10555 mExtras.putInt(name, value); 10556 return this; 10557 } 10558 10559 /** 10560 * Add extended data to the intent. The name must include a package 10561 * prefix, for example the app com.android.contacts would use names 10562 * like "com.android.contacts.ShowAll". 10563 * 10564 * @param name The name of the extra data, with package prefix. 10565 * @param value The long data value. 10566 * 10567 * @return Returns the same Intent object, for chaining multiple calls 10568 * into a single statement. 10569 * 10570 * @see #putExtras 10571 * @see #removeExtra 10572 * @see #getLongExtra(String, long) 10573 */ putExtra(String name, long value)10574 public @NonNull Intent putExtra(String name, long value) { 10575 if (mExtras == null) { 10576 mExtras = new Bundle(); 10577 } 10578 mExtras.putLong(name, value); 10579 return this; 10580 } 10581 10582 /** 10583 * Add extended data to the intent. The name must include a package 10584 * prefix, for example the app com.android.contacts would use names 10585 * like "com.android.contacts.ShowAll". 10586 * 10587 * @param name The name of the extra data, with package prefix. 10588 * @param value The float data value. 10589 * 10590 * @return Returns the same Intent object, for chaining multiple calls 10591 * into a single statement. 10592 * 10593 * @see #putExtras 10594 * @see #removeExtra 10595 * @see #getFloatExtra(String, float) 10596 */ putExtra(String name, float value)10597 public @NonNull Intent putExtra(String name, float value) { 10598 if (mExtras == null) { 10599 mExtras = new Bundle(); 10600 } 10601 mExtras.putFloat(name, value); 10602 return this; 10603 } 10604 10605 /** 10606 * Add extended data to the intent. The name must include a package 10607 * prefix, for example the app com.android.contacts would use names 10608 * like "com.android.contacts.ShowAll". 10609 * 10610 * @param name The name of the extra data, with package prefix. 10611 * @param value The double data value. 10612 * 10613 * @return Returns the same Intent object, for chaining multiple calls 10614 * into a single statement. 10615 * 10616 * @see #putExtras 10617 * @see #removeExtra 10618 * @see #getDoubleExtra(String, double) 10619 */ putExtra(String name, double value)10620 public @NonNull Intent putExtra(String name, double value) { 10621 if (mExtras == null) { 10622 mExtras = new Bundle(); 10623 } 10624 mExtras.putDouble(name, value); 10625 return this; 10626 } 10627 10628 /** 10629 * Add extended data to the intent. The name must include a package 10630 * prefix, for example the app com.android.contacts would use names 10631 * like "com.android.contacts.ShowAll". 10632 * 10633 * @param name The name of the extra data, with package prefix. 10634 * @param value The String data value. 10635 * 10636 * @return Returns the same Intent object, for chaining multiple calls 10637 * into a single statement. 10638 * 10639 * @see #putExtras 10640 * @see #removeExtra 10641 * @see #getStringExtra(String) 10642 */ putExtra(String name, @Nullable String value)10643 public @NonNull Intent putExtra(String name, @Nullable String value) { 10644 if (mExtras == null) { 10645 mExtras = new Bundle(); 10646 } 10647 mExtras.putString(name, value); 10648 return this; 10649 } 10650 10651 /** 10652 * Add extended data to the intent. The name must include a package 10653 * prefix, for example the app com.android.contacts would use names 10654 * like "com.android.contacts.ShowAll". 10655 * 10656 * @param name The name of the extra data, with package prefix. 10657 * @param value The CharSequence data value. 10658 * 10659 * @return Returns the same Intent object, for chaining multiple calls 10660 * into a single statement. 10661 * 10662 * @see #putExtras 10663 * @see #removeExtra 10664 * @see #getCharSequenceExtra(String) 10665 */ putExtra(String name, @Nullable CharSequence value)10666 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) { 10667 if (mExtras == null) { 10668 mExtras = new Bundle(); 10669 } 10670 mExtras.putCharSequence(name, value); 10671 return this; 10672 } 10673 10674 /** 10675 * Add extended data to the intent. The name must include a package 10676 * prefix, for example the app com.android.contacts would use names 10677 * like "com.android.contacts.ShowAll". 10678 * 10679 * @param name The name of the extra data, with package prefix. 10680 * @param value The Parcelable data value. 10681 * 10682 * @return Returns the same Intent object, for chaining multiple calls 10683 * into a single statement. 10684 * 10685 * @see #putExtras 10686 * @see #removeExtra 10687 * @see #getParcelableExtra(String) 10688 */ putExtra(String name, @Nullable Parcelable value)10689 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) { 10690 if (mExtras == null) { 10691 mExtras = new Bundle(); 10692 } 10693 mExtras.putParcelable(name, value); 10694 return this; 10695 } 10696 10697 /** 10698 * Add extended data to the intent. The name must include a package 10699 * prefix, for example the app com.android.contacts would use names 10700 * like "com.android.contacts.ShowAll". 10701 * 10702 * @param name The name of the extra data, with package prefix. 10703 * @param value The Parcelable[] data value. 10704 * 10705 * @return Returns the same Intent object, for chaining multiple calls 10706 * into a single statement. 10707 * 10708 * @see #putExtras 10709 * @see #removeExtra 10710 * @see #getParcelableArrayExtra(String) 10711 */ putExtra(String name, @Nullable Parcelable[] value)10712 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) { 10713 if (mExtras == null) { 10714 mExtras = new Bundle(); 10715 } 10716 mExtras.putParcelableArray(name, value); 10717 return this; 10718 } 10719 10720 /** 10721 * Add extended data to the intent. The name must include a package 10722 * prefix, for example the app com.android.contacts would use names 10723 * like "com.android.contacts.ShowAll". 10724 * 10725 * @param name The name of the extra data, with package prefix. 10726 * @param value The ArrayList<Parcelable> data value. 10727 * 10728 * @return Returns the same Intent object, for chaining multiple calls 10729 * into a single statement. 10730 * 10731 * @see #putExtras 10732 * @see #removeExtra 10733 * @see #getParcelableArrayListExtra(String) 10734 */ putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)10735 public @NonNull Intent putParcelableArrayListExtra(String name, 10736 @Nullable ArrayList<? extends Parcelable> value) { 10737 if (mExtras == null) { 10738 mExtras = new Bundle(); 10739 } 10740 mExtras.putParcelableArrayList(name, value); 10741 return this; 10742 } 10743 10744 /** 10745 * Add extended data to the intent. The name must include a package 10746 * prefix, for example the app com.android.contacts would use names 10747 * like "com.android.contacts.ShowAll". 10748 * 10749 * @param name The name of the extra data, with package prefix. 10750 * @param value The ArrayList<Integer> data value. 10751 * 10752 * @return Returns the same Intent object, for chaining multiple calls 10753 * into a single statement. 10754 * 10755 * @see #putExtras 10756 * @see #removeExtra 10757 * @see #getIntegerArrayListExtra(String) 10758 */ putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)10759 public @NonNull Intent putIntegerArrayListExtra(String name, 10760 @Nullable ArrayList<Integer> value) { 10761 if (mExtras == null) { 10762 mExtras = new Bundle(); 10763 } 10764 mExtras.putIntegerArrayList(name, value); 10765 return this; 10766 } 10767 10768 /** 10769 * Add extended data to the intent. The name must include a package 10770 * prefix, for example the app com.android.contacts would use names 10771 * like "com.android.contacts.ShowAll". 10772 * 10773 * @param name The name of the extra data, with package prefix. 10774 * @param value The ArrayList<String> data value. 10775 * 10776 * @return Returns the same Intent object, for chaining multiple calls 10777 * into a single statement. 10778 * 10779 * @see #putExtras 10780 * @see #removeExtra 10781 * @see #getStringArrayListExtra(String) 10782 */ putStringArrayListExtra(String name, @Nullable ArrayList<String> value)10783 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) { 10784 if (mExtras == null) { 10785 mExtras = new Bundle(); 10786 } 10787 mExtras.putStringArrayList(name, value); 10788 return this; 10789 } 10790 10791 /** 10792 * Add extended data to the intent. The name must include a package 10793 * prefix, for example the app com.android.contacts would use names 10794 * like "com.android.contacts.ShowAll". 10795 * 10796 * @param name The name of the extra data, with package prefix. 10797 * @param value The ArrayList<CharSequence> data value. 10798 * 10799 * @return Returns the same Intent object, for chaining multiple calls 10800 * into a single statement. 10801 * 10802 * @see #putExtras 10803 * @see #removeExtra 10804 * @see #getCharSequenceArrayListExtra(String) 10805 */ putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)10806 public @NonNull Intent putCharSequenceArrayListExtra(String name, 10807 @Nullable ArrayList<CharSequence> value) { 10808 if (mExtras == null) { 10809 mExtras = new Bundle(); 10810 } 10811 mExtras.putCharSequenceArrayList(name, value); 10812 return this; 10813 } 10814 10815 /** 10816 * Add extended data to the intent. The name must include a package 10817 * prefix, for example the app com.android.contacts would use names 10818 * like "com.android.contacts.ShowAll". 10819 * 10820 * @param name The name of the extra data, with package prefix. 10821 * @param value The Serializable data value. 10822 * 10823 * @return Returns the same Intent object, for chaining multiple calls 10824 * into a single statement. 10825 * 10826 * @see #putExtras 10827 * @see #removeExtra 10828 * @see #getSerializableExtra(String) 10829 */ putExtra(String name, @Nullable Serializable value)10830 public @NonNull Intent putExtra(String name, @Nullable Serializable value) { 10831 if (mExtras == null) { 10832 mExtras = new Bundle(); 10833 } 10834 mExtras.putSerializable(name, value); 10835 return this; 10836 } 10837 10838 /** 10839 * Add extended data to the intent. The name must include a package 10840 * prefix, for example the app com.android.contacts would use names 10841 * like "com.android.contacts.ShowAll". 10842 * 10843 * @param name The name of the extra data, with package prefix. 10844 * @param value The boolean array data value. 10845 * 10846 * @return Returns the same Intent object, for chaining multiple calls 10847 * into a single statement. 10848 * 10849 * @see #putExtras 10850 * @see #removeExtra 10851 * @see #getBooleanArrayExtra(String) 10852 */ putExtra(String name, @Nullable boolean[] value)10853 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) { 10854 if (mExtras == null) { 10855 mExtras = new Bundle(); 10856 } 10857 mExtras.putBooleanArray(name, value); 10858 return this; 10859 } 10860 10861 /** 10862 * Add extended data to the intent. The name must include a package 10863 * prefix, for example the app com.android.contacts would use names 10864 * like "com.android.contacts.ShowAll". 10865 * 10866 * @param name The name of the extra data, with package prefix. 10867 * @param value The byte array data value. 10868 * 10869 * @return Returns the same Intent object, for chaining multiple calls 10870 * into a single statement. 10871 * 10872 * @see #putExtras 10873 * @see #removeExtra 10874 * @see #getByteArrayExtra(String) 10875 */ putExtra(String name, @Nullable byte[] value)10876 public @NonNull Intent putExtra(String name, @Nullable byte[] value) { 10877 if (mExtras == null) { 10878 mExtras = new Bundle(); 10879 } 10880 mExtras.putByteArray(name, value); 10881 return this; 10882 } 10883 10884 /** 10885 * Add extended data to the intent. The name must include a package 10886 * prefix, for example the app com.android.contacts would use names 10887 * like "com.android.contacts.ShowAll". 10888 * 10889 * @param name The name of the extra data, with package prefix. 10890 * @param value The short array data value. 10891 * 10892 * @return Returns the same Intent object, for chaining multiple calls 10893 * into a single statement. 10894 * 10895 * @see #putExtras 10896 * @see #removeExtra 10897 * @see #getShortArrayExtra(String) 10898 */ putExtra(String name, @Nullable short[] value)10899 public @NonNull Intent putExtra(String name, @Nullable short[] value) { 10900 if (mExtras == null) { 10901 mExtras = new Bundle(); 10902 } 10903 mExtras.putShortArray(name, value); 10904 return this; 10905 } 10906 10907 /** 10908 * Add extended data to the intent. The name must include a package 10909 * prefix, for example the app com.android.contacts would use names 10910 * like "com.android.contacts.ShowAll". 10911 * 10912 * @param name The name of the extra data, with package prefix. 10913 * @param value The char array data value. 10914 * 10915 * @return Returns the same Intent object, for chaining multiple calls 10916 * into a single statement. 10917 * 10918 * @see #putExtras 10919 * @see #removeExtra 10920 * @see #getCharArrayExtra(String) 10921 */ putExtra(String name, @Nullable char[] value)10922 public @NonNull Intent putExtra(String name, @Nullable char[] value) { 10923 if (mExtras == null) { 10924 mExtras = new Bundle(); 10925 } 10926 mExtras.putCharArray(name, value); 10927 return this; 10928 } 10929 10930 /** 10931 * Add extended data to the intent. The name must include a package 10932 * prefix, for example the app com.android.contacts would use names 10933 * like "com.android.contacts.ShowAll". 10934 * 10935 * @param name The name of the extra data, with package prefix. 10936 * @param value The int array data value. 10937 * 10938 * @return Returns the same Intent object, for chaining multiple calls 10939 * into a single statement. 10940 * 10941 * @see #putExtras 10942 * @see #removeExtra 10943 * @see #getIntArrayExtra(String) 10944 */ putExtra(String name, @Nullable int[] value)10945 public @NonNull Intent putExtra(String name, @Nullable int[] value) { 10946 if (mExtras == null) { 10947 mExtras = new Bundle(); 10948 } 10949 mExtras.putIntArray(name, value); 10950 return this; 10951 } 10952 10953 /** 10954 * Add extended data to the intent. The name must include a package 10955 * prefix, for example the app com.android.contacts would use names 10956 * like "com.android.contacts.ShowAll". 10957 * 10958 * @param name The name of the extra data, with package prefix. 10959 * @param value The byte array data value. 10960 * 10961 * @return Returns the same Intent object, for chaining multiple calls 10962 * into a single statement. 10963 * 10964 * @see #putExtras 10965 * @see #removeExtra 10966 * @see #getLongArrayExtra(String) 10967 */ putExtra(String name, @Nullable long[] value)10968 public @NonNull Intent putExtra(String name, @Nullable long[] value) { 10969 if (mExtras == null) { 10970 mExtras = new Bundle(); 10971 } 10972 mExtras.putLongArray(name, value); 10973 return this; 10974 } 10975 10976 /** 10977 * Add extended data to the intent. The name must include a package 10978 * prefix, for example the app com.android.contacts would use names 10979 * like "com.android.contacts.ShowAll". 10980 * 10981 * @param name The name of the extra data, with package prefix. 10982 * @param value The float array data value. 10983 * 10984 * @return Returns the same Intent object, for chaining multiple calls 10985 * into a single statement. 10986 * 10987 * @see #putExtras 10988 * @see #removeExtra 10989 * @see #getFloatArrayExtra(String) 10990 */ putExtra(String name, @Nullable float[] value)10991 public @NonNull Intent putExtra(String name, @Nullable float[] value) { 10992 if (mExtras == null) { 10993 mExtras = new Bundle(); 10994 } 10995 mExtras.putFloatArray(name, value); 10996 return this; 10997 } 10998 10999 /** 11000 * Add extended data to the intent. The name must include a package 11001 * prefix, for example the app com.android.contacts would use names 11002 * like "com.android.contacts.ShowAll". 11003 * 11004 * @param name The name of the extra data, with package prefix. 11005 * @param value The double array data value. 11006 * 11007 * @return Returns the same Intent object, for chaining multiple calls 11008 * into a single statement. 11009 * 11010 * @see #putExtras 11011 * @see #removeExtra 11012 * @see #getDoubleArrayExtra(String) 11013 */ putExtra(String name, @Nullable double[] value)11014 public @NonNull Intent putExtra(String name, @Nullable double[] value) { 11015 if (mExtras == null) { 11016 mExtras = new Bundle(); 11017 } 11018 mExtras.putDoubleArray(name, value); 11019 return this; 11020 } 11021 11022 /** 11023 * Add extended data to the intent. The name must include a package 11024 * prefix, for example the app com.android.contacts would use names 11025 * like "com.android.contacts.ShowAll". 11026 * 11027 * @param name The name of the extra data, with package prefix. 11028 * @param value The String array data value. 11029 * 11030 * @return Returns the same Intent object, for chaining multiple calls 11031 * into a single statement. 11032 * 11033 * @see #putExtras 11034 * @see #removeExtra 11035 * @see #getStringArrayExtra(String) 11036 */ putExtra(String name, @Nullable String[] value)11037 public @NonNull Intent putExtra(String name, @Nullable String[] value) { 11038 if (mExtras == null) { 11039 mExtras = new Bundle(); 11040 } 11041 mExtras.putStringArray(name, value); 11042 return this; 11043 } 11044 11045 /** 11046 * Add extended data to the intent. The name must include a package 11047 * prefix, for example the app com.android.contacts would use names 11048 * like "com.android.contacts.ShowAll". 11049 * 11050 * @param name The name of the extra data, with package prefix. 11051 * @param value The CharSequence array data value. 11052 * 11053 * @return Returns the same Intent object, for chaining multiple calls 11054 * into a single statement. 11055 * 11056 * @see #putExtras 11057 * @see #removeExtra 11058 * @see #getCharSequenceArrayExtra(String) 11059 */ putExtra(String name, @Nullable CharSequence[] value)11060 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) { 11061 if (mExtras == null) { 11062 mExtras = new Bundle(); 11063 } 11064 mExtras.putCharSequenceArray(name, value); 11065 return this; 11066 } 11067 11068 /** 11069 * Add extended data to the intent. The name must include a package 11070 * prefix, for example the app com.android.contacts would use names 11071 * like "com.android.contacts.ShowAll". 11072 * 11073 * @param name The name of the extra data, with package prefix. 11074 * @param value The Bundle data value. 11075 * 11076 * @return Returns the same Intent object, for chaining multiple calls 11077 * into a single statement. 11078 * 11079 * @see #putExtras 11080 * @see #removeExtra 11081 * @see #getBundleExtra(String) 11082 */ putExtra(String name, @Nullable Bundle value)11083 public @NonNull Intent putExtra(String name, @Nullable Bundle value) { 11084 if (mExtras == null) { 11085 mExtras = new Bundle(); 11086 } 11087 mExtras.putBundle(name, value); 11088 return this; 11089 } 11090 11091 /** 11092 * Add extended data to the intent. The name must include a package 11093 * prefix, for example the app com.android.contacts would use names 11094 * like "com.android.contacts.ShowAll". 11095 * 11096 * @param name The name of the extra data, with package prefix. 11097 * @param value The IBinder data value. 11098 * 11099 * @return Returns the same Intent object, for chaining multiple calls 11100 * into a single statement. 11101 * 11102 * @see #putExtras 11103 * @see #removeExtra 11104 * @see #getIBinderExtra(String) 11105 * 11106 * @deprecated 11107 * @hide 11108 */ 11109 @Deprecated 11110 @UnsupportedAppUsage putExtra(String name, IBinder value)11111 public @NonNull Intent putExtra(String name, IBinder value) { 11112 if (mExtras == null) { 11113 mExtras = new Bundle(); 11114 } 11115 mExtras.putIBinder(name, value); 11116 return this; 11117 } 11118 11119 /** 11120 * Copy all extras in 'src' in to this intent. 11121 * 11122 * @param src Contains the extras to copy. 11123 * 11124 * @see #putExtra 11125 */ putExtras(@onNull Intent src)11126 public @NonNull Intent putExtras(@NonNull Intent src) { 11127 if (src.mExtras != null) { 11128 if (mExtras == null) { 11129 mExtras = new Bundle(src.mExtras); 11130 } else { 11131 mExtras.putAll(src.mExtras); 11132 } 11133 } 11134 // If the provided Intent was unparceled and this is not an Intent delivered to a protected 11135 // component then mark the extras as unfiltered. An Intent delivered to a protected 11136 // component had to come from a trusted component, and if unfiltered data was copied to the 11137 // delivered Intent then it would have been reported when that Intent left the sending 11138 // process. 11139 if ((src.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 11140 && (src.mLocalFlags & ( 11141 LOCAL_FLAG_FROM_PROTECTED_COMPONENT 11142 | LOCAL_FLAG_FROM_SYSTEM)) == 0) { 11143 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 11144 } 11145 return this; 11146 } 11147 11148 /** 11149 * Add a set of extended data to the intent. The keys must include a package 11150 * prefix, for example the app com.android.contacts would use names 11151 * like "com.android.contacts.ShowAll". 11152 * 11153 * @param extras The Bundle of extras to add to this intent. 11154 * 11155 * @see #putExtra 11156 * @see #removeExtra 11157 */ putExtras(@onNull Bundle extras)11158 public @NonNull Intent putExtras(@NonNull Bundle extras) { 11159 // If the provided Bundle has not yet been unparceled then treat this as unfiltered extras. 11160 if (extras.isParcelled()) { 11161 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 11162 } 11163 if (mExtras == null) { 11164 mExtras = new Bundle(); 11165 } 11166 mExtras.putAll(extras); 11167 return this; 11168 } 11169 11170 /** 11171 * Completely replace the extras in the Intent with the extras in the 11172 * given Intent. 11173 * 11174 * @param src The exact extras contained in this Intent are copied 11175 * into the target intent, replacing any that were previously there. 11176 */ replaceExtras(@onNull Intent src)11177 public @NonNull Intent replaceExtras(@NonNull Intent src) { 11178 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; 11179 return this; 11180 } 11181 11182 /** 11183 * Completely replace the extras in the Intent with the given Bundle of 11184 * extras. 11185 * 11186 * @param extras The new set of extras in the Intent, or null to erase 11187 * all extras. 11188 */ replaceExtras(@ullable Bundle extras)11189 public @NonNull Intent replaceExtras(@Nullable Bundle extras) { 11190 mExtras = extras != null ? new Bundle(extras) : null; 11191 return this; 11192 } 11193 11194 /** 11195 * Remove extended data from the intent. 11196 * 11197 * @see #putExtra 11198 */ removeExtra(String name)11199 public void removeExtra(String name) { 11200 if (mExtras != null) { 11201 mExtras.remove(name); 11202 if (mExtras.size() == 0) { 11203 mExtras = null; 11204 } 11205 } 11206 } 11207 11208 /** 11209 * Set special flags controlling how this intent is handled. Most values 11210 * here depend on the type of component being executed by the Intent, 11211 * specifically the FLAG_ACTIVITY_* flags are all for use with 11212 * {@link Context#startActivity Context.startActivity()} and the 11213 * FLAG_RECEIVER_* flags are all for use with 11214 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. 11215 * 11216 * <p>See the 11217 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 11218 * Stack</a> documentation for important information on how some of these options impact 11219 * the behavior of your application. 11220 * 11221 * @param flags The desired flags. 11222 * @return Returns the same Intent object, for chaining multiple calls 11223 * into a single statement. 11224 * @see #getFlags 11225 * @see #addFlags 11226 * @see #removeFlags 11227 */ setFlags(@lags int flags)11228 public @NonNull Intent setFlags(@Flags int flags) { 11229 mFlags = flags; 11230 return this; 11231 } 11232 11233 /** 11234 * Add additional flags to the intent (or with existing flags value). 11235 * 11236 * @param flags The new flags to set. 11237 * @return Returns the same Intent object, for chaining multiple calls into 11238 * a single statement. 11239 * @see #setFlags 11240 * @see #getFlags 11241 * @see #removeFlags 11242 */ addFlags(@lags int flags)11243 public @NonNull Intent addFlags(@Flags int flags) { 11244 mFlags |= flags; 11245 return this; 11246 } 11247 11248 /** 11249 * Add additional extended flags to the intent (or with existing flags value). 11250 * 11251 * @param flags The new flags to set. 11252 * @return Returns the same Intent object, for chaining multiple calls into 11253 * a single statement. 11254 * @see #getExtendedFlags 11255 * @see #removeExtendedFlags 11256 * 11257 * @hide 11258 */ 11259 @TestApi addExtendedFlags(@xtendedFlags int flags)11260 public @NonNull Intent addExtendedFlags(@ExtendedFlags int flags) { 11261 mExtendedFlags |= flags; 11262 return this; 11263 } 11264 11265 /** 11266 * Remove these flags from the intent. 11267 * 11268 * @param flags The flags to remove. 11269 * @see #setFlags 11270 * @see #getFlags 11271 * @see #addFlags 11272 */ removeFlags(@lags int flags)11273 public void removeFlags(@Flags int flags) { 11274 mFlags &= ~flags; 11275 } 11276 11277 /** 11278 * Remove these extended flags from the intent. 11279 * 11280 * @param flags The flags to remove. 11281 * @see #getExtendedFlags 11282 * @see #addExtendedFlags 11283 * 11284 * @hide 11285 */ removeExtendedFlags(@xtendedFlags int flags)11286 public void removeExtendedFlags(@ExtendedFlags int flags) { 11287 mExtendedFlags &= ~flags; 11288 } 11289 11290 /** 11291 * (Usually optional) Set an explicit application package name that limits 11292 * the components this Intent will resolve to. If left to the default 11293 * value of null, all components in all applications will considered. 11294 * If non-null, the Intent can only match the components in the given 11295 * application package. 11296 * 11297 * @param packageName The name of the application package to handle the 11298 * intent, or null to allow any application package. 11299 * 11300 * @return Returns the same Intent object, for chaining multiple calls 11301 * into a single statement. 11302 * 11303 * @see #getPackage 11304 * @see #resolveActivity 11305 */ setPackage(@ullable String packageName)11306 public @NonNull Intent setPackage(@Nullable String packageName) { 11307 if (packageName != null && mSelector != null) { 11308 throw new IllegalArgumentException( 11309 "Can't set package name when selector is already set"); 11310 } 11311 mPackage = packageName; 11312 return this; 11313 } 11314 11315 /** 11316 * (Usually optional) Explicitly set the component to handle the intent. 11317 * If left with the default value of null, the system will determine the 11318 * appropriate class to use based on the other fields (action, data, 11319 * type, categories) in the Intent. If this class is defined, the 11320 * specified class will always be used regardless of the other fields. You 11321 * should only set this value when you know you absolutely want a specific 11322 * class to be used; otherwise it is better to let the system find the 11323 * appropriate class so that you will respect the installed applications 11324 * and user preferences. 11325 * 11326 * @param component The name of the application component to handle the 11327 * intent, or null to let the system find one for you. 11328 * 11329 * @return Returns the same Intent object, for chaining multiple calls 11330 * into a single statement. 11331 * 11332 * @see #setClass 11333 * @see #setClassName(Context, String) 11334 * @see #setClassName(String, String) 11335 * @see #getComponent 11336 * @see #resolveActivity 11337 */ setComponent(@ullable ComponentName component)11338 public @NonNull Intent setComponent(@Nullable ComponentName component) { 11339 mComponent = component; 11340 return this; 11341 } 11342 11343 /** 11344 * Convenience for calling {@link #setComponent} with an 11345 * explicit class name. 11346 * 11347 * @param packageContext A Context of the application package implementing 11348 * this class. 11349 * @param className The name of a class inside of the application package 11350 * that will be used as the component for this Intent. 11351 * 11352 * @return Returns the same Intent object, for chaining multiple calls 11353 * into a single statement. 11354 * 11355 * @see #setComponent 11356 * @see #setClass 11357 */ setClassName(@onNull Context packageContext, @NonNull String className)11358 public @NonNull Intent setClassName(@NonNull Context packageContext, 11359 @NonNull String className) { 11360 mComponent = new ComponentName(packageContext, className); 11361 return this; 11362 } 11363 11364 /** 11365 * Convenience for calling {@link #setComponent} with an 11366 * explicit application package name and class name. 11367 * 11368 * @param packageName The name of the package implementing the desired 11369 * component. 11370 * @param className The name of a class inside of the application package 11371 * that will be used as the component for this Intent. 11372 * 11373 * @return Returns the same Intent object, for chaining multiple calls 11374 * into a single statement. 11375 * 11376 * @see #setComponent 11377 * @see #setClass 11378 */ setClassName(@onNull String packageName, @NonNull String className)11379 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) { 11380 mComponent = new ComponentName(packageName, className); 11381 return this; 11382 } 11383 11384 /** 11385 * Convenience for calling {@link #setComponent(ComponentName)} with the 11386 * name returned by a {@link Class} object. 11387 * 11388 * @param packageContext A Context of the application package implementing 11389 * this class. 11390 * @param cls The class name to set, equivalent to 11391 * <code>setClassName(context, cls.getName())</code>. 11392 * 11393 * @return Returns the same Intent object, for chaining multiple calls 11394 * into a single statement. 11395 * 11396 * @see #setComponent 11397 */ setClass(@onNull Context packageContext, @NonNull Class<?> cls)11398 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) { 11399 mComponent = new ComponentName(packageContext, cls); 11400 return this; 11401 } 11402 11403 /** 11404 * Set the bounds of the sender of this intent, in screen coordinates. This can be 11405 * used as a hint to the receiver for animations and the like. Null means that there 11406 * is no source bounds. 11407 */ setSourceBounds(@ullable Rect r)11408 public void setSourceBounds(@Nullable Rect r) { 11409 if (r != null) { 11410 mSourceBounds = new Rect(r); 11411 } else { 11412 mSourceBounds = null; 11413 } 11414 } 11415 11416 /** @hide */ 11417 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = { 11418 FILL_IN_ACTION, 11419 FILL_IN_DATA, 11420 FILL_IN_CATEGORIES, 11421 FILL_IN_COMPONENT, 11422 FILL_IN_PACKAGE, 11423 FILL_IN_SOURCE_BOUNDS, 11424 FILL_IN_SELECTOR, 11425 FILL_IN_CLIP_DATA 11426 }) 11427 @Retention(RetentionPolicy.SOURCE) 11428 public @interface FillInFlags {} 11429 11430 /** 11431 * Use with {@link #fillIn} to allow the current action value to be 11432 * overwritten, even if it is already set. 11433 */ 11434 public static final int FILL_IN_ACTION = 1<<0; 11435 11436 /** 11437 * Use with {@link #fillIn} to allow the current data or type value 11438 * overwritten, even if it is already set. 11439 */ 11440 public static final int FILL_IN_DATA = 1<<1; 11441 11442 /** 11443 * Use with {@link #fillIn} to allow the current categories to be 11444 * overwritten, even if they are already set. 11445 */ 11446 public static final int FILL_IN_CATEGORIES = 1<<2; 11447 11448 /** 11449 * Use with {@link #fillIn} to allow the current component value to be 11450 * overwritten, even if it is already set. 11451 */ 11452 public static final int FILL_IN_COMPONENT = 1<<3; 11453 11454 /** 11455 * Use with {@link #fillIn} to allow the current package value to be 11456 * overwritten, even if it is already set. 11457 */ 11458 public static final int FILL_IN_PACKAGE = 1<<4; 11459 11460 /** 11461 * Use with {@link #fillIn} to allow the current bounds rectangle to be 11462 * overwritten, even if it is already set. 11463 */ 11464 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; 11465 11466 /** 11467 * Use with {@link #fillIn} to allow the current selector to be 11468 * overwritten, even if it is already set. 11469 */ 11470 public static final int FILL_IN_SELECTOR = 1<<6; 11471 11472 /** 11473 * Use with {@link #fillIn} to allow the current ClipData to be 11474 * overwritten, even if it is already set. 11475 */ 11476 public static final int FILL_IN_CLIP_DATA = 1<<7; 11477 11478 /** 11479 * Use with {@link #fillIn} to allow the current identifier value to be 11480 * overwritten, even if it is already set. 11481 */ 11482 public static final int FILL_IN_IDENTIFIER = 1<<8; 11483 11484 /** 11485 * Copy the contents of <var>other</var> in to this object, but only 11486 * where fields are not defined by this object. For purposes of a field 11487 * being defined, the following pieces of data in the Intent are 11488 * considered to be separate fields: 11489 * 11490 * <ul> 11491 * <li> action, as set by {@link #setAction}. 11492 * <li> data Uri and MIME type, as set by {@link #setData(Uri)}, 11493 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. 11494 * <li> identifier, as set by {@link #setIdentifier}. 11495 * <li> categories, as set by {@link #addCategory}. 11496 * <li> package, as set by {@link #setPackage}. 11497 * <li> component, as set by {@link #setComponent(ComponentName)} or 11498 * related methods. 11499 * <li> source bounds, as set by {@link #setSourceBounds}. 11500 * <li> selector, as set by {@link #setSelector(Intent)}. 11501 * <li> clip data, as set by {@link #setClipData(ClipData)}. 11502 * <li> each top-level name in the associated extras. 11503 * </ul> 11504 * 11505 * <p>In addition, you can use the {@link #FILL_IN_ACTION}, 11506 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES}, 11507 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 11508 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override 11509 * the restriction where the corresponding field will not be replaced if 11510 * it is already set. 11511 * 11512 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} 11513 * is explicitly specified. The selector will only be copied if 11514 * {@link #FILL_IN_SELECTOR} is explicitly specified. 11515 * 11516 * <p>For example, consider Intent A with {data="foo", categories="bar"} 11517 * and Intent B with {action="gotit", data-type="some/thing", 11518 * categories="one","two"}. 11519 * 11520 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now 11521 * containing: {action="gotit", data-type="some/thing", 11522 * categories="bar"}. 11523 * 11524 * @param other Another Intent whose values are to be used to fill in 11525 * the current one. 11526 * @param flags Options to control which fields can be filled in. 11527 * 11528 * @return Returns a bit mask of {@link #FILL_IN_ACTION}, 11529 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 11530 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 11531 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were 11532 * changed. 11533 */ 11534 @FillInFlags fillIn(@onNull Intent other, @FillInFlags int flags)11535 public int fillIn(@NonNull Intent other, @FillInFlags int flags) { 11536 int changes = 0; 11537 boolean mayHaveCopiedUris = false; 11538 if (other.mAction != null 11539 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { 11540 mAction = other.mAction; 11541 changes |= FILL_IN_ACTION; 11542 } 11543 if ((other.mData != null || other.mType != null) 11544 && ((mData == null && mType == null) 11545 || (flags&FILL_IN_DATA) != 0)) { 11546 mData = other.mData; 11547 mType = other.mType; 11548 changes |= FILL_IN_DATA; 11549 mayHaveCopiedUris = true; 11550 } 11551 if (other.mIdentifier != null 11552 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) { 11553 mIdentifier = other.mIdentifier; 11554 changes |= FILL_IN_IDENTIFIER; 11555 } 11556 if (other.mCategories != null 11557 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { 11558 if (other.mCategories != null) { 11559 mCategories = new ArraySet<String>(other.mCategories); 11560 } 11561 changes |= FILL_IN_CATEGORIES; 11562 } 11563 if (other.mPackage != null 11564 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { 11565 // Only do this if mSelector is not set. 11566 if (mSelector == null) { 11567 mPackage = other.mPackage; 11568 changes |= FILL_IN_PACKAGE; 11569 } 11570 } 11571 // Selector is special: it can only be set if explicitly allowed, 11572 // for the same reason as the component name. 11573 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { 11574 if (mPackage == null) { 11575 mSelector = new Intent(other.mSelector); 11576 mPackage = null; 11577 changes |= FILL_IN_SELECTOR; 11578 } 11579 } 11580 if (other.mClipData != null 11581 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { 11582 mClipData = other.mClipData; 11583 changes |= FILL_IN_CLIP_DATA; 11584 mayHaveCopiedUris = true; 11585 } 11586 // Component is special: it can -only- be set if explicitly allowed, 11587 // since otherwise the sender could force the intent somewhere the 11588 // originator didn't intend. 11589 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { 11590 mComponent = other.mComponent; 11591 changes |= FILL_IN_COMPONENT; 11592 } 11593 mFlags |= other.mFlags; 11594 mExtendedFlags |= other.mExtendedFlags; 11595 if (other.mSourceBounds != null 11596 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { 11597 mSourceBounds = new Rect(other.mSourceBounds); 11598 changes |= FILL_IN_SOURCE_BOUNDS; 11599 } 11600 if (mExtras == null) { 11601 if (other.mExtras != null) { 11602 mExtras = new Bundle(other.mExtras); 11603 mayHaveCopiedUris = true; 11604 } 11605 } else if (other.mExtras != null) { 11606 try { 11607 Bundle newb = new Bundle(other.mExtras); 11608 newb.putAll(mExtras); 11609 mExtras = newb; 11610 mayHaveCopiedUris = true; 11611 } catch (RuntimeException e) { 11612 // Modifying the extras can cause us to unparcel the contents 11613 // of the bundle, and if we do this in the system process that 11614 // may fail. We really should handle this (i.e., the Bundle 11615 // impl shouldn't be on top of a plain map), but for now just 11616 // ignore it and keep the original contents. :( 11617 Log.w(TAG, "Failure filling in extras", e); 11618 } 11619 } 11620 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT 11621 && other.mContentUserHint != UserHandle.USER_CURRENT) { 11622 mContentUserHint = other.mContentUserHint; 11623 } 11624 return changes; 11625 } 11626 11627 /** 11628 * Merge the extras data in this intent with that of other supplied intent using the 11629 * strategy specified using {@code extrasMerger}. 11630 * 11631 * <p> Note the extras data in this intent is treated as the {@code first} param 11632 * and the extras data in {@code other} intent is treated as the {@code last} param 11633 * when using the passed in {@link BundleMerger} object. 11634 * 11635 * @hide 11636 */ mergeExtras(@onNull Intent other, @NonNull BundleMerger extrasMerger)11637 public void mergeExtras(@NonNull Intent other, @NonNull BundleMerger extrasMerger) { 11638 mExtras = extrasMerger.merge(mExtras, other.mExtras); 11639 } 11640 11641 /** 11642 * Wrapper class holding an Intent and implementing comparisons on it for 11643 * the purpose of filtering. The class implements its 11644 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as 11645 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and 11646 * {@link android.content.Intent#filterHashCode()} filterHashCode()} 11647 * on the wrapped Intent. 11648 */ 11649 public static final class FilterComparison { 11650 private final Intent mIntent; 11651 private final int mHashCode; 11652 FilterComparison(Intent intent)11653 public FilterComparison(Intent intent) { 11654 mIntent = intent; 11655 mHashCode = intent.filterHashCode(); 11656 } 11657 11658 /** 11659 * Return the Intent that this FilterComparison represents. 11660 * @return Returns the Intent held by the FilterComparison. Do 11661 * not modify! 11662 */ getIntent()11663 public Intent getIntent() { 11664 return mIntent; 11665 } 11666 11667 @Override equals(@ullable Object obj)11668 public boolean equals(@Nullable Object obj) { 11669 if (obj instanceof FilterComparison) { 11670 Intent other = ((FilterComparison)obj).mIntent; 11671 return mIntent.filterEquals(other); 11672 } 11673 return false; 11674 } 11675 11676 @Override hashCode()11677 public int hashCode() { 11678 return mHashCode; 11679 } 11680 } 11681 11682 /** 11683 * Determine if two intents are the same for the purposes of intent 11684 * resolution (filtering). That is, if their action, data, type, identity, 11685 * class, and categories are the same. This does <em>not</em> compare 11686 * any extra data included in the intents. Note that technically when actually 11687 * matching against an {@link IntentFilter} the identifier is ignored, while here 11688 * it is directly compared for equality like the other fields. 11689 * 11690 * @param other The other Intent to compare against. 11691 * 11692 * @return Returns true if action, data, type, class, and categories 11693 * are the same. 11694 */ filterEquals(Intent other)11695 public boolean filterEquals(Intent other) { 11696 if (other == null) { 11697 return false; 11698 } 11699 if (!Objects.equals(this.mAction, other.mAction)) return false; 11700 if (!Objects.equals(this.mData, other.mData)) return false; 11701 if (!Objects.equals(this.mType, other.mType)) return false; 11702 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false; 11703 if (!Objects.equals(this.mPackage, other.mPackage)) return false; 11704 if (!Objects.equals(this.mComponent, other.mComponent)) return false; 11705 if (!Objects.equals(this.mCategories, other.mCategories)) return false; 11706 11707 return true; 11708 } 11709 11710 /** 11711 * Generate hash code that matches semantics of filterEquals(). 11712 * 11713 * @return Returns the hash value of the action, data, type, class, and 11714 * categories. 11715 * 11716 * @see #filterEquals 11717 */ filterHashCode()11718 public int filterHashCode() { 11719 int code = 0; 11720 if (mAction != null) { 11721 code += mAction.hashCode(); 11722 } 11723 if (mData != null) { 11724 code += mData.hashCode(); 11725 } 11726 if (mType != null) { 11727 code += mType.hashCode(); 11728 } 11729 if (mIdentifier != null) { 11730 code += mIdentifier.hashCode(); 11731 } 11732 if (mPackage != null) { 11733 code += mPackage.hashCode(); 11734 } 11735 if (mComponent != null) { 11736 code += mComponent.hashCode(); 11737 } 11738 if (mCategories != null) { 11739 code += mCategories.hashCode(); 11740 } 11741 return code; 11742 } 11743 11744 @Override toString()11745 public String toString() { 11746 StringBuilder b = new StringBuilder(128); 11747 toString(b); 11748 return b.toString(); 11749 } 11750 11751 /** @hide */ toString(@onNull StringBuilder b)11752 public void toString(@NonNull StringBuilder b) { 11753 b.append("Intent { "); 11754 toShortString(b, true, true, true, false); 11755 b.append(" }"); 11756 } 11757 11758 /** @hide */ 11759 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) toInsecureString()11760 public String toInsecureString() { 11761 StringBuilder b = new StringBuilder(128); 11762 11763 b.append("Intent { "); 11764 toShortString(b, false, true, true, false); 11765 b.append(" }"); 11766 11767 return b.toString(); 11768 } 11769 11770 /** @hide */ toShortString(boolean secure, boolean comp, boolean extras, boolean clip)11771 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { 11772 StringBuilder b = new StringBuilder(128); 11773 toShortString(b, secure, comp, extras, clip); 11774 return b.toString(); 11775 } 11776 11777 /** @hide */ toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)11778 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, 11779 boolean clip) { 11780 boolean first = true; 11781 if (mAction != null) { 11782 b.append("act=").append(mAction); 11783 first = false; 11784 } 11785 if (mCategories != null) { 11786 if (!first) { 11787 b.append(' '); 11788 } 11789 first = false; 11790 b.append("cat=["); 11791 for (int i=0; i<mCategories.size(); i++) { 11792 if (i > 0) b.append(','); 11793 b.append(mCategories.valueAt(i)); 11794 } 11795 b.append("]"); 11796 } 11797 if (mData != null) { 11798 if (!first) { 11799 b.append(' '); 11800 } 11801 first = false; 11802 b.append("dat="); 11803 if (secure) { 11804 b.append(mData.toSafeString()); 11805 } else { 11806 b.append(mData); 11807 } 11808 } 11809 if (mType != null) { 11810 if (!first) { 11811 b.append(' '); 11812 } 11813 first = false; 11814 b.append("typ=").append(mType); 11815 } 11816 if (mIdentifier != null) { 11817 if (!first) { 11818 b.append(' '); 11819 } 11820 first = false; 11821 b.append("id=").append(mIdentifier); 11822 } 11823 if (mFlags != 0) { 11824 if (!first) { 11825 b.append(' '); 11826 } 11827 first = false; 11828 b.append("flg=0x").append(Integer.toHexString(mFlags)); 11829 } 11830 if (mExtendedFlags != 0) { 11831 if (!first) { 11832 b.append(' '); 11833 } 11834 first = false; 11835 b.append("xflg=0x").append(Integer.toHexString(mExtendedFlags)); 11836 } 11837 if (mPackage != null) { 11838 if (!first) { 11839 b.append(' '); 11840 } 11841 first = false; 11842 b.append("pkg=").append(mPackage); 11843 } 11844 if (comp && mComponent != null) { 11845 if (!first) { 11846 b.append(' '); 11847 } 11848 first = false; 11849 b.append("cmp=").append(mComponent.flattenToShortString()); 11850 } 11851 if (mSourceBounds != null) { 11852 if (!first) { 11853 b.append(' '); 11854 } 11855 first = false; 11856 b.append("bnds=").append(mSourceBounds.toShortString()); 11857 } 11858 if (mClipData != null) { 11859 if (!first) { 11860 b.append(' '); 11861 } 11862 b.append("clip={"); 11863 mClipData.toShortString(b, !clip || secure); 11864 first = false; 11865 b.append('}'); 11866 } 11867 if (extras && mExtras != null) { 11868 if (!first) { 11869 b.append(' '); 11870 } 11871 first = false; 11872 b.append("(has extras)"); 11873 } 11874 if (mContentUserHint != UserHandle.USER_CURRENT) { 11875 if (!first) { 11876 b.append(' '); 11877 } 11878 first = false; 11879 b.append("u=").append(mContentUserHint); 11880 } 11881 if (mSelector != null) { 11882 b.append(" sel="); 11883 mSelector.toShortString(b, secure, comp, extras, clip); 11884 b.append("}"); 11885 } 11886 if (mOriginalIntent != null) { 11887 b.append(" org={"); 11888 mOriginalIntent.toShortString(b, secure, comp, extras, clip); 11889 b.append("}"); 11890 } 11891 } 11892 11893 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId)11894 public void dumpDebug(ProtoOutputStream proto, long fieldId) { 11895 // Same input parameters that toString() gives to toShortString(). 11896 dumpDebug(proto, fieldId, true, true, true, false); 11897 } 11898 11899 /** @hide */ dumpDebug(ProtoOutputStream proto)11900 public void dumpDebug(ProtoOutputStream proto) { 11901 // Same input parameters that toString() gives to toShortString(). 11902 dumpDebugWithoutFieldId(proto, true, true, true, false); 11903 } 11904 11905 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)11906 public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, 11907 boolean extras, boolean clip) { 11908 long token = proto.start(fieldId); 11909 dumpDebugWithoutFieldId(proto, secure, comp, extras, clip); 11910 proto.end(token); 11911 } 11912 dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)11913 private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, 11914 boolean extras, boolean clip) { 11915 if (mAction != null) { 11916 proto.write(IntentProto.ACTION, mAction); 11917 } 11918 if (mCategories != null) { 11919 for (String category : mCategories) { 11920 proto.write(IntentProto.CATEGORIES, category); 11921 } 11922 } 11923 if (mData != null) { 11924 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString()); 11925 } 11926 if (mType != null) { 11927 proto.write(IntentProto.TYPE, mType); 11928 } 11929 if (mIdentifier != null) { 11930 proto.write(IntentProto.IDENTIFIER, mIdentifier); 11931 } 11932 if (mFlags != 0) { 11933 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags)); 11934 } 11935 if (mExtendedFlags != 0) { 11936 proto.write(IntentProto.EXTENDED_FLAG, "0x" + Integer.toHexString(mExtendedFlags)); 11937 } 11938 if (mPackage != null) { 11939 proto.write(IntentProto.PACKAGE, mPackage); 11940 } 11941 if (comp && mComponent != null) { 11942 mComponent.dumpDebug(proto, IntentProto.COMPONENT); 11943 } 11944 if (mSourceBounds != null) { 11945 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString()); 11946 } 11947 if (mClipData != null) { 11948 StringBuilder b = new StringBuilder(); 11949 mClipData.toShortString(b, !clip || secure); 11950 proto.write(IntentProto.CLIP_DATA, b.toString()); 11951 } 11952 if (extras && mExtras != null) { 11953 proto.write(IntentProto.EXTRAS, mExtras.toShortString()); 11954 } 11955 if (mContentUserHint != 0) { 11956 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint); 11957 } 11958 if (mSelector != null) { 11959 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip)); 11960 } 11961 } 11962 11963 /** 11964 * Call {@link #toUri} with 0 flags. 11965 * @deprecated Use {@link #toUri} instead. 11966 */ 11967 @Deprecated toURI()11968 public String toURI() { 11969 return toUri(0); 11970 } 11971 11972 /** 11973 * Convert this Intent into a String holding a URI representation of it. 11974 * The returned URI string has been properly URI encoded, so it can be 11975 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the 11976 * Intent's data as the base URI, with an additional fragment describing 11977 * the action, categories, type, flags, package, component, and extras. 11978 * 11979 * <p>You can convert the returned string back to an Intent with 11980 * {@link #getIntent}. 11981 * 11982 * @param flags Additional operating flags. 11983 * 11984 * @return Returns a URI encoding URI string describing the entire contents 11985 * of the Intent. 11986 */ toUri(@riFlags int flags)11987 public String toUri(@UriFlags int flags) { 11988 StringBuilder uri = new StringBuilder(128); 11989 if ((flags&URI_ANDROID_APP_SCHEME) != 0) { 11990 if (mPackage == null) { 11991 throw new IllegalArgumentException( 11992 "Intent must include an explicit package name to build an android-app: " 11993 + this); 11994 } 11995 uri.append("android-app://"); 11996 uri.append(Uri.encode(mPackage)); 11997 String scheme = null; 11998 if (mData != null) { 11999 // All values here must be wrapped with Uri#encodeIfNotEncoded because it is 12000 // possible to exploit the Uri API to return a raw unencoded value, which will 12001 // not deserialize properly and may cause the resulting Intent to be transformed 12002 // to a malicious value. 12003 scheme = Uri.encodeIfNotEncoded(mData.getScheme(), null); 12004 if (scheme != null) { 12005 uri.append('/'); 12006 uri.append(scheme); 12007 String authority = Uri.encodeIfNotEncoded(mData.getEncodedAuthority(), null); 12008 if (authority != null) { 12009 uri.append('/'); 12010 uri.append(authority); 12011 12012 // Multiple path segments are allowed, don't encode the path / separator 12013 String path = Uri.encodeIfNotEncoded(mData.getEncodedPath(), "/"); 12014 if (path != null) { 12015 uri.append(path); 12016 } 12017 String queryParams = Uri.encodeIfNotEncoded(mData.getEncodedQuery(), null); 12018 if (queryParams != null) { 12019 uri.append('?'); 12020 uri.append(queryParams); 12021 } 12022 String fragment = Uri.encodeIfNotEncoded(mData.getEncodedFragment(), null); 12023 if (fragment != null) { 12024 uri.append('#'); 12025 uri.append(fragment); 12026 } 12027 } 12028 } 12029 } 12030 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, 12031 mPackage, flags); 12032 return uri.toString(); 12033 } 12034 String scheme = null; 12035 if (mData != null) { 12036 String data = mData.toString(); 12037 if ((flags&URI_INTENT_SCHEME) != 0) { 12038 final int N = data.length(); 12039 for (int i=0; i<N; i++) { 12040 char c = data.charAt(i); 12041 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 12042 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') { 12043 continue; 12044 } 12045 if (c == ':' && i > 0) { 12046 // Valid scheme. 12047 scheme = data.substring(0, i); 12048 uri.append("intent:"); 12049 data = data.substring(i+1); 12050 break; 12051 } 12052 12053 // No scheme. 12054 break; 12055 } 12056 } 12057 uri.append(data); 12058 12059 } else if ((flags&URI_INTENT_SCHEME) != 0) { 12060 uri.append("intent:"); 12061 } 12062 12063 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); 12064 12065 return uri.toString(); 12066 } 12067 toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)12068 private void toUriFragment(StringBuilder uri, String scheme, String defAction, 12069 String defPackage, int flags) { 12070 StringBuilder frag = new StringBuilder(128); 12071 12072 toUriInner(frag, scheme, defAction, defPackage, flags); 12073 if (mSelector != null) { 12074 frag.append("SEL;"); 12075 // Note that for now we are not going to try to handle the 12076 // data part; not clear how to represent this as a URI, and 12077 // not much utility in it. 12078 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, 12079 null, null, flags); 12080 } 12081 12082 if (frag.length() > 0) { 12083 uri.append("#Intent;"); 12084 uri.append(frag); 12085 uri.append("end"); 12086 } 12087 } 12088 toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)12089 private void toUriInner(StringBuilder uri, String scheme, String defAction, 12090 String defPackage, int flags) { 12091 if (scheme != null) { 12092 uri.append("scheme=").append(Uri.encode(scheme)).append(';'); 12093 } 12094 if (mAction != null && !mAction.equals(defAction)) { 12095 uri.append("action=").append(Uri.encode(mAction)).append(';'); 12096 } 12097 if (mCategories != null) { 12098 for (int i=0; i<mCategories.size(); i++) { 12099 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';'); 12100 } 12101 } 12102 if (mType != null) { 12103 uri.append("type=").append(Uri.encode(mType, "/")).append(';'); 12104 } 12105 if (mIdentifier != null) { 12106 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';'); 12107 } 12108 if (mFlags != 0) { 12109 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); 12110 } 12111 if (mExtendedFlags != 0) { 12112 uri.append("extendedLaunchFlags=0x").append(Integer.toHexString(mExtendedFlags)) 12113 .append(';'); 12114 } 12115 if (mPackage != null && !mPackage.equals(defPackage)) { 12116 uri.append("package=").append(Uri.encode(mPackage)).append(';'); 12117 } 12118 if (mComponent != null) { 12119 uri.append("component=").append(Uri.encode( 12120 mComponent.flattenToShortString(), "/")).append(';'); 12121 } 12122 if (mSourceBounds != null) { 12123 uri.append("sourceBounds=") 12124 .append(Uri.encode(mSourceBounds.flattenToString())) 12125 .append(';'); 12126 } 12127 if (mExtras != null) { 12128 for (String key : mExtras.keySet()) { 12129 final Object value = mExtras.get(key); 12130 char entryType = 12131 value instanceof String ? 'S' : 12132 value instanceof Boolean ? 'B' : 12133 value instanceof Byte ? 'b' : 12134 value instanceof Character ? 'c' : 12135 value instanceof Double ? 'd' : 12136 value instanceof Float ? 'f' : 12137 value instanceof Integer ? 'i' : 12138 value instanceof Long ? 'l' : 12139 value instanceof Short ? 's' : 12140 '\0'; 12141 12142 if (entryType != '\0') { 12143 uri.append(entryType); 12144 uri.append('.'); 12145 uri.append(Uri.encode(key)); 12146 uri.append('='); 12147 uri.append(Uri.encode(value.toString())); 12148 uri.append(';'); 12149 } 12150 } 12151 } 12152 } 12153 describeContents()12154 public int describeContents() { 12155 return (mExtras != null) ? mExtras.describeContents() : 0; 12156 } 12157 writeToParcel(Parcel out, int flags)12158 public void writeToParcel(Parcel out, int flags) { 12159 out.writeString8(mAction); 12160 Uri.writeToParcel(out, mData); 12161 out.writeString8(mType); 12162 out.writeString8(mIdentifier); 12163 out.writeInt(mFlags); 12164 out.writeInt(mExtendedFlags); 12165 out.writeString8(mPackage); 12166 ComponentName.writeToParcel(mComponent, out); 12167 12168 if (mSourceBounds != null) { 12169 out.writeInt(1); 12170 mSourceBounds.writeToParcel(out, flags); 12171 } else { 12172 out.writeInt(0); 12173 } 12174 12175 if (mCategories != null) { 12176 final int N = mCategories.size(); 12177 out.writeInt(N); 12178 for (int i=0; i<N; i++) { 12179 out.writeString8(mCategories.valueAt(i)); 12180 } 12181 } else { 12182 out.writeInt(0); 12183 } 12184 12185 if (mSelector != null) { 12186 out.writeInt(1); 12187 mSelector.writeToParcel(out, flags); 12188 } else { 12189 out.writeInt(0); 12190 } 12191 12192 if (mClipData != null) { 12193 out.writeInt(1); 12194 mClipData.writeToParcel(out, flags); 12195 } else { 12196 out.writeInt(0); 12197 } 12198 out.writeInt(mContentUserHint); 12199 out.writeBundle(mExtras); 12200 12201 if (mOriginalIntent != null) { 12202 out.writeInt(1); 12203 mOriginalIntent.writeToParcel(out, flags); 12204 } else { 12205 out.writeInt(0); 12206 } 12207 } 12208 12209 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR 12210 = new Parcelable.Creator<Intent>() { 12211 public Intent createFromParcel(Parcel in) { 12212 return new Intent(in); 12213 } 12214 public Intent[] newArray(int size) { 12215 return new Intent[size]; 12216 } 12217 }; 12218 12219 /** @hide */ Intent(Parcel in)12220 protected Intent(Parcel in) { 12221 // Remember that we came from a remote process to help detect security 12222 // issues caused by later unsafe launches 12223 mLocalFlags = LOCAL_FLAG_FROM_PARCEL; 12224 readFromParcel(in); 12225 } 12226 readFromParcel(Parcel in)12227 public void readFromParcel(Parcel in) { 12228 setAction(in.readString8()); 12229 mData = Uri.CREATOR.createFromParcel(in); 12230 mType = in.readString8(); 12231 mIdentifier = in.readString8(); 12232 mFlags = in.readInt(); 12233 mExtendedFlags = in.readInt(); 12234 mPackage = in.readString8(); 12235 mComponent = ComponentName.readFromParcel(in); 12236 12237 if (in.readInt() != 0) { 12238 mSourceBounds = Rect.CREATOR.createFromParcel(in); 12239 } 12240 12241 int N = in.readInt(); 12242 if (N > 0) { 12243 mCategories = new ArraySet<String>(); 12244 int i; 12245 for (i=0; i<N; i++) { 12246 mCategories.add(in.readString8().intern()); 12247 } 12248 } else { 12249 mCategories = null; 12250 } 12251 12252 if (in.readInt() != 0) { 12253 mSelector = new Intent(in); 12254 } 12255 12256 if (in.readInt() != 0) { 12257 mClipData = new ClipData(in); 12258 } 12259 mContentUserHint = in.readInt(); 12260 mExtras = in.readBundle(); 12261 if (in.readInt() != 0) { 12262 mOriginalIntent = new Intent(in); 12263 } 12264 } 12265 12266 /** 12267 * Parses the "intent" element (and its children) from XML and instantiates 12268 * an Intent object. The given XML parser should be located at the tag 12269 * where parsing should start (often named "intent"), from which the 12270 * basic action, data, type, and package and class name will be 12271 * retrieved. The function will then parse in to any child elements, 12272 * looking for <category android:name="xxx"> tags to add categories and 12273 * <extra android:name="xxx" android:value="yyy"> to attach extra data 12274 * to the intent. 12275 * 12276 * @param resources The Resources to use when inflating resources. 12277 * @param parser The XML parser pointing at an "intent" tag. 12278 * @param attrs The AttributeSet interface for retrieving extended 12279 * attribute data at the current <var>parser</var> location. 12280 * @return An Intent object matching the XML data. 12281 * @throws XmlPullParserException If there was an XML parsing error. 12282 * @throws IOException If there was an I/O error. 12283 */ parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)12284 public static @NonNull Intent parseIntent(@NonNull Resources resources, 12285 @NonNull XmlPullParser parser, AttributeSet attrs) 12286 throws XmlPullParserException, IOException { 12287 Intent intent = new Intent(); 12288 12289 TypedArray sa = resources.obtainAttributes(attrs, 12290 com.android.internal.R.styleable.Intent); 12291 12292 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); 12293 12294 String data = sa.getString(com.android.internal.R.styleable.Intent_data); 12295 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); 12296 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); 12297 12298 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier)); 12299 12300 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); 12301 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); 12302 if (packageName != null && className != null) { 12303 intent.setComponent(new ComponentName(packageName, className)); 12304 } 12305 12306 sa.recycle(); 12307 12308 int outerDepth = parser.getDepth(); 12309 int type; 12310 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 12311 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 12312 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 12313 continue; 12314 } 12315 12316 String nodeName = parser.getName(); 12317 if (nodeName.equals(TAG_CATEGORIES)) { 12318 sa = resources.obtainAttributes(attrs, 12319 com.android.internal.R.styleable.IntentCategory); 12320 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); 12321 sa.recycle(); 12322 12323 if (cat != null) { 12324 intent.addCategory(cat); 12325 } 12326 XmlUtils.skipCurrentTag(parser); 12327 12328 } else if (nodeName.equals(TAG_EXTRA)) { 12329 if (intent.mExtras == null) { 12330 intent.mExtras = new Bundle(); 12331 } 12332 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); 12333 XmlUtils.skipCurrentTag(parser); 12334 12335 } else { 12336 XmlUtils.skipCurrentTag(parser); 12337 } 12338 } 12339 12340 return intent; 12341 } 12342 12343 /** @hide */ saveToXml(XmlSerializer out)12344 public void saveToXml(XmlSerializer out) throws IOException { 12345 if (mAction != null) { 12346 out.attribute(null, ATTR_ACTION, mAction); 12347 } 12348 if (mData != null) { 12349 out.attribute(null, ATTR_DATA, mData.toString()); 12350 } 12351 if (mType != null) { 12352 out.attribute(null, ATTR_TYPE, mType); 12353 } 12354 if (mIdentifier != null) { 12355 out.attribute(null, ATTR_IDENTIFIER, mIdentifier); 12356 } 12357 if (mComponent != null) { 12358 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); 12359 } 12360 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); 12361 12362 if (mCategories != null) { 12363 out.startTag(null, TAG_CATEGORIES); 12364 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { 12365 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); 12366 } 12367 out.endTag(null, TAG_CATEGORIES); 12368 } 12369 } 12370 12371 /** @hide */ restoreFromXml(XmlPullParser in)12372 public static Intent restoreFromXml(XmlPullParser in) throws IOException, 12373 XmlPullParserException { 12374 Intent intent = new Intent(); 12375 final int outerDepth = in.getDepth(); 12376 12377 int attrCount = in.getAttributeCount(); 12378 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 12379 final String attrName = in.getAttributeName(attrNdx); 12380 final String attrValue = in.getAttributeValue(attrNdx); 12381 if (ATTR_ACTION.equals(attrName)) { 12382 intent.setAction(attrValue); 12383 } else if (ATTR_DATA.equals(attrName)) { 12384 intent.setData(Uri.parse(attrValue)); 12385 } else if (ATTR_TYPE.equals(attrName)) { 12386 intent.setType(attrValue); 12387 } else if (ATTR_IDENTIFIER.equals(attrName)) { 12388 intent.setIdentifier(attrValue); 12389 } else if (ATTR_COMPONENT.equals(attrName)) { 12390 intent.setComponent(ComponentName.unflattenFromString(attrValue)); 12391 } else if (ATTR_FLAGS.equals(attrName)) { 12392 intent.setFlags(Integer.parseInt(attrValue, 16)); 12393 } else { 12394 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName); 12395 } 12396 } 12397 12398 int event; 12399 String name; 12400 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && 12401 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { 12402 if (event == XmlPullParser.START_TAG) { 12403 name = in.getName(); 12404 if (TAG_CATEGORIES.equals(name)) { 12405 attrCount = in.getAttributeCount(); 12406 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 12407 intent.addCategory(in.getAttributeValue(attrNdx)); 12408 } 12409 } else { 12410 Log.w(TAG, "restoreFromXml: unknown name=" + name); 12411 XmlUtils.skipCurrentTag(in); 12412 } 12413 } 12414 } 12415 12416 return intent; 12417 } 12418 12419 /** 12420 * Normalize a MIME data type. 12421 * 12422 * <p>A normalized MIME type has white-space trimmed, 12423 * content-type parameters removed, and is lower-case. 12424 * This aligns the type with Android best practices for 12425 * intent filtering. 12426 * 12427 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". 12428 * "text/x-vCard" becomes "text/x-vcard". 12429 * 12430 * <p>All MIME types received from outside Android (such as user input, 12431 * or external sources like Bluetooth, NFC, or the Internet) should 12432 * be normalized before they are used to create an Intent. 12433 * 12434 * @param type MIME data type to normalize 12435 * @return normalized MIME data type, or null if the input was null 12436 * @see #setType 12437 * @see #setTypeAndNormalize 12438 */ normalizeMimeType(@ullable String type)12439 public static @Nullable String normalizeMimeType(@Nullable String type) { 12440 if (type == null) { 12441 return null; 12442 } 12443 12444 type = type.trim().toLowerCase(Locale.ROOT); 12445 12446 final int semicolonIndex = type.indexOf(';'); 12447 if (semicolonIndex != -1) { 12448 type = type.substring(0, semicolonIndex); 12449 } 12450 return type; 12451 } 12452 12453 /** 12454 * Prepare this {@link Intent} to leave an app process. 12455 * 12456 * @hide 12457 */ 12458 @android.ravenwood.annotation.RavenwoodThrow 12459 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) prepareToLeaveProcess(Context context)12460 public void prepareToLeaveProcess(Context context) { 12461 final boolean leavingPackage; 12462 if (mComponent != null) { 12463 leavingPackage = !Objects.equals(mComponent.getPackageName(), context.getPackageName()); 12464 } else if (mPackage != null) { 12465 leavingPackage = !Objects.equals(mPackage, context.getPackageName()); 12466 } else { 12467 // When no specific component or package has been defined, we have 12468 // to assume that we might be routed through an intent 12469 // disambiguation dialog which might leave our package 12470 leavingPackage = true; 12471 } 12472 prepareToLeaveProcess(leavingPackage); 12473 } 12474 12475 /** 12476 * Prepare this {@link Intent} to leave an app process. 12477 * 12478 * @hide 12479 */ 12480 @android.ravenwood.annotation.RavenwoodThrow prepareToLeaveProcess(boolean leavingPackage)12481 public void prepareToLeaveProcess(boolean leavingPackage) { 12482 setAllowFds(false); 12483 12484 if (mSelector != null) { 12485 mSelector.prepareToLeaveProcess(leavingPackage); 12486 } 12487 if (mClipData != null) { 12488 mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); 12489 } 12490 if (mOriginalIntent != null) { 12491 mOriginalIntent.prepareToLeaveProcess(leavingPackage); 12492 } 12493 12494 if (mExtras != null && !mExtras.isParcelled()) { 12495 final Object intent = mExtras.get(Intent.EXTRA_INTENT); 12496 if (intent instanceof Intent) { 12497 ((Intent) intent).prepareToLeaveProcess(leavingPackage); 12498 } 12499 } 12500 12501 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() 12502 && leavingPackage) { 12503 switch (mAction) { 12504 case ACTION_MEDIA_REMOVED: 12505 case ACTION_MEDIA_UNMOUNTED: 12506 case ACTION_MEDIA_CHECKING: 12507 case ACTION_MEDIA_NOFS: 12508 case ACTION_MEDIA_MOUNTED: 12509 case ACTION_MEDIA_SHARED: 12510 case ACTION_MEDIA_UNSHARED: 12511 case ACTION_MEDIA_BAD_REMOVAL: 12512 case ACTION_MEDIA_UNMOUNTABLE: 12513 case ACTION_MEDIA_EJECT: 12514 case ACTION_MEDIA_SCANNER_STARTED: 12515 case ACTION_MEDIA_SCANNER_FINISHED: 12516 case ACTION_MEDIA_SCANNER_SCAN_FILE: 12517 case ACTION_PACKAGE_NEEDS_VERIFICATION: 12518 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION: 12519 case ACTION_PACKAGE_VERIFIED: 12520 case ACTION_PACKAGE_ENABLE_ROLLBACK: 12521 // Ignore legacy actions 12522 break; 12523 default: 12524 mData.checkFileUriExposed("Intent.getData()"); 12525 } 12526 } 12527 12528 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() 12529 && leavingPackage) { 12530 switch (mAction) { 12531 case ACTION_PROVIDER_CHANGED: 12532 case QuickContact.ACTION_QUICK_CONTACT: 12533 // Ignore actions that don't need to grant 12534 break; 12535 default: 12536 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); 12537 } 12538 } 12539 12540 // Translate raw filesystem paths out of storage sandbox 12541 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null 12542 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) { 12543 final StorageManager sm = AppGlobals.getInitialApplication() 12544 .getSystemService(StorageManager.class); 12545 final File before = new File(mData.getPath()); 12546 final File after = sm.translateAppToSystem(before, 12547 android.os.Process.myPid(), android.os.Process.myUid()); 12548 if (!Objects.equals(before, after)) { 12549 Log.v(TAG, "Translated " + before + " to " + after); 12550 mData = Uri.fromFile(after); 12551 } 12552 } 12553 12554 // Detect cases where we're about to launch a potentially unsafe intent 12555 if (StrictMode.vmUnsafeIntentLaunchEnabled()) { 12556 if ((mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 12557 && (mLocalFlags 12558 & (LOCAL_FLAG_FROM_PROTECTED_COMPONENT | LOCAL_FLAG_FROM_SYSTEM)) == 0) { 12559 StrictMode.onUnsafeIntentLaunch(this); 12560 } else if ((mLocalFlags & LOCAL_FLAG_UNFILTERED_EXTRAS) != 0) { 12561 StrictMode.onUnsafeIntentLaunch(this); 12562 } else if ((mLocalFlags & LOCAL_FLAG_FROM_URI) != 0 12563 && !(mCategories != null && mCategories.contains(CATEGORY_BROWSABLE) 12564 && mComponent == null)) { 12565 // Since the docs for #URI_ALLOW_UNSAFE recommend setting the category to browsable 12566 // for an implicit Intent parsed from a URI a violation should be reported if these 12567 // conditions are not met. 12568 StrictMode.onUnsafeIntentLaunch(this); 12569 } 12570 } 12571 } 12572 12573 /** 12574 * @hide 12575 */ 12576 @android.ravenwood.annotation.RavenwoodThrow prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source)12577 public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) { 12578 if (fromProtectedComponent) { 12579 prepareToEnterProcess(LOCAL_FLAG_FROM_PROTECTED_COMPONENT, source); 12580 } else { 12581 prepareToEnterProcess(0, source); 12582 } 12583 } 12584 12585 /** 12586 * @hide 12587 */ 12588 @android.ravenwood.annotation.RavenwoodThrow prepareToEnterProcess(int localFlags, AttributionSource source)12589 public void prepareToEnterProcess(int localFlags, AttributionSource source) { 12590 // We just entered destination process, so we should be able to read all 12591 // parcelables inside. 12592 setDefusable(true); 12593 12594 if (mSelector != null) { 12595 // We can't recursively claim that this data is from a protected 12596 // component, since it may have been filled in by a malicious app 12597 mSelector.prepareToEnterProcess(0, source); 12598 } 12599 if (mClipData != null) { 12600 mClipData.prepareToEnterProcess(source); 12601 } 12602 if (mOriginalIntent != null) { 12603 // We can't recursively claim that this data is from a protected 12604 // component, since it may have been filled in by a malicious app 12605 mOriginalIntent.prepareToEnterProcess(0, source); 12606 } 12607 12608 if (mContentUserHint != UserHandle.USER_CURRENT) { 12609 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { 12610 fixUris(mContentUserHint); 12611 mContentUserHint = UserHandle.USER_CURRENT; 12612 } 12613 } 12614 12615 mLocalFlags |= localFlags; 12616 12617 // Special attribution fix-up logic for any BluetoothDevice extras 12618 // passed via Bluetooth intents 12619 if (mAction != null && mAction.startsWith("android.bluetooth.") 12620 && hasExtra(BluetoothDevice.EXTRA_DEVICE)) { 12621 final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE, BluetoothDevice.class); 12622 if (device != null) { 12623 device.prepareToEnterProcess(source); 12624 } 12625 } 12626 } 12627 12628 /** @hide */ hasWebURI()12629 public boolean hasWebURI() { 12630 if (getData() == null) { 12631 return false; 12632 } 12633 final String scheme = getScheme(); 12634 if (TextUtils.isEmpty(scheme)) { 12635 return false; 12636 } 12637 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS); 12638 } 12639 12640 /** @hide */ isWebIntent()12641 public boolean isWebIntent() { 12642 return ACTION_VIEW.equals(mAction) 12643 && hasWebURI(); 12644 } 12645 isImageCaptureIntent()12646 private boolean isImageCaptureIntent() { 12647 return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction) 12648 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction) 12649 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction)); 12650 } 12651 12652 /** @hide */ isImplicitImageCaptureIntent()12653 public boolean isImplicitImageCaptureIntent() { 12654 return mPackage == null && mComponent == null && isImageCaptureIntent(); 12655 } 12656 12657 /** 12658 * Whether the intent mismatches all intent filters declared in the receiving component. 12659 * <p> 12660 * When a component receives an intent, normally obtainable through the following methods: 12661 * <ul> 12662 * <li> {@link BroadcastReceiver#onReceive(Context, Intent)} 12663 * <li> {@link Activity#getIntent()} 12664 * <li> {@link Activity#onNewIntent)} 12665 * <li> {@link android.app.Service#onStartCommand(Intent, int, int)} 12666 * <li> {@link android.app.Service#onBind(Intent)} 12667 * </ul> 12668 * The developer can call this method to check if this intent does not match any of its 12669 * declared intent filters. A non-matching intent can be delivered when the intent sender 12670 * explicitly set the component through {@link #setComponent} or {@link #setClassName}. 12671 * <p> 12672 * This method always returns {@code false} if the intent originated from within the same 12673 * application or the system, because these cases are always exempted from security checks. 12674 * 12675 * @return Returns true if the intent does not match any intent filters declared in the 12676 * receiving component. 12677 */ 12678 @FlaggedApi(android.security.Flags.FLAG_ENFORCE_INTENT_FILTER_MATCH) isMismatchingFilter()12679 public boolean isMismatchingFilter() { 12680 return (mExtendedFlags & EXTENDED_FLAG_FILTER_MISMATCH) != 0; 12681 } 12682 12683 /** 12684 * @hide 12685 */ 12686 @android.ravenwood.annotation.RavenwoodThrow fixUris(int contentUserHint)12687 public void fixUris(int contentUserHint) { 12688 Uri data = getData(); 12689 if (data != null) { 12690 mData = maybeAddUserId(data, contentUserHint); 12691 } 12692 if (mClipData != null) { 12693 mClipData.fixUris(contentUserHint); 12694 } 12695 String action = getAction(); 12696 if (ACTION_SEND.equals(action)) { 12697 final Uri stream = getParcelableExtra(EXTRA_STREAM, Uri.class); 12698 if (stream != null) { 12699 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); 12700 } 12701 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 12702 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM, Uri.class); 12703 if (streams != null) { 12704 ArrayList<Uri> newStreams = new ArrayList<Uri>(); 12705 for (int i = 0; i < streams.size(); i++) { 12706 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); 12707 } 12708 putParcelableArrayListExtra(EXTRA_STREAM, newStreams); 12709 } 12710 } else if (isImageCaptureIntent()) { 12711 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT, Uri.class); 12712 if (output != null) { 12713 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); 12714 } 12715 } 12716 } 12717 12718 /** 12719 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 12720 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 12721 * intents in {@link #ACTION_CHOOSER}. 12722 * 12723 * @return Whether any contents were migrated. 12724 * @hide 12725 */ 12726 @android.ravenwood.annotation.RavenwoodThrow migrateExtraStreamToClipData()12727 public boolean migrateExtraStreamToClipData() { 12728 return migrateExtraStreamToClipData(AppGlobals.getInitialApplication()); 12729 } 12730 12731 /** 12732 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 12733 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 12734 * intents in {@link #ACTION_CHOOSER}. 12735 * 12736 * @param context app context 12737 * @return Whether any contents were migrated. 12738 * @hide 12739 */ 12740 @android.ravenwood.annotation.RavenwoodThrow migrateExtraStreamToClipData(Context context)12741 public boolean migrateExtraStreamToClipData(Context context) { 12742 // Refuse to touch if extras already parcelled 12743 if (mExtras != null && mExtras.isParcelled()) return false; 12744 12745 // Bail when someone already gave us ClipData 12746 if (getClipData() != null) return false; 12747 12748 final String action = getAction(); 12749 if (ACTION_CHOOSER.equals(action)) { 12750 // Inspect contained intents to see if we need to migrate extras. We 12751 // don't promote ClipData to the parent, since ChooserActivity will 12752 // already start the picked item as the caller, and we can't combine 12753 // the flags in a safe way. 12754 12755 boolean migrated = false; 12756 try { 12757 final Intent intent = getParcelableExtra(EXTRA_INTENT, Intent.class); 12758 if (intent != null) { 12759 migrated |= intent.migrateExtraStreamToClipData(context); 12760 } 12761 } catch (ClassCastException e) { 12762 } 12763 try { 12764 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); 12765 if (intents != null) { 12766 for (int i = 0; i < intents.length; i++) { 12767 final Intent intent = (Intent) intents[i]; 12768 if (intent != null) { 12769 migrated |= intent.migrateExtraStreamToClipData(context); 12770 } 12771 } 12772 } 12773 } catch (ClassCastException e) { 12774 } 12775 return migrated; 12776 12777 } else if (ACTION_SEND.equals(action)) { 12778 try { 12779 final Uri stream = getParcelableExtra(EXTRA_STREAM, Uri.class); 12780 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); 12781 final String htmlText = getStringExtra(EXTRA_HTML_TEXT); 12782 if (stream != null || text != null || htmlText != null) { 12783 final ClipData clipData = new ClipData( 12784 null, new String[] { getType() }, 12785 new ClipData.Item(text, htmlText, null, stream)); 12786 setClipData(clipData); 12787 if (stream != null) { 12788 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 12789 } 12790 return true; 12791 } 12792 } catch (ClassCastException e) { 12793 } 12794 12795 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 12796 try { 12797 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM, Uri.class); 12798 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); 12799 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); 12800 int num = -1; 12801 if (streams != null) { 12802 num = streams.size(); 12803 } 12804 if (texts != null) { 12805 if (num >= 0 && num != texts.size()) { 12806 // Wha...! F- you. 12807 return false; 12808 } 12809 num = texts.size(); 12810 } 12811 if (htmlTexts != null) { 12812 if (num >= 0 && num != htmlTexts.size()) { 12813 // Wha...! F- you. 12814 return false; 12815 } 12816 num = htmlTexts.size(); 12817 } 12818 if (num > 0) { 12819 final ClipData clipData = new ClipData( 12820 null, new String[] { getType() }, 12821 makeClipItem(streams, texts, htmlTexts, 0)); 12822 12823 for (int i = 1; i < num; i++) { 12824 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); 12825 } 12826 12827 setClipData(clipData); 12828 if (streams != null) { 12829 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 12830 } 12831 return true; 12832 } 12833 } catch (ClassCastException e) { 12834 } 12835 } else if (isImageCaptureIntent()) { 12836 Uri output; 12837 try { 12838 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT, Uri.class); 12839 } catch (ClassCastException e) { 12840 return false; 12841 } 12842 12843 if (output != null) { 12844 output = maybeConvertFileToContentUri(context, output); 12845 putExtra(MediaStore.EXTRA_OUTPUT, output); 12846 12847 setClipData(ClipData.newRawUri("", output)); 12848 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); 12849 return true; 12850 } 12851 } 12852 12853 return false; 12854 } 12855 12856 @android.ravenwood.annotation.RavenwoodThrow maybeConvertFileToContentUri(Context context, Uri uri)12857 private Uri maybeConvertFileToContentUri(Context context, Uri uri) { 12858 if (ContentResolver.SCHEME_FILE.equals(uri.getScheme()) 12859 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) { 12860 File file = new File(uri.getPath()); 12861 try { 12862 if (!file.exists()) file.createNewFile(); 12863 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath())); 12864 if (uri != null) { 12865 return uri; 12866 } 12867 } catch (IOException e) { 12868 Log.e(TAG, "Ignoring failure to create file " + file, e); 12869 } 12870 } 12871 return uri; 12872 } 12873 12874 /** 12875 * Convert the dock state to a human readable format. 12876 * @hide 12877 */ dockStateToString(int dock)12878 public static String dockStateToString(int dock) { 12879 switch (dock) { 12880 case EXTRA_DOCK_STATE_HE_DESK: 12881 return "EXTRA_DOCK_STATE_HE_DESK"; 12882 case EXTRA_DOCK_STATE_LE_DESK: 12883 return "EXTRA_DOCK_STATE_LE_DESK"; 12884 case EXTRA_DOCK_STATE_CAR: 12885 return "EXTRA_DOCK_STATE_CAR"; 12886 case EXTRA_DOCK_STATE_DESK: 12887 return "EXTRA_DOCK_STATE_DESK"; 12888 case EXTRA_DOCK_STATE_UNDOCKED: 12889 return "EXTRA_DOCK_STATE_UNDOCKED"; 12890 default: 12891 return Integer.toString(dock); 12892 } 12893 } 12894 makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)12895 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, 12896 ArrayList<String> htmlTexts, int which) { 12897 Uri uri = streams != null ? streams.get(which) : null; 12898 CharSequence text = texts != null ? texts.get(which) : null; 12899 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; 12900 return new ClipData.Item(text, htmlText, null, uri); 12901 } 12902 12903 /** @hide */ isDocument()12904 public boolean isDocument() { 12905 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; 12906 } 12907 12908 /** 12909 * @deprecated Use {@link SdkSandboxActivityAuthority#isSdkSandboxActivityIntent} instead. 12910 * Once the other API is finalized this method will be removed. 12911 * 12912 * TODO(b/300059435): remove as part of the cleanup. 12913 * 12914 * @hide 12915 */ 12916 @Deprecated 12917 @android.ravenwood.annotation.RavenwoodThrow isSandboxActivity(@onNull Context context)12918 public boolean isSandboxActivity(@NonNull Context context) { 12919 if (mAction != null && mAction.equals(ACTION_START_SANDBOXED_ACTIVITY)) { 12920 return true; 12921 } 12922 final String sandboxPackageName = context.getPackageManager().getSdkSandboxPackageName(); 12923 if (mPackage != null && mPackage.equals(sandboxPackageName)) { 12924 return true; 12925 } 12926 if (mComponent != null && mComponent.getPackageName().equals(sandboxPackageName)) { 12927 return true; 12928 } 12929 return false; 12930 } 12931 } 12932