1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.content; 18 19 import static android.content.ContentProvider.maybeAddUserId; 20 21 import android.Manifest; 22 import android.accessibilityservice.AccessibilityService; 23 import android.annotation.AnyRes; 24 import android.annotation.BroadcastBehavior; 25 import android.annotation.IntDef; 26 import android.annotation.NonNull; 27 import android.annotation.Nullable; 28 import android.annotation.RequiresPermission; 29 import android.annotation.SdkConstant; 30 import android.annotation.SdkConstant.SdkConstantType; 31 import android.annotation.SuppressLint; 32 import android.annotation.SystemApi; 33 import android.annotation.TestApi; 34 import android.app.ActivityThread; 35 import android.app.AppGlobals; 36 import android.bluetooth.BluetoothDevice; 37 import android.compat.annotation.UnsupportedAppUsage; 38 import android.content.pm.ActivityInfo; 39 import android.content.pm.ApplicationInfo; 40 import android.content.pm.ComponentInfo; 41 import android.content.pm.PackageManager; 42 import android.content.pm.ResolveInfo; 43 import android.content.pm.ShortcutInfo; 44 import android.content.pm.SuspendDialogInfo; 45 import android.content.pm.verify.domain.DomainVerificationManager; 46 import android.content.res.Resources; 47 import android.content.res.TypedArray; 48 import android.graphics.Rect; 49 import android.net.Uri; 50 import android.os.Build; 51 import android.os.Bundle; 52 import android.os.IBinder; 53 import android.os.IncidentManager; 54 import android.os.Parcel; 55 import android.os.Parcelable; 56 import android.os.PersistableBundle; 57 import android.os.Process; 58 import android.os.ResultReceiver; 59 import android.os.ShellCommand; 60 import android.os.StrictMode; 61 import android.os.UserHandle; 62 import android.os.storage.StorageManager; 63 import android.provider.ContactsContract.QuickContact; 64 import android.provider.DocumentsContract; 65 import android.provider.DocumentsProvider; 66 import android.provider.MediaStore; 67 import android.provider.OpenableColumns; 68 import android.service.chooser.ChooserAction; 69 import android.telecom.PhoneAccount; 70 import android.telecom.TelecomManager; 71 import android.text.TextUtils; 72 import android.util.ArraySet; 73 import android.util.AttributeSet; 74 import android.util.Log; 75 import android.util.proto.ProtoOutputStream; 76 77 import com.android.internal.util.XmlUtils; 78 79 import org.xmlpull.v1.XmlPullParser; 80 import org.xmlpull.v1.XmlPullParserException; 81 import org.xmlpull.v1.XmlSerializer; 82 83 import java.io.File; 84 import java.io.IOException; 85 import java.io.PrintWriter; 86 import java.io.Serializable; 87 import java.lang.annotation.Retention; 88 import java.lang.annotation.RetentionPolicy; 89 import java.net.URISyntaxException; 90 import java.util.ArrayList; 91 import java.util.HashSet; 92 import java.util.List; 93 import java.util.Locale; 94 import java.util.Objects; 95 import java.util.Set; 96 import java.util.TimeZone; 97 98 /** 99 * An intent is an abstract description of an operation to be performed. It 100 * can be used with {@link Context#startActivity(Intent) startActivity} to 101 * launch an {@link android.app.Activity}, 102 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to 103 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components, 104 * and {@link android.content.Context#startService} or 105 * {@link android.content.Context#bindService} to communicate with a 106 * background {@link android.app.Service}. 107 * 108 * <p>An Intent provides a facility for performing late runtime binding between the code in 109 * different applications. Its most significant use is in the launching of activities, where it 110 * can be thought of as the glue between activities. It is basically a passive data structure 111 * holding an abstract description of an action to be performed.</p> 112 * 113 * <div class="special reference"> 114 * <h3>Developer Guides</h3> 115 * <p>For information about how to create and resolve intents, read the 116 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a> 117 * developer guide.</p> 118 * </div> 119 * 120 * <a name="IntentStructure"></a> 121 * <h3>Intent Structure</h3> 122 * <p>The primary pieces of information in an intent are:</p> 123 * 124 * <ul> 125 * <li> <p><b>action</b> -- The general action to be performed, such as 126 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN}, 127 * etc.</p> 128 * </li> 129 * <li> <p><b>data</b> -- The data to operate on, such as a person record 130 * in the contacts database, expressed as a {@link android.net.Uri}.</p> 131 * </li> 132 * </ul> 133 * 134 * 135 * <p>Some examples of action/data pairs are:</p> 136 * 137 * <ul> 138 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display 139 * information about the person whose identifier is "1".</p> 140 * </li> 141 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display 142 * the phone dialer with the person filled in.</p> 143 * </li> 144 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display 145 * the phone dialer with the given number filled in. Note how the 146 * VIEW action does what is considered the most reasonable thing for 147 * a particular URI.</p> 148 * </li> 149 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display 150 * the phone dialer with the given number filled in.</p> 151 * </li> 152 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit 153 * information about the person whose identifier is "1".</p> 154 * </li> 155 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display 156 * a list of people, which the user can browse through. This example is a 157 * typical top-level entry into the Contacts application, showing you the 158 * list of people. Selecting a particular person to view would result in a 159 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> } 160 * being used to start an activity to display that person.</p> 161 * </li> 162 * </ul> 163 * 164 * <p>In addition to these primary attributes, there are a number of secondary 165 * attributes that you can also include with an intent:</p> 166 * 167 * <ul> 168 * <li> <p><b>category</b> -- Gives additional information about the action 169 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should 170 * appear in the Launcher as a top-level application, while 171 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list 172 * of alternative actions the user can perform on a piece of data.</p> 173 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the 174 * intent data. Normally the type is inferred from the data itself. 175 * By setting this attribute, you disable that evaluation and force 176 * an explicit type.</p> 177 * <li> <p><b>component</b> -- Specifies an explicit name of a component 178 * class to use for the intent. Normally this is determined by looking 179 * at the other information in the intent (the action, data/type, and 180 * categories) and matching that with a component that can handle it. 181 * If this attribute is set then none of the evaluation is performed, 182 * and this component is used exactly as is. By specifying this attribute, 183 * all of the other Intent attributes become optional.</p> 184 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information. 185 * This can be used to provide extended information to the component. 186 * For example, if we have a action to send an e-mail message, we could 187 * also include extra pieces of data here to supply a subject, body, 188 * etc.</p> 189 * </ul> 190 * 191 * <p>Here are some examples of other operations you can specify as intents 192 * using these additional parameters:</p> 193 * 194 * <ul> 195 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> -- 196 * Launch the home screen.</p> 197 * </li> 198 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 199 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI 200 * vnd.android.cursor.item/phone}</i></b> 201 * -- Display the list of people's phone numbers, allowing the user to 202 * browse through them and pick one and return it to the parent activity.</p> 203 * </li> 204 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type 205 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b> 206 * -- Display all pickers for data that can be opened with 207 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()}, 208 * allowing the user to pick one of them and then some data inside of it 209 * and returning the resulting URI to the caller. This can be used, 210 * for example, in an e-mail application to allow the user to pick some 211 * data to include as an attachment.</p> 212 * </li> 213 * </ul> 214 * 215 * <p>There are a variety of standard Intent action and category constants 216 * defined in the Intent class, but applications can also define their own. 217 * These strings use Java-style scoping, to ensure they are unique -- for 218 * example, the standard {@link #ACTION_VIEW} is called 219 * "android.intent.action.VIEW".</p> 220 * 221 * <p>Put together, the set of actions, data types, categories, and extra data 222 * defines a language for the system allowing for the expression of phrases 223 * such as "call john smith's cell". As applications are added to the system, 224 * they can extend this language by adding new actions, types, and categories, or 225 * they can modify the behavior of existing phrases by supplying their own 226 * activities that handle them.</p> 227 * 228 * <a name="IntentResolution"></a> 229 * <h3>Intent Resolution</h3> 230 * 231 * <p>There are two primary forms of intents you will use. 232 * 233 * <ul> 234 * <li> <p><b>Explicit Intents</b> have specified a component (via 235 * {@link #setComponent} or {@link #setClass}), which provides the exact 236 * class to be run. Often these will not include any other information, 237 * simply being a way for an application to launch various internal 238 * activities it has as the user interacts with the application. 239 * 240 * <li> <p><b>Implicit Intents</b> have not specified a component; 241 * instead, they must include enough information for the system to 242 * determine which of the available components is best to run for that 243 * intent. 244 * </ul> 245 * 246 * <p>When using implicit intents, given such an arbitrary intent we need to 247 * know what to do with it. This is handled by the process of <em>Intent 248 * resolution</em>, which maps an Intent to an {@link android.app.Activity}, 249 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or 250 * more activities/receivers) that can handle it.</p> 251 * 252 * <p>The intent resolution mechanism basically revolves around matching an 253 * Intent against all of the <intent-filter> descriptions in the 254 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver} 255 * objects explicitly registered with {@link Context#registerReceiver}.) More 256 * details on this can be found in the documentation on the {@link 257 * IntentFilter} class.</p> 258 * 259 * <p>There are three pieces of information in the Intent that are used for 260 * resolution: the action, type, and category. Using this information, a query 261 * is done on the {@link PackageManager} for a component that can handle the 262 * intent. The appropriate component is determined based on the intent 263 * information supplied in the <code>AndroidManifest.xml</code> file as 264 * follows:</p> 265 * 266 * <ul> 267 * <li> <p>The <b>action</b>, if given, must be listed by the component as 268 * one it handles.</p> 269 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not 270 * already supplied in the Intent. Like the action, if a type is 271 * included in the intent (either explicitly or implicitly in its 272 * data), then this must be listed by the component as one it handles.</p> 273 * <li> For data that is not a <code>content:</code> URI and where no explicit 274 * type is included in the Intent, instead the <b>scheme</b> of the 275 * intent data (such as <code>http:</code> or <code>mailto:</code>) is 276 * considered. Again like the action, if we are matching a scheme it 277 * must be listed by the component as one it can handle. 278 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed 279 * by the activity as categories it handles. That is, if you include 280 * the categories {@link #CATEGORY_LAUNCHER} and 281 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components 282 * with an intent that lists <em>both</em> of those categories. 283 * Activities will very often need to support the 284 * {@link #CATEGORY_DEFAULT} so that they can be found by 285 * {@link Context#startActivity Context.startActivity()}.</p> 286 * </ul> 287 * 288 * <p>For example, consider the Note Pad sample application that 289 * allows a user to browse through a list of notes data and view details about 290 * individual items. Text in italics indicates places where you would replace a 291 * name with one specific to your own package.</p> 292 * 293 * <pre> <manifest xmlns:android="http://schemas.android.com/apk/res/android" 294 * package="<i>com.android.notepad</i>"> 295 * <application android:icon="@drawable/app_notes" 296 * android:label="@string/app_name"> 297 * 298 * <provider class=".NotePadProvider" 299 * android:authorities="<i>com.google.provider.NotePad</i>" /> 300 * 301 * <activity class=".NotesList" android:label="@string/title_notes_list"> 302 * <intent-filter> 303 * <action android:name="android.intent.action.MAIN" /> 304 * <category android:name="android.intent.category.LAUNCHER" /> 305 * </intent-filter> 306 * <intent-filter> 307 * <action android:name="android.intent.action.VIEW" /> 308 * <action android:name="android.intent.action.EDIT" /> 309 * <action android:name="android.intent.action.PICK" /> 310 * <category android:name="android.intent.category.DEFAULT" /> 311 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 312 * </intent-filter> 313 * <intent-filter> 314 * <action android:name="android.intent.action.GET_CONTENT" /> 315 * <category android:name="android.intent.category.DEFAULT" /> 316 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 317 * </intent-filter> 318 * </activity> 319 * 320 * <activity class=".NoteEditor" android:label="@string/title_note"> 321 * <intent-filter android:label="@string/resolve_edit"> 322 * <action android:name="android.intent.action.VIEW" /> 323 * <action android:name="android.intent.action.EDIT" /> 324 * <category android:name="android.intent.category.DEFAULT" /> 325 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 326 * </intent-filter> 327 * 328 * <intent-filter> 329 * <action android:name="android.intent.action.INSERT" /> 330 * <category android:name="android.intent.category.DEFAULT" /> 331 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 332 * </intent-filter> 333 * 334 * </activity> 335 * 336 * <activity class=".TitleEditor" android:label="@string/title_edit_title" 337 * android:theme="@android:style/Theme.Dialog"> 338 * <intent-filter android:label="@string/resolve_title"> 339 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 340 * <category android:name="android.intent.category.DEFAULT" /> 341 * <category android:name="android.intent.category.ALTERNATIVE" /> 342 * <category android:name="android.intent.category.SELECTED_ALTERNATIVE" /> 343 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 344 * </intent-filter> 345 * </activity> 346 * 347 * </application> 348 * </manifest></pre> 349 * 350 * <p>The first activity, 351 * <code>com.android.notepad.NotesList</code>, serves as our main 352 * entry into the app. It can do three things as described by its three intent 353 * templates: 354 * <ol> 355 * <li><pre> 356 * <intent-filter> 357 * <action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /> 358 * <category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /> 359 * </intent-filter></pre> 360 * <p>This provides a top-level entry into the NotePad application: the standard 361 * MAIN action is a main entry point (not requiring any other information in 362 * the Intent), and the LAUNCHER category says that this entry point should be 363 * listed in the application launcher.</p> 364 * <li><pre> 365 * <intent-filter> 366 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 367 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 368 * <action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /> 369 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 370 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 371 * </intent-filter></pre> 372 * <p>This declares the things that the activity can do on a directory of 373 * notes. The type being supported is given with the <type> tag, where 374 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which 375 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can 376 * be retrieved which holds our note pad data (<code>vnd.google.note</code>). 377 * The activity allows the user to view or edit the directory of data (via 378 * the VIEW and EDIT actions), or to pick a particular note and return it 379 * to the caller (via the PICK action). Note also the DEFAULT category 380 * supplied here: this is <em>required</em> for the 381 * {@link Context#startActivity Context.startActivity} method to resolve your 382 * activity when its component name is not explicitly specified.</p> 383 * <li><pre> 384 * <intent-filter> 385 * <action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /> 386 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 387 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 388 * </intent-filter></pre> 389 * <p>This filter describes the ability to return to the caller a note selected by 390 * the user without needing to know where it came from. The data type 391 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which 392 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can 393 * be retrieved which contains our note pad data (<code>vnd.google.note</code>). 394 * The GET_CONTENT action is similar to the PICK action, where the activity 395 * will return to its caller a piece of data selected by the user. Here, 396 * however, the caller specifies the type of data they desire instead of 397 * the type of data the user will be picking from.</p> 398 * </ol> 399 * 400 * <p>Given these capabilities, the following intents will resolve to the 401 * NotesList activity:</p> 402 * 403 * <ul> 404 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the 405 * activities that can be used as top-level entry points into an 406 * application.</p> 407 * <li> <p><b>{ action=android.app.action.MAIN, 408 * category=android.app.category.LAUNCHER }</b> is the actual intent 409 * used by the Launcher to populate its top-level list.</p> 410 * <li> <p><b>{ action=android.intent.action.VIEW 411 * data=content://com.google.provider.NotePad/notes }</b> 412 * displays a list of all the notes under 413 * "content://com.google.provider.NotePad/notes", which 414 * the user can browse through and see the details on.</p> 415 * <li> <p><b>{ action=android.app.action.PICK 416 * data=content://com.google.provider.NotePad/notes }</b> 417 * provides a list of the notes under 418 * "content://com.google.provider.NotePad/notes", from which 419 * the user can pick a note whose data URL is returned back to the caller.</p> 420 * <li> <p><b>{ action=android.app.action.GET_CONTENT 421 * type=vnd.android.cursor.item/vnd.google.note }</b> 422 * is similar to the pick action, but allows the caller to specify the 423 * kind of data they want back so that the system can find the appropriate 424 * activity to pick something of that data type.</p> 425 * </ul> 426 * 427 * <p>The second activity, 428 * <code>com.android.notepad.NoteEditor</code>, shows the user a single 429 * note entry and allows them to edit it. It can do two things as described 430 * by its two intent templates: 431 * <ol> 432 * <li><pre> 433 * <intent-filter android:label="@string/resolve_edit"> 434 * <action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /> 435 * <action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /> 436 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 437 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 438 * </intent-filter></pre> 439 * <p>The first, primary, purpose of this activity is to let the user interact 440 * with a single note, as decribed by the MIME type 441 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can 442 * either VIEW a note or allow the user to EDIT it. Again we support the 443 * DEFAULT category to allow the activity to be launched without explicitly 444 * specifying its component.</p> 445 * <li><pre> 446 * <intent-filter> 447 * <action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /> 448 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 449 * <data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /> 450 * </intent-filter></pre> 451 * <p>The secondary use of this activity is to insert a new note entry into 452 * an existing directory of notes. This is used when the user creates a new 453 * note: the INSERT action is executed on the directory of notes, causing 454 * this activity to run and have the user create the new note data which 455 * it then adds to the content provider.</p> 456 * </ol> 457 * 458 * <p>Given these capabilities, the following intents will resolve to the 459 * NoteEditor activity:</p> 460 * 461 * <ul> 462 * <li> <p><b>{ action=android.intent.action.VIEW 463 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 464 * shows the user the content of note <var>{ID}</var>.</p> 465 * <li> <p><b>{ action=android.app.action.EDIT 466 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 467 * allows the user to edit the content of note <var>{ID}</var>.</p> 468 * <li> <p><b>{ action=android.app.action.INSERT 469 * data=content://com.google.provider.NotePad/notes }</b> 470 * creates a new, empty note in the notes list at 471 * "content://com.google.provider.NotePad/notes" 472 * and allows the user to edit it. If they keep their changes, the URI 473 * of the newly created note is returned to the caller.</p> 474 * </ul> 475 * 476 * <p>The last activity, 477 * <code>com.android.notepad.TitleEditor</code>, allows the user to 478 * edit the title of a note. This could be implemented as a class that the 479 * application directly invokes (by explicitly setting its component in 480 * the Intent), but here we show a way you can publish alternative 481 * operations on existing data:</p> 482 * 483 * <pre> 484 * <intent-filter android:label="@string/resolve_title"> 485 * <action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /> 486 * <category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /> 487 * <category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /> 488 * <category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /> 489 * <data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /> 490 * </intent-filter></pre> 491 * 492 * <p>In the single intent template here, we 493 * have created our own private action called 494 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to 495 * edit the title of a note. It must be invoked on a specific note 496 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous 497 * view and edit actions, but here displays and edits the title contained 498 * in the note data. 499 * 500 * <p>In addition to supporting the default category as usual, our title editor 501 * also supports two other standard categories: ALTERNATIVE and 502 * SELECTED_ALTERNATIVE. Implementing 503 * these categories allows others to find the special action it provides 504 * without directly knowing about it, through the 505 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or 506 * more often to build dynamic menu items with 507 * {@link android.view.Menu#addIntentOptions}. Note that in the intent 508 * template here was also supply an explicit name for the template 509 * (via <code>android:label="@string/resolve_title"</code>) to better control 510 * what the user sees when presented with this activity as an alternative 511 * action to the data they are viewing. 512 * 513 * <p>Given these capabilities, the following intent will resolve to the 514 * TitleEditor activity:</p> 515 * 516 * <ul> 517 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE 518 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b> 519 * displays and allows the user to edit the title associated 520 * with note <var>{ID}</var>.</p> 521 * </ul> 522 * 523 * <h3>Standard Activity Actions</h3> 524 * 525 * <p>These are the current standard actions that Intent defines for launching 526 * activities (usually through {@link Context#startActivity}. The most 527 * important, and by far most frequently used, are {@link #ACTION_MAIN} and 528 * {@link #ACTION_EDIT}. 529 * 530 * <ul> 531 * <li> {@link #ACTION_MAIN} 532 * <li> {@link #ACTION_VIEW} 533 * <li> {@link #ACTION_ATTACH_DATA} 534 * <li> {@link #ACTION_EDIT} 535 * <li> {@link #ACTION_PICK} 536 * <li> {@link #ACTION_CHOOSER} 537 * <li> {@link #ACTION_GET_CONTENT} 538 * <li> {@link #ACTION_DIAL} 539 * <li> {@link #ACTION_CALL} 540 * <li> {@link #ACTION_SEND} 541 * <li> {@link #ACTION_SENDTO} 542 * <li> {@link #ACTION_ANSWER} 543 * <li> {@link #ACTION_INSERT} 544 * <li> {@link #ACTION_DELETE} 545 * <li> {@link #ACTION_RUN} 546 * <li> {@link #ACTION_SYNC} 547 * <li> {@link #ACTION_PICK_ACTIVITY} 548 * <li> {@link #ACTION_SEARCH} 549 * <li> {@link #ACTION_WEB_SEARCH} 550 * <li> {@link #ACTION_FACTORY_TEST} 551 * </ul> 552 * 553 * <h3>Standard Broadcast Actions</h3> 554 * 555 * <p>These are the current standard actions that Intent defines for receiving 556 * broadcasts (usually through {@link Context#registerReceiver} or a 557 * <receiver> tag in a manifest). 558 * 559 * <ul> 560 * <li> {@link #ACTION_TIME_TICK} 561 * <li> {@link #ACTION_TIME_CHANGED} 562 * <li> {@link #ACTION_TIMEZONE_CHANGED} 563 * <li> {@link #ACTION_BOOT_COMPLETED} 564 * <li> {@link #ACTION_PACKAGE_ADDED} 565 * <li> {@link #ACTION_PACKAGE_CHANGED} 566 * <li> {@link #ACTION_PACKAGE_REMOVED} 567 * <li> {@link #ACTION_PACKAGE_RESTARTED} 568 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED} 569 * <li> {@link #ACTION_PACKAGES_SUSPENDED} 570 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED} 571 * <li> {@link #ACTION_UID_REMOVED} 572 * <li> {@link #ACTION_BATTERY_CHANGED} 573 * <li> {@link #ACTION_POWER_CONNECTED} 574 * <li> {@link #ACTION_POWER_DISCONNECTED} 575 * <li> {@link #ACTION_SHUTDOWN} 576 * </ul> 577 * 578 * <h3>Standard Categories</h3> 579 * 580 * <p>These are the current standard categories that can be used to further 581 * clarify an Intent via {@link #addCategory}. 582 * 583 * <ul> 584 * <li> {@link #CATEGORY_DEFAULT} 585 * <li> {@link #CATEGORY_BROWSABLE} 586 * <li> {@link #CATEGORY_TAB} 587 * <li> {@link #CATEGORY_ALTERNATIVE} 588 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE} 589 * <li> {@link #CATEGORY_LAUNCHER} 590 * <li> {@link #CATEGORY_INFO} 591 * <li> {@link #CATEGORY_HOME} 592 * <li> {@link #CATEGORY_PREFERENCE} 593 * <li> {@link #CATEGORY_TEST} 594 * <li> {@link #CATEGORY_CAR_DOCK} 595 * <li> {@link #CATEGORY_DESK_DOCK} 596 * <li> {@link #CATEGORY_LE_DESK_DOCK} 597 * <li> {@link #CATEGORY_HE_DESK_DOCK} 598 * <li> {@link #CATEGORY_CAR_MODE} 599 * <li> {@link #CATEGORY_APP_MARKET} 600 * <li> {@link #CATEGORY_VR_HOME} 601 * </ul> 602 * 603 * <h3>Standard Extra Data</h3> 604 * 605 * <p>These are the current standard fields that can be used as extra data via 606 * {@link #putExtra}. 607 * 608 * <ul> 609 * <li> {@link #EXTRA_ALARM_COUNT} 610 * <li> {@link #EXTRA_BCC} 611 * <li> {@link #EXTRA_CC} 612 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME} 613 * <li> {@link #EXTRA_DATA_REMOVED} 614 * <li> {@link #EXTRA_DOCK_STATE} 615 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK} 616 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK} 617 * <li> {@link #EXTRA_DOCK_STATE_CAR} 618 * <li> {@link #EXTRA_DOCK_STATE_DESK} 619 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED} 620 * <li> {@link #EXTRA_DONT_KILL_APP} 621 * <li> {@link #EXTRA_EMAIL} 622 * <li> {@link #EXTRA_INITIAL_INTENTS} 623 * <li> {@link #EXTRA_INTENT} 624 * <li> {@link #EXTRA_KEY_EVENT} 625 * <li> {@link #EXTRA_ORIGINATING_URI} 626 * <li> {@link #EXTRA_PHONE_NUMBER} 627 * <li> {@link #EXTRA_REFERRER} 628 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN} 629 * <li> {@link #EXTRA_REPLACING} 630 * <li> {@link #EXTRA_SHORTCUT_ICON} 631 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE} 632 * <li> {@link #EXTRA_SHORTCUT_INTENT} 633 * <li> {@link #EXTRA_STREAM} 634 * <li> {@link #EXTRA_SHORTCUT_NAME} 635 * <li> {@link #EXTRA_SUBJECT} 636 * <li> {@link #EXTRA_TEMPLATE} 637 * <li> {@link #EXTRA_TEXT} 638 * <li> {@link #EXTRA_TITLE} 639 * <li> {@link #EXTRA_UID} 640 * <li> {@link #EXTRA_USER_INITIATED} 641 * </ul> 642 * 643 * <h3>Flags</h3> 644 * 645 * <p>These are the possible flags that can be used in the Intent via 646 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list 647 * of all possible flags. 648 */ 649 public class Intent implements Parcelable, Cloneable { 650 private static final String TAG = "Intent"; 651 652 private static final String ATTR_ACTION = "action"; 653 private static final String TAG_CATEGORIES = "categories"; 654 private static final String ATTR_CATEGORY = "category"; 655 private static final String TAG_EXTRA = "extra"; 656 private static final String ATTR_TYPE = "type"; 657 private static final String ATTR_IDENTIFIER = "ident"; 658 private static final String ATTR_COMPONENT = "component"; 659 private static final String ATTR_DATA = "data"; 660 private static final String ATTR_FLAGS = "flags"; 661 662 // --------------------------------------------------------------------- 663 // --------------------------------------------------------------------- 664 // Standard intent activity actions (see action variable). 665 666 /** 667 * Activity Action: Start as a main entry point, does not expect to 668 * receive data. 669 * <p>Input: nothing 670 * <p>Output: nothing 671 */ 672 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 673 public static final String ACTION_MAIN = "android.intent.action.MAIN"; 674 675 /** 676 * Activity Action: Display the data to the user. This is the most common 677 * action performed on data -- it is the generic action you can use on 678 * a piece of data to get the most reasonable thing to occur. For example, 679 * when used on a contacts entry it will view the entry; when used on a 680 * mailto: URI it will bring up a compose window filled with the information 681 * supplied by the URI; when used with a tel: URI it will invoke the 682 * dialer. 683 * <p>Input: {@link #getData} is URI from which to retrieve data. 684 * <p>Output: nothing. 685 */ 686 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 687 public static final String ACTION_VIEW = "android.intent.action.VIEW"; 688 689 /** 690 * Extra that can be included on activity intents coming from the storage UI 691 * when it launches sub-activities to manage various types of storage. For example, 692 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show 693 * the images on the device, and in that case also include this extra to tell the 694 * app it is coming from the storage UI so should help the user manage storage of 695 * this type. 696 */ 697 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE"; 698 699 /** 700 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is 701 * performed on a piece of data. 702 */ 703 public static final String ACTION_DEFAULT = ACTION_VIEW; 704 705 /** 706 * Activity Action: Quick view the data. Launches a quick viewer for 707 * a URI or a list of URIs. 708 * <p>Activities handling this intent action should handle the vast majority of 709 * MIME types rather than only specific ones. 710 * <p>Quick viewers must render the quick view image locally, and must not send 711 * file content outside current device. 712 * <p>Input: {@link #getData} is a mandatory content URI of the item to 713 * preview. {@link #getClipData} contains an optional list of content URIs 714 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an 715 * optional index of the URI in the clip data to show first. 716 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features 717 * that can be shown in the quick view UI. 718 * <p>Output: nothing. 719 * @see #EXTRA_INDEX 720 * @see #EXTRA_QUICK_VIEW_FEATURES 721 */ 722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 723 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW"; 724 725 /** 726 * Used to indicate that some piece of data should be attached to some other 727 * place. For example, image data could be attached to a contact. It is up 728 * to the recipient to decide where the data should be attached; the intent 729 * does not specify the ultimate destination. 730 * <p>Input: {@link #getData} is URI of data to be attached. 731 * <p>Output: nothing. 732 */ 733 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 734 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA"; 735 736 /** 737 * Activity Action: Provide explicit editable access to the given data. 738 * <p>Input: {@link #getData} is URI of data to be edited. 739 * <p>Output: nothing. 740 */ 741 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 742 public static final String ACTION_EDIT = "android.intent.action.EDIT"; 743 744 /** 745 * Activity Action: Pick an existing item, or insert a new item, and then edit it. 746 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit. 747 * The extras can contain type specific data to pass through to the editing/creating 748 * activity. 749 * <p>Output: The URI of the item that was picked. This must be a content: 750 * URI so that any receiver can access it. 751 */ 752 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 753 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT"; 754 755 /** 756 * Activity Action: Pick an item from the data, returning what was selected. 757 * <p>Input: {@link #getData} is URI containing a directory of data 758 * (vnd.android.cursor.dir/*) from which to pick an item. 759 * <p>Output: The URI of the item that was picked. 760 */ 761 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 762 public static final String ACTION_PICK = "android.intent.action.PICK"; 763 764 /** 765 * Activity Action: Creates a reminder. 766 * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user. 767 * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at 768 * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will 769 * be shown to the user. The time is specified in milliseconds since the Epoch (optional). 770 * </p> 771 * <p>Output: Nothing.</p> 772 * 773 * @see #EXTRA_TITLE 774 * @see #EXTRA_TEXT 775 * @see #EXTRA_TIME 776 */ 777 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 778 public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER"; 779 780 /** 781 * Activity Action: Creates a shortcut. 782 * <p>Input: Nothing.</p> 783 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p> 784 * <p>For compatibility with older versions of android the intent may also contain three 785 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String), 786 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE 787 * (value: ShortcutIconResource).</p> 788 * 789 * @see android.content.pm.ShortcutManager#createShortcutResultIntent 790 * @see #EXTRA_SHORTCUT_INTENT 791 * @see #EXTRA_SHORTCUT_NAME 792 * @see #EXTRA_SHORTCUT_ICON 793 * @see #EXTRA_SHORTCUT_ICON_RESOURCE 794 * @see android.content.Intent.ShortcutIconResource 795 */ 796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 797 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT"; 798 799 /** 800 * The name of the extra used to define the Intent of a shortcut. 801 * 802 * @see #ACTION_CREATE_SHORTCUT 803 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 804 */ 805 @Deprecated 806 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT"; 807 /** 808 * The name of the extra used to define the name of a shortcut. 809 * 810 * @see #ACTION_CREATE_SHORTCUT 811 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 812 */ 813 @Deprecated 814 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME"; 815 /** 816 * The name of the extra used to define the icon, as a Bitmap, of a shortcut. 817 * 818 * @see #ACTION_CREATE_SHORTCUT 819 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 820 */ 821 @Deprecated 822 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON"; 823 /** 824 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut. 825 * 826 * @see #ACTION_CREATE_SHORTCUT 827 * @see android.content.Intent.ShortcutIconResource 828 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent} 829 */ 830 @Deprecated 831 public static final String EXTRA_SHORTCUT_ICON_RESOURCE = 832 "android.intent.extra.shortcut.ICON_RESOURCE"; 833 834 /** 835 * An activity that provides a user interface for adjusting application preferences. 836 * Optional but recommended settings for all applications which have settings. 837 */ 838 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 839 public static final String ACTION_APPLICATION_PREFERENCES 840 = "android.intent.action.APPLICATION_PREFERENCES"; 841 842 /** 843 * Activity Action: Launch an activity showing the app information. 844 * For applications which install other applications (such as app stores), it is recommended 845 * to handle this action for providing the app information to the user. 846 * 847 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs 848 * to be displayed. 849 * <p>Output: Nothing. 850 */ 851 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 852 public static final String ACTION_SHOW_APP_INFO 853 = "android.intent.action.SHOW_APP_INFO"; 854 855 /** 856 * Activity Action: Placeholder that the component handling it can do activity 857 * recognition. Can be placed on a service. Only one service per package is 858 * supported. 859 * 860 * <p>Input: Nothing.</p> 861 * <p>Output: Nothing </p> 862 * 863 * @hide 864 */ 865 @SystemApi 866 @SdkConstant(SdkConstantType.SERVICE_ACTION) 867 public static final String ACTION_ACTIVITY_RECOGNIZER = 868 "android.intent.action.ACTIVITY_RECOGNIZER"; 869 870 /** 871 * Represents a shortcut/live folder icon resource. 872 * 873 * @see Intent#ACTION_CREATE_SHORTCUT 874 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE 875 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER 876 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON 877 */ 878 public static class ShortcutIconResource implements Parcelable { 879 /** 880 * The package name of the application containing the icon. 881 */ 882 public String packageName; 883 884 /** 885 * The resource name of the icon, including package, name and type. 886 */ 887 public String resourceName; 888 889 /** 890 * Creates a new ShortcutIconResource for the specified context and resource 891 * identifier. 892 * 893 * @param context The context of the application. 894 * @param resourceId The resource identifier for the icon. 895 * @return A new ShortcutIconResource with the specified's context package name 896 * and icon resource identifier.`` 897 */ fromContext(Context context, @AnyRes int resourceId)898 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) { 899 ShortcutIconResource icon = new ShortcutIconResource(); 900 icon.packageName = context.getPackageName(); 901 icon.resourceName = context.getResources().getResourceName(resourceId); 902 return icon; 903 } 904 905 /** 906 * Used to read a ShortcutIconResource from a Parcel. 907 */ 908 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR = 909 new Parcelable.Creator<ShortcutIconResource>() { 910 911 public ShortcutIconResource createFromParcel(Parcel source) { 912 ShortcutIconResource icon = new ShortcutIconResource(); 913 icon.packageName = source.readString8(); 914 icon.resourceName = source.readString8(); 915 return icon; 916 } 917 918 public ShortcutIconResource[] newArray(int size) { 919 return new ShortcutIconResource[size]; 920 } 921 }; 922 923 /** 924 * No special parcel contents. 925 */ describeContents()926 public int describeContents() { 927 return 0; 928 } 929 writeToParcel(Parcel dest, int flags)930 public void writeToParcel(Parcel dest, int flags) { 931 dest.writeString8(packageName); 932 dest.writeString8(resourceName); 933 } 934 935 @Override toString()936 public String toString() { 937 return resourceName; 938 } 939 } 940 941 /** 942 * Activity Action: Display an activity chooser, allowing the user to pick 943 * what they want to before proceeding. This can be used as an alternative 944 * to the standard activity picker that is displayed by the system when 945 * you try to start an activity with multiple possible matches, with these 946 * differences in behavior: 947 * <ul> 948 * <li>You can specify the title that will appear in the activity chooser. 949 * <li>The user does not have the option to make one of the matching 950 * activities a preferred activity, and all possible activities will 951 * always be shown even if one of them is currently marked as the 952 * preferred activity. 953 * </ul> 954 * <p> 955 * This action should be used when the user will naturally expect to 956 * select an activity in order to proceed. An example if when not to use 957 * it is when the user clicks on a "mailto:" link. They would naturally 958 * expect to go directly to their mail app, so startActivity() should be 959 * called directly: it will 960 * either launch the current preferred app, or put up a dialog allowing the 961 * user to pick an app to use and optionally marking that as preferred. 962 * <p> 963 * In contrast, if the user is selecting a menu item to send a picture 964 * they are viewing to someone else, there are many different things they 965 * may want to do at this point: send it through e-mail, upload it to a 966 * web service, etc. In this case the CHOOSER action should be used, to 967 * always present to the user a list of the things they can do, with a 968 * nice title given by the caller such as "Send this photo with:". 969 * <p> 970 * If you need to grant URI permissions through a chooser, you must specify 971 * the permissions to be granted on the ACTION_CHOOSER Intent 972 * <em>in addition</em> to the EXTRA_INTENT inside. This means using 973 * {@link #setClipData} to specify the URIs to be granted as well as 974 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 975 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate. 976 * <p> 977 * As a convenience, an Intent of this form can be created with the 978 * {@link #createChooser} function. 979 * <p> 980 * Input: No data should be specified. get*Extra must have 981 * a {@link #EXTRA_INTENT} field containing the Intent being executed, 982 * and can optionally have a {@link #EXTRA_TITLE} field containing the 983 * title text to display in the chooser. 984 * <p> 985 * Output: Depends on the protocol of {@link #EXTRA_INTENT}. 986 */ 987 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 988 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER"; 989 990 /** 991 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 992 * 993 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 994 * target intent, also optionally supplying a title. If the target 995 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 996 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 997 * set in the returned chooser intent, with its ClipData set appropriately: 998 * either a direct reflection of {@link #getClipData()} if that is non-null, 999 * or a new ClipData built from {@link #getData()}. 1000 * 1001 * @param target The Intent that the user will be selecting an activity 1002 * to perform. 1003 * @param title Optional title that will be displayed in the chooser, 1004 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1005 * @return Return a new Intent object that you can hand to 1006 * {@link Context#startActivity(Intent) Context.startActivity()} and 1007 * related methods. 1008 */ createChooser(Intent target, CharSequence title)1009 public static Intent createChooser(Intent target, CharSequence title) { 1010 return createChooser(target, title, null); 1011 } 1012 1013 /** 1014 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent. 1015 * 1016 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given 1017 * target intent, also optionally supplying a title. If the target 1018 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or 1019 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be 1020 * set in the returned chooser intent, with its ClipData set appropriately: 1021 * either a direct reflection of {@link #getClipData()} if that is non-null, 1022 * or a new ClipData built from {@link #getData()}.</p> 1023 * 1024 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback 1025 * when the user makes a choice. This can be useful if the calling application wants 1026 * to remember the last chosen target and surface it as a more prominent or one-touch 1027 * affordance elsewhere in the UI for next time.</p> 1028 * 1029 * @param target The Intent that the user will be selecting an activity 1030 * to perform. 1031 * @param title Optional title that will be displayed in the chooser, 1032 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE. 1033 * @param sender Optional IntentSender to be called when a choice is made. 1034 * @return Return a new Intent object that you can hand to 1035 * {@link Context#startActivity(Intent) Context.startActivity()} and 1036 * related methods. 1037 */ createChooser(Intent target, CharSequence title, IntentSender sender)1038 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) { 1039 Intent intent = new Intent(ACTION_CHOOSER); 1040 intent.putExtra(EXTRA_INTENT, target); 1041 if (title != null) { 1042 intent.putExtra(EXTRA_TITLE, title); 1043 } 1044 1045 if (sender != null) { 1046 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender); 1047 } 1048 1049 // Migrate any clip data and flags from target. 1050 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION 1051 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 1052 | FLAG_GRANT_PREFIX_URI_PERMISSION); 1053 if (permFlags != 0) { 1054 ClipData targetClipData = target.getClipData(); 1055 if (targetClipData == null && target.getData() != null) { 1056 ClipData.Item item = new ClipData.Item(target.getData()); 1057 String[] mimeTypes; 1058 if (target.getType() != null) { 1059 mimeTypes = new String[] { target.getType() }; 1060 } else { 1061 mimeTypes = new String[] { }; 1062 } 1063 targetClipData = new ClipData(null, mimeTypes, item); 1064 } 1065 if (targetClipData != null) { 1066 intent.setClipData(targetClipData); 1067 intent.addFlags(permFlags); 1068 } 1069 } 1070 1071 return intent; 1072 } 1073 1074 /** 1075 * Activity Action: Allow the user to select a particular kind of data and 1076 * return it. This is different than {@link #ACTION_PICK} in that here we 1077 * just say what kind of data is desired, not a URI of existing data from 1078 * which the user can pick. An ACTION_GET_CONTENT could allow the user to 1079 * create the data as it runs (for example taking a picture or recording a 1080 * sound), let them browse over the web and download the desired data, 1081 * etc. 1082 * <p> 1083 * There are two main ways to use this action: if you want a specific kind 1084 * of data, such as a person contact, you set the MIME type to the kind of 1085 * data you want and launch it with {@link Context#startActivity(Intent)}. 1086 * The system will then launch the best application to select that kind 1087 * of data for you. 1088 * <p> 1089 * You may also be interested in any of a set of types of content the user 1090 * can pick. For example, an e-mail application that wants to allow the 1091 * user to add an attachment to an e-mail message can use this action to 1092 * bring up a list of all of the types of content the user can attach. 1093 * <p> 1094 * In this case, you should wrap the GET_CONTENT intent with a chooser 1095 * (through {@link #createChooser}), which will give the proper interface 1096 * for the user to pick how to send your data and allow you to specify 1097 * a prompt indicating what they are doing. You will usually specify a 1098 * broad MIME type (such as image/* or {@literal *}/*), resulting in a 1099 * broad range of content types the user can select from. 1100 * <p> 1101 * When using such a broad GET_CONTENT action, it is often desirable to 1102 * only pick from data that can be represented as a stream. This is 1103 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent. 1104 * <p> 1105 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that 1106 * the launched content chooser only returns results representing data that 1107 * is locally available on the device. For example, if this extra is set 1108 * to true then an image picker should not show any pictures that are available 1109 * from a remote server but not already on the local device (thus requiring 1110 * they be downloaded when opened). 1111 * <p> 1112 * If the caller can handle multiple returned items (the user performing 1113 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE} 1114 * to indicate this. 1115 * <p> 1116 * Input: {@link #getType} is the desired MIME type to retrieve. Note 1117 * that no URI is supplied in the intent, as there are no constraints on 1118 * where the returned data originally comes from. You may also include the 1119 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be 1120 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content 1121 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to 1122 * allow the user to select multiple items. 1123 * <p> 1124 * Output: The URI of the item that was picked. This must be a content: 1125 * URI so that any receiver can access it. 1126 */ 1127 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1128 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT"; 1129 /** 1130 * Activity Action: Dial a number as specified by the data. This shows a 1131 * UI with the number being dialed, allowing the user to explicitly 1132 * initiate the call. 1133 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1134 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1135 * number. 1136 * <p>Output: nothing. 1137 */ 1138 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1139 public static final String ACTION_DIAL = "android.intent.action.DIAL"; 1140 /** 1141 * Activity Action: Perform a call to someone specified by the data. 1142 * <p>Input: If nothing, an empty dialer is started; else {@link #getData} 1143 * is URI of a phone number to be dialed or a tel: URI of an explicit phone 1144 * number. 1145 * <p>Output: nothing. 1146 * 1147 * <p>Note: there will be restrictions on which applications can initiate a 1148 * call; most applications should use the {@link #ACTION_DIAL}. 1149 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency 1150 * numbers. Applications can <strong>dial</strong> emergency numbers using 1151 * {@link #ACTION_DIAL}, however. 1152 * 1153 * <p>Note: An app filling the {@link android.app.role.RoleManager#ROLE_DIALER} role should use 1154 * {@link android.telecom.TelecomManager#placeCall(Uri, Bundle)} to place calls rather than 1155 * relying on this intent. 1156 * 1157 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M} 1158 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE} 1159 * permission which is not granted, then attempting to use this action will 1160 * result in a {@link java.lang.SecurityException}. 1161 */ 1162 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1163 public static final String ACTION_CALL = "android.intent.action.CALL"; 1164 /** 1165 * Activity Action: Perform a call to an emergency number specified by the 1166 * data. 1167 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1168 * tel: URI of an explicit phone number. 1169 * <p>Output: nothing. 1170 * 1171 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on 1172 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} 1173 * extra (if specified) and may be placed on another {@link PhoneAccount} with the 1174 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external 1175 * factors, such as network conditions and Modem/SIM status. 1176 * @hide 1177 */ 1178 @SystemApi 1179 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1180 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY"; 1181 /** 1182 * Activity Action: Dial a emergency number specified by the data. This shows a 1183 * UI with the number being dialed, allowing the user to explicitly 1184 * initiate the call. 1185 * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData} 1186 * is a tel: URI of an explicit emergency phone number. 1187 * <p>Output: nothing. 1188 * @hide 1189 */ 1190 @SystemApi 1191 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1192 public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY"; 1193 /** 1194 * Activity action: Perform a call to any number (emergency or not) 1195 * specified by the data. 1196 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a 1197 * tel: URI of an explicit phone number. 1198 * <p>Output: nothing. 1199 * @hide 1200 */ 1201 @SystemApi 1202 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1203 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED"; 1204 1205 /** 1206 * Activity Action: Main entry point for carrier setup apps. 1207 * <p>Carrier apps that provide an implementation for this action may be invoked to configure 1208 * carrier service and typically require 1209 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to 1210 * fulfill their duties. 1211 */ 1212 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1213 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP"; 1214 /** 1215 * Activity Action: Send a message to someone specified by the data. 1216 * <p>Input: {@link #getData} is URI describing the target. 1217 * <p>Output: nothing. 1218 */ 1219 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1220 public static final String ACTION_SENDTO = "android.intent.action.SENDTO"; 1221 /** 1222 * Activity Action: Deliver some data to someone else. Who the data is 1223 * being delivered to is not specified; it is up to the receiver of this 1224 * action to ask the user where the data should be sent. 1225 * <p> 1226 * When launching a SEND intent, you should usually wrap it in a chooser 1227 * (through {@link #createChooser}), which will give the proper interface 1228 * for the user to pick how to send your data and allow you to specify 1229 * a prompt indicating what they are doing. 1230 * <p> 1231 * Input: {@link #getType} is the MIME type of the data being sent. 1232 * get*Extra can have either a {@link #EXTRA_TEXT} 1233 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If 1234 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it 1235 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/* 1236 * if the MIME type is unknown (this will only allow senders that can 1237 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can 1238 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve 1239 * your text with HTML formatting. 1240 * <p> 1241 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1242 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1243 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1244 * content: URIs and other advanced features of {@link ClipData}. If 1245 * using this approach, you still must supply the same data through the 1246 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1247 * for compatibility with old applications. If you don't set a ClipData, 1248 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1249 * <p> 1250 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1251 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1252 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1253 * be openable only as asset typed files using 1254 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1255 * <p> 1256 * Optional standard extras, which may be interpreted by some recipients as 1257 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1258 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1259 * <p> 1260 * Output: nothing. 1261 */ 1262 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1263 public static final String ACTION_SEND = "android.intent.action.SEND"; 1264 /** 1265 * Activity Action: Deliver multiple data to someone else. 1266 * <p> 1267 * Like {@link #ACTION_SEND}, except the data is multiple. 1268 * <p> 1269 * Input: {@link #getType} is the MIME type of the data being sent. 1270 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link 1271 * #EXTRA_STREAM} field, containing the data to be sent. If using 1272 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT} 1273 * for clients to retrieve your text with HTML formatting. 1274 * <p> 1275 * Multiple types are supported, and receivers should handle mixed types 1276 * whenever possible. The right way for the receiver to check them is to 1277 * use the content resolver on each URI. The intent sender should try to 1278 * put the most concrete mime type in the intent type, but it can fall 1279 * back to {@literal <type>/*} or {@literal *}/* as needed. 1280 * <p> 1281 * e.g. if you are sending image/jpg and image/jpg, the intent's type can 1282 * be image/jpg, but if you are sending image/jpg and image/png, then the 1283 * intent's type should be image/*. 1284 * <p> 1285 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data 1286 * being sent can be supplied through {@link #setClipData(ClipData)}. This 1287 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing 1288 * content: URIs and other advanced features of {@link ClipData}. If 1289 * using this approach, you still must supply the same data through the 1290 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below 1291 * for compatibility with old applications. If you don't set a ClipData, 1292 * it will be copied there for you when calling {@link Context#startActivity(Intent)}. 1293 * <p> 1294 * Starting from {@link android.os.Build.VERSION_CODES#O}, if 1295 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in 1296 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may 1297 * be openable only as asset typed files using 1298 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. 1299 * <p> 1300 * Optional standard extras, which may be interpreted by some recipients as 1301 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC}, 1302 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}. 1303 * <p> 1304 * Output: nothing. 1305 */ 1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1307 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE"; 1308 /** 1309 * Activity Action: Handle an incoming phone call. 1310 * <p>Input: nothing. 1311 * <p>Output: nothing. 1312 */ 1313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1314 public static final String ACTION_ANSWER = "android.intent.action.ANSWER"; 1315 /** 1316 * Activity Action: Insert an empty item into the given container. 1317 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1318 * in which to place the data. 1319 * <p>Output: URI of the new data that was created. 1320 */ 1321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1322 public static final String ACTION_INSERT = "android.intent.action.INSERT"; 1323 /** 1324 * Activity Action: Create a new item in the given container, initializing it 1325 * from the current contents of the clipboard. 1326 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*) 1327 * in which to place the data. 1328 * <p>Output: URI of the new data that was created. 1329 */ 1330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1331 public static final String ACTION_PASTE = "android.intent.action.PASTE"; 1332 /** 1333 * Activity Action: Delete the given data from its container. 1334 * <p>Input: {@link #getData} is URI of data to be deleted. 1335 * <p>Output: nothing. 1336 */ 1337 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1338 public static final String ACTION_DELETE = "android.intent.action.DELETE"; 1339 /** 1340 * Activity Action: Run the data, whatever that means. 1341 * <p>Input: ? (Note: this is currently specific to the test harness.) 1342 * <p>Output: nothing. 1343 */ 1344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1345 public static final String ACTION_RUN = "android.intent.action.RUN"; 1346 /** 1347 * Activity Action: Perform a data synchronization. 1348 * <p>Input: ? 1349 * <p>Output: ? 1350 */ 1351 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1352 public static final String ACTION_SYNC = "android.intent.action.SYNC"; 1353 /** 1354 * Activity Action: Pick an activity given an intent, returning the class 1355 * selected. 1356 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent 1357 * used with {@link PackageManager#queryIntentActivities} to determine the 1358 * set of activities from which to pick. 1359 * <p>Output: Class name of the activity that was selected. 1360 */ 1361 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1362 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY"; 1363 /** 1364 * Activity Action: Perform a search. 1365 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1366 * is the text to search for. If empty, simply 1367 * enter your search results Activity with the search UI activated. 1368 * <p>Output: nothing. 1369 */ 1370 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1371 public static final String ACTION_SEARCH = "android.intent.action.SEARCH"; 1372 /** 1373 * Activity Action: Start the platform-defined tutorial 1374 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)} 1375 * is the text to search for. If empty, simply 1376 * enter your search results Activity with the search UI activated. 1377 * <p>Output: nothing. 1378 */ 1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1380 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL"; 1381 /** 1382 * Activity Action: Perform a web search. 1383 * <p> 1384 * Input: {@link android.app.SearchManager#QUERY 1385 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is 1386 * a url starts with http or https, the site will be opened. If it is plain 1387 * text, Google search will be applied. 1388 * <p> 1389 * Output: nothing. 1390 */ 1391 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1392 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH"; 1393 1394 /** 1395 * Activity Action: Perform assist action. 1396 * <p> 1397 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1398 * additional optional contextual information about where the user was when they 1399 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer 1400 * information. 1401 * Output: nothing. 1402 */ 1403 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1404 public static final String ACTION_ASSIST = "android.intent.action.ASSIST"; 1405 1406 /** 1407 * Activity Action: Perform voice assist action. 1408 * <p> 1409 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide 1410 * additional optional contextual information about where the user was when they 1411 * requested the voice assist. 1412 * Output: nothing. 1413 * @hide 1414 */ 1415 @SystemApi 1416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1417 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST"; 1418 1419 /** 1420 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground 1421 * application package at the time the assist was invoked. 1422 */ 1423 public static final String EXTRA_ASSIST_PACKAGE 1424 = "android.intent.extra.ASSIST_PACKAGE"; 1425 1426 /** 1427 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground 1428 * application package at the time the assist was invoked. 1429 */ 1430 public static final String EXTRA_ASSIST_UID 1431 = "android.intent.extra.ASSIST_UID"; 1432 1433 /** 1434 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual 1435 * information supplied by the current foreground app at the time of the assist request. 1436 * This is a {@link Bundle} of additional data. 1437 */ 1438 public static final String EXTRA_ASSIST_CONTEXT 1439 = "android.intent.extra.ASSIST_CONTEXT"; 1440 1441 /** 1442 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a 1443 * keyboard as the primary input device for assistance. 1444 */ 1445 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = 1446 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; 1447 1448 /** 1449 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id 1450 * that was used to invoke the assist. 1451 */ 1452 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = 1453 "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; 1454 1455 /** 1456 * Activity Action: List all available applications. 1457 * <p>Input: Nothing. 1458 * <p>Output: nothing. 1459 */ 1460 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1461 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS"; 1462 1463 /** 1464 * Activity Action: Action to show the list of all work apps in the launcher. For example, 1465 * shows the work apps folder or tab. 1466 * 1467 * <p>Input: Nothing. 1468 * <p>Output: nothing. 1469 */ 1470 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1471 public static final String ACTION_SHOW_WORK_APPS = 1472 "android.intent.action.SHOW_WORK_APPS"; 1473 1474 /** 1475 * Activity Action: Show settings for choosing wallpaper. 1476 * <p>Input: Nothing. 1477 * <p>Output: Nothing. 1478 */ 1479 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1480 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER"; 1481 1482 /** 1483 * Activity Action: Show activity for reporting a bug. 1484 * <p>Input: Nothing. 1485 * <p>Output: Nothing. 1486 */ 1487 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1488 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT"; 1489 1490 /** 1491 * Activity Action: Main entry point for factory tests. Only used when 1492 * the device is booting in factory test node. The implementing package 1493 * must be installed in the system image. 1494 * <p>Input: nothing 1495 * <p>Output: nothing 1496 */ 1497 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1498 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST"; 1499 1500 /** 1501 * Activity Action: The user pressed the "call" button to go to the dialer 1502 * or other appropriate UI for placing a call. 1503 * <p>Input: Nothing. 1504 * <p>Output: Nothing. 1505 */ 1506 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1507 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON"; 1508 1509 /** 1510 * Activity Action: Start Voice Command. 1511 * <p>Input: Nothing. 1512 * <p>Output: Nothing. 1513 * <p class="note"> 1514 * In some cases, a matching Activity may not exist, so ensure you 1515 * safeguard against this. 1516 */ 1517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1518 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND"; 1519 1520 /** 1521 * Activity Action: Start action associated with long pressing on the 1522 * search key. 1523 * <p>Input: Nothing. 1524 * <p>Output: Nothing. 1525 */ 1526 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1527 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS"; 1528 1529 /** 1530 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog. 1531 * This intent is delivered to the package which installed the application, usually 1532 * Google Play. 1533 * <p>Input: No data is specified. The bug report is passed in using 1534 * an {@link #EXTRA_BUG_REPORT} field. 1535 * <p>Output: Nothing. 1536 * 1537 * @see #EXTRA_BUG_REPORT 1538 */ 1539 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1540 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR"; 1541 1542 /** 1543 * An incident or bug report has been taken, and a system app has requested it to be shared, 1544 * so trigger the confirmation screen. 1545 * 1546 * This will be sent directly to the registered receiver with the 1547 * android.permission.APPROVE_INCIDENT_REPORTS permission. 1548 * @hide 1549 */ 1550 @SystemApi 1551 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED = 1552 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED"; 1553 1554 /** 1555 * An incident report has been taken, and the user has approved it for sharing. 1556 * <p> 1557 * This will be sent directly to the registered receiver, which must have 1558 * both the DUMP and USAGE_STATS permissions. 1559 * <p> 1560 * After receiving this, the application should wait until a suitable time 1561 * (e.g. network available), get the list of available reports with 1562 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)} 1563 * and then when the reports have been successfully uploaded, call 1564 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}. 1565 * 1566 * @hide 1567 */ 1568 @SystemApi 1569 public static final String ACTION_INCIDENT_REPORT_READY = 1570 "android.intent.action.INCIDENT_REPORT_READY"; 1571 1572 /** 1573 * Activity Action: Show power usage information to the user. 1574 * <p>Input: Nothing. 1575 * <p>Output: Nothing. 1576 */ 1577 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1578 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY"; 1579 1580 /** 1581 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs 1582 * to run. 1583 * <p>Input: Nothing. 1584 * <p>Output: Nothing. 1585 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified 1586 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD} 1587 * @hide 1588 * @removed 1589 */ 1590 @Deprecated 1591 @SystemApi 1592 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD = 1593 "android.intent.action.DEVICE_INITIALIZATION_WIZARD"; 1594 1595 /** 1596 * Activity Action: Setup wizard to launch after a platform update. This 1597 * activity should have a string meta-data field associated with it, 1598 * {@link #METADATA_SETUP_VERSION}, which defines the current version of 1599 * the platform for setup. The activity will be launched only if 1600 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the 1601 * same value. 1602 * <p>Input: Nothing. 1603 * <p>Output: Nothing. 1604 * @hide 1605 */ 1606 @SystemApi 1607 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1608 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP"; 1609 1610 /** 1611 * Activity Action: Start the Keyboard Shortcuts Helper screen. 1612 * <p>Input: Nothing. 1613 * <p>Output: Nothing. 1614 * @hide 1615 */ 1616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1617 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS = 1618 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS"; 1619 1620 /** 1621 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen. 1622 * <p>Input: Nothing. 1623 * <p>Output: Nothing. 1624 * @hide 1625 */ 1626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1627 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS = 1628 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS"; 1629 1630 /** 1631 * Activity Action: Show settings for managing network data usage of a 1632 * specific application. Applications should define an activity that offers 1633 * options to control data usage. 1634 */ 1635 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1636 public static final String ACTION_MANAGE_NETWORK_USAGE = 1637 "android.intent.action.MANAGE_NETWORK_USAGE"; 1638 1639 /** 1640 * Activity Action: Launch application installer. 1641 * <p> 1642 * Input: The data must be a content: URI at which the application 1643 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1}, 1644 * you can also use "package:<package-name>" to install an application for the 1645 * current user that is already installed for another user. You can optionally supply 1646 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE}, 1647 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}. 1648 * <p> 1649 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install 1650 * succeeded. 1651 * <p> 1652 * <strong>Note:</strong>If your app is targeting API level higher than 25 you 1653 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} 1654 * in order to launch the application installer. 1655 * </p> 1656 * 1657 * @see #EXTRA_INSTALLER_PACKAGE_NAME 1658 * @see #EXTRA_NOT_UNKNOWN_SOURCE 1659 * @see #EXTRA_RETURN_RESULT 1660 * 1661 * @deprecated use {@link android.content.pm.PackageInstaller} instead 1662 */ 1663 @Deprecated 1664 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1665 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE"; 1666 1667 /** 1668 * Activity Action: Activity to handle split installation failures. 1669 * <p>Splits may be installed dynamically. This happens when an Activity is launched, 1670 * but the split that contains the application isn't installed. When a split is 1671 * installed in this manner, the containing package usually doesn't know this is 1672 * happening. However, if an error occurs during installation, the containing 1673 * package can define a single activity handling this action to deal with such 1674 * failures. 1675 * <p>The activity handling this action must be in the base package. 1676 * <p> 1677 * Input: {@link #EXTRA_INTENT} the original intent that started split installation. 1678 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed. 1679 */ 1680 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1681 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE"; 1682 1683 /** 1684 * Activity Action: Launch instant application installer. 1685 * <p class="note"> 1686 * This is a protected intent that can only be sent by the system. 1687 * </p> 1688 * 1689 * @hide 1690 */ 1691 @SystemApi 1692 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1693 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE 1694 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE"; 1695 1696 /** 1697 * Service Action: Resolve instant application. 1698 * <p> 1699 * The system will have a persistent connection to this service. 1700 * This is a protected intent that can only be sent by the system. 1701 * </p> 1702 * 1703 * @hide 1704 */ 1705 @SystemApi 1706 @SdkConstant(SdkConstantType.SERVICE_ACTION) 1707 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE 1708 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; 1709 1710 /** 1711 * Activity Action: Launch instant app settings. 1712 * 1713 * <p class="note"> 1714 * This is a protected intent that can only be sent by the system. 1715 * </p> 1716 * 1717 * @hide 1718 */ 1719 @SystemApi 1720 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1721 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS 1722 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS"; 1723 1724 /** 1725 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1726 * package. Specifies the installer package name; this package will receive the 1727 * {@link #ACTION_APP_ERROR} intent. 1728 */ 1729 public static final String EXTRA_INSTALLER_PACKAGE_NAME 1730 = "android.intent.extra.INSTALLER_PACKAGE_NAME"; 1731 1732 /** 1733 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1734 * package. Specifies that the application being installed should not be 1735 * treated as coming from an unknown source, but as coming from the app 1736 * invoking the Intent. For this to work you must start the installer with 1737 * startActivityForResult(). 1738 */ 1739 public static final String EXTRA_NOT_UNKNOWN_SOURCE 1740 = "android.intent.extra.NOT_UNKNOWN_SOURCE"; 1741 1742 /** 1743 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and 1744 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent 1745 * data field originated from. 1746 */ 1747 public static final String EXTRA_ORIGINATING_URI 1748 = "android.intent.extra.ORIGINATING_URI"; 1749 1750 /** 1751 * This extra can be used with any Intent used to launch an activity, supplying information 1752 * about who is launching that activity. This field contains a {@link android.net.Uri} 1753 * object, typically an http: or https: URI of the web site that the referral came from; 1754 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify 1755 * a native application that it came from. 1756 * 1757 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer} 1758 * instead of directly retrieving the extra. It is also valid for applications to 1759 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create 1760 * a string, not a Uri; the field here, if supplied, will always take precedence, 1761 * however.</p> 1762 * 1763 * @see #EXTRA_REFERRER_NAME 1764 */ 1765 public static final String EXTRA_REFERRER 1766 = "android.intent.extra.REFERRER"; 1767 1768 /** 1769 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather 1770 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can 1771 * not be created, in particular when Intent extras are supplied through the 1772 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:} 1773 * schemes. 1774 * 1775 * @see #EXTRA_REFERRER 1776 */ 1777 public static final String EXTRA_REFERRER_NAME 1778 = "android.intent.extra.REFERRER_NAME"; 1779 1780 /** 1781 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and 1782 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install 1783 * Currently only a system app that hosts the provider authority "downloads" or holds the 1784 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this. 1785 * @hide 1786 */ 1787 @SystemApi 1788 public static final String EXTRA_ORIGINATING_UID 1789 = "android.intent.extra.ORIGINATING_UID"; 1790 1791 /** 1792 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a 1793 * package. Tells the installer UI to skip the confirmation with the user 1794 * if the .apk is replacing an existing one. 1795 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android 1796 * will no longer show an interstitial message about updating existing 1797 * applications so this is no longer needed. 1798 */ 1799 @Deprecated 1800 public static final String EXTRA_ALLOW_REPLACE 1801 = "android.intent.extra.ALLOW_REPLACE"; 1802 1803 /** 1804 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or 1805 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should 1806 * return to the application the result code of the install/uninstall. The returned result 1807 * code will be {@link android.app.Activity#RESULT_OK} on success or 1808 * {@link android.app.Activity#RESULT_FIRST_USER} on failure. 1809 */ 1810 public static final String EXTRA_RETURN_RESULT 1811 = "android.intent.extra.RETURN_RESULT"; 1812 1813 /** 1814 * Package manager install result code. @hide because result codes are not 1815 * yet ready to be exposed. 1816 */ 1817 public static final String EXTRA_INSTALL_RESULT 1818 = "android.intent.extra.INSTALL_RESULT"; 1819 1820 /** 1821 * Activity Action: Launch application uninstaller. 1822 * <p> 1823 * Input: The data must be a package: URI whose scheme specific part is 1824 * the package name of the current installed package to be uninstalled. 1825 * You can optionally supply {@link #EXTRA_RETURN_RESULT}. 1826 * <p> 1827 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the uninstall 1828 * succeeded. 1829 * <p> 1830 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES} 1831 * since {@link Build.VERSION_CODES#P}. 1832 * 1833 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)} 1834 * instead 1835 */ 1836 @Deprecated 1837 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1838 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE"; 1839 1840 /** 1841 * Specify whether the package should be uninstalled for all users. 1842 * @hide because these should not be part of normal application flow. 1843 */ 1844 public static final String EXTRA_UNINSTALL_ALL_USERS 1845 = "android.intent.extra.UNINSTALL_ALL_USERS"; 1846 1847 /** 1848 * A string that associates with a metadata entry, indicating the last run version of the 1849 * platform that was setup. 1850 * 1851 * @see #ACTION_UPGRADE_SETUP 1852 * 1853 * @hide 1854 */ 1855 @SystemApi 1856 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION"; 1857 1858 /** 1859 * Activity action: Launch UI to manage the permissions of an app. 1860 * <p> 1861 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions 1862 * will be managed by the launched UI. 1863 * </p> 1864 * <p> 1865 * Output: Nothing. 1866 * </p> 1867 * 1868 * @see #EXTRA_PACKAGE_NAME 1869 * 1870 * @hide 1871 */ 1872 @SystemApi 1873 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1874 public static final String ACTION_MANAGE_APP_PERMISSIONS = 1875 "android.intent.action.MANAGE_APP_PERMISSIONS"; 1876 1877 /** 1878 * Activity action: Launch UI to manage a specific permission group of an app. 1879 * <p> 1880 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission 1881 * will be managed by the launched UI. 1882 * </p> 1883 * <p> 1884 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission 1885 * whose group should be managed by the launched UI. 1886 * </p> 1887 * <p> 1888 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group 1889 * that should be managed by the launched UI. Do not send both this and EXTRA_PERMISSION_NAME 1890 * together. 1891 * </p> 1892 * <p> 1893 * <li> {@link #EXTRA_USER} specifies the {@link UserHandle} of the user that owns the app. 1894 * </p> 1895 * <p> 1896 * Output: Nothing. 1897 * </p> 1898 * 1899 * @see #EXTRA_PACKAGE_NAME 1900 * @see #EXTRA_PERMISSION_NAME 1901 * @see #EXTRA_PERMISSION_GROUP_NAME 1902 * @see #EXTRA_USER 1903 * 1904 * @hide 1905 */ 1906 @SystemApi 1907 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 1908 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1909 public static final String ACTION_MANAGE_APP_PERMISSION = 1910 "android.intent.action.MANAGE_APP_PERMISSION"; 1911 1912 /** 1913 * Activity action: Launch UI to manage permissions. 1914 * <p> 1915 * Input: Nothing. 1916 * </p> 1917 * <p> 1918 * Output: Nothing. 1919 * </p> 1920 * 1921 * @hide 1922 */ 1923 @SystemApi 1924 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1925 public static final String ACTION_MANAGE_PERMISSIONS = 1926 "android.intent.action.MANAGE_PERMISSIONS"; 1927 1928 /** 1929 * Activity action: Launch UI to manage auto-revoke state. 1930 * 1931 * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS 1932 * 1933 * <p> 1934 * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with 1935 * a package name, whose auto-revoke state will be reviewed (mandatory). 1936 * E.g. {@code Uri.fromParts("package", packageName, null) } 1937 * </p> 1938 * <p> 1939 * Output: Nothing. 1940 * </p> 1941 */ 1942 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1943 public static final String ACTION_AUTO_REVOKE_PERMISSIONS = 1944 "android.intent.action.AUTO_REVOKE_PERMISSIONS"; 1945 1946 /** 1947 * Activity action: Launch UI to manage unused apps (hibernated apps). 1948 * 1949 * <p> 1950 * Input: Nothing. 1951 * </p> 1952 * <p> 1953 * Output: Nothing. 1954 * </p> 1955 */ 1956 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1957 public static final String ACTION_MANAGE_UNUSED_APPS = 1958 "android.intent.action.MANAGE_UNUSED_APPS"; 1959 1960 /** 1961 * Activity action: Launch UI to review permissions for an app. 1962 * The system uses this intent if permission review for apps not 1963 * supporting the new runtime permissions model is enabled. In 1964 * this mode a permission review is required before any of the 1965 * app components can run. 1966 * <p> 1967 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose 1968 * permissions will be reviewed (mandatory). 1969 * </p> 1970 * <p> 1971 * Input: {@link #EXTRA_INTENT} specifies a pending intent to 1972 * be fired after the permission review (optional). 1973 * </p> 1974 * <p> 1975 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to 1976 * be invoked after the permission review (optional). 1977 * </p> 1978 * <p> 1979 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent 1980 * passed via {@link #EXTRA_INTENT} needs a result (optional). 1981 * </p> 1982 * <p> 1983 * Output: Nothing. 1984 * </p> 1985 * 1986 * @see #EXTRA_PACKAGE_NAME 1987 * @see #EXTRA_INTENT 1988 * @see #EXTRA_REMOTE_CALLBACK 1989 * @see #EXTRA_RESULT_NEEDED 1990 * 1991 * @hide 1992 */ 1993 @SystemApi 1994 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 1995 public static final String ACTION_REVIEW_PERMISSIONS = 1996 "android.intent.action.REVIEW_PERMISSIONS"; 1997 1998 /** 1999 * Activity action: Launch UI to show information about the usage 2000 * of a given permission group. This action would be handled by apps that 2001 * want to show details about how and why given permission group is being 2002 * used. 2003 * <p> 2004 * <strong>Important:</strong>You must protect the activity that handles 2005 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE 2006 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the 2007 * system can launch this activity. The system will not launch 2008 * activities that are not properly protected. 2009 * 2010 * <p> 2011 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group 2012 * for which the launched UI would be targeted. 2013 * </p> 2014 * <p> 2015 * Output: Nothing. 2016 * </p> 2017 */ 2018 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2019 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2020 public static final String ACTION_VIEW_PERMISSION_USAGE = 2021 "android.intent.action.VIEW_PERMISSION_USAGE"; 2022 2023 /** 2024 * Activity action: Launch UI to show information about the usage of a given permission group in 2025 * a given period. This action would be handled by apps that want to show details about how and 2026 * why given permission group is being used. 2027 * <p> 2028 * <strong>Important:</strong>You must protect the activity that handles this action with the 2029 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that 2030 * only the system can launch this activity. The system will not launch activities that are not 2031 * properly protected. 2032 * 2033 * <p> 2034 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for which the 2035 * launched UI would be targeted. 2036 * </p> 2037 * <p> 2038 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry. 2039 * </p> 2040 * <p> 2041 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in 2042 * millis). Both start time and end time are needed and start time must be <= end time. 2043 * </p> 2044 * <p> 2045 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in 2046 * millis). Both start time and end time are needed and start time must be <= end time. 2047 * </p> 2048 * <p> 2049 * Output: Nothing. 2050 * </p> 2051 */ 2052 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2053 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2054 public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD = 2055 "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD"; 2056 2057 /** 2058 * Activity action: Launch the Safety Center Quick Settings UI. 2059 * 2060 * <p> 2061 * Input: Nothing. 2062 * </p> 2063 * <p> 2064 * Output: Nothing. 2065 * </p> 2066 * 2067 * @hide 2068 */ 2069 @SystemApi 2070 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2071 @RequiresPermission(Manifest.permission.MANAGE_SENSOR_PRIVACY) 2072 public static final String ACTION_VIEW_SAFETY_CENTER_QS = 2073 "android.intent.action.VIEW_SAFETY_CENTER_QS"; 2074 2075 /** 2076 * Activity action: Launch UI to manage a default app. 2077 * <p> 2078 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed 2079 * by the launched UI. 2080 * </p> 2081 * <p> 2082 * Output: Nothing. 2083 * </p> 2084 * 2085 * @hide 2086 */ 2087 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2088 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2089 @SystemApi 2090 public static final String ACTION_MANAGE_DEFAULT_APP = 2091 "android.intent.action.MANAGE_DEFAULT_APP"; 2092 2093 /** 2094 * Intent extra: A role name. 2095 * <p> 2096 * Type: String 2097 * </p> 2098 * 2099 * @see android.app.role.RoleManager 2100 * 2101 * @hide 2102 */ 2103 @SystemApi 2104 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME"; 2105 2106 /** 2107 * Activity action: Launch UI to manage special app accesses. 2108 * <p> 2109 * Input: Nothing. 2110 * </p> 2111 * <p> 2112 * Output: Nothing. 2113 * </p> 2114 * 2115 * @hide 2116 */ 2117 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) 2118 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2119 @SystemApi 2120 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES = 2121 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES"; 2122 2123 /** 2124 * Intent extra: A callback for reporting remote result as a bundle. 2125 * <p> 2126 * Type: IRemoteCallback 2127 * </p> 2128 * 2129 * @hide 2130 */ 2131 @SystemApi 2132 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; 2133 2134 /** 2135 * Intent extra: An app package name. 2136 * <p> 2137 * Type: String 2138 * </p> 2139 * 2140 */ 2141 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME"; 2142 2143 /** 2144 * Intent extra: A {@link android.os.LocaleList} 2145 * <p> 2146 * Type: LocaleList 2147 * </p> 2148 */ 2149 public static final String EXTRA_LOCALE_LIST = "android.intent.extra.LOCALE_LIST"; 2150 2151 /** 2152 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an 2153 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}. 2154 * 2155 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the 2156 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}. 2157 * This is meant to enable the suspended app to better handle the state of being suspended. 2158 * 2159 * @see #ACTION_MY_PACKAGE_SUSPENDED 2160 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2161 * @see PackageManager#isPackageSuspended() 2162 * @see PackageManager#getSuspendedPackageAppExtras() 2163 */ 2164 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS"; 2165 2166 /** 2167 * Intent extra: An app split name. 2168 * <p> 2169 * Type: String 2170 * </p> 2171 */ 2172 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME"; 2173 2174 /** 2175 * Intent extra: A {@link ComponentName} value. 2176 * <p> 2177 * Type: String 2178 * </p> 2179 */ 2180 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME"; 2181 2182 /** 2183 * Intent extra: An extra for specifying whether a result is needed. 2184 * <p> 2185 * Type: boolean 2186 * </p> 2187 * 2188 * @hide 2189 */ 2190 @SystemApi 2191 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; 2192 2193 /** 2194 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with 2195 * {@link #ACTION_SEND}. 2196 * 2197 * @see ShortcutInfo#getId() 2198 * 2199 * <p> 2200 * Type: String 2201 * </p> 2202 */ 2203 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID"; 2204 2205 /** 2206 * Activity action: Launch UI to manage which apps have a given permission. 2207 * <p> 2208 * Input: {@link #EXTRA_PERMISSION_NAME} or {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the 2209 * permission group which will be managed by the launched UI. 2210 * </p> 2211 * <p> 2212 * Output: Nothing. 2213 * </p> 2214 * 2215 * @see #EXTRA_PERMISSION_NAME 2216 * @see #EXTRA_PERMISSION_GROUP_NAME 2217 * 2218 * @hide 2219 */ 2220 @SystemApi 2221 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2222 public static final String ACTION_MANAGE_PERMISSION_APPS = 2223 "android.intent.action.MANAGE_PERMISSION_APPS"; 2224 2225 /** 2226 * Intent extra: The name of a permission. 2227 * <p> 2228 * Type: String 2229 * </p> 2230 * 2231 * @hide 2232 */ 2233 @SystemApi 2234 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; 2235 2236 /** 2237 * Intent extra: The name of a permission group. 2238 * <p> 2239 * Type: String 2240 * </p> 2241 */ 2242 public static final String EXTRA_PERMISSION_GROUP_NAME = 2243 "android.intent.extra.PERMISSION_GROUP_NAME"; 2244 2245 /** 2246 * Intent extra: The number of milliseconds. 2247 * <p> 2248 * Type: long 2249 * </p> 2250 */ 2251 public static final String EXTRA_DURATION_MILLIS = 2252 "android.intent.extra.DURATION_MILLIS"; 2253 2254 /** 2255 * Activity action: Launch UI to review app uses of permissions. 2256 * <p> 2257 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name 2258 * that will be displayed by the launched UI. Do not pass both this and 2259 * {@link #EXTRA_PERMISSION_GROUP_NAME} . 2260 * </p> 2261 * <p> 2262 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2263 * that will be displayed by the launched UI. Do not pass both this and 2264 * {@link #EXTRA_PERMISSION_NAME}. 2265 * </p> 2266 * <p> 2267 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2268 * activity to show (optional). Must be non-negative. 2269 * </p> 2270 * <p> 2271 * Output: Nothing. 2272 * </p> 2273 * <p class="note"> 2274 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2275 * </p> 2276 * 2277 * @see #EXTRA_PERMISSION_NAME 2278 * @see #EXTRA_PERMISSION_GROUP_NAME 2279 * @see #EXTRA_DURATION_MILLIS 2280 * 2281 * @hide 2282 */ 2283 @SystemApi 2284 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2286 public static final String ACTION_REVIEW_PERMISSION_USAGE = 2287 "android.intent.action.REVIEW_PERMISSION_USAGE"; 2288 2289 /** 2290 * Activity action: Launch UI to review the timeline history of permissions. 2291 * <p> 2292 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name 2293 * that will be displayed by the launched UI. 2294 * </p> 2295 * <p> 2296 * Output: Nothing. 2297 * </p> 2298 * <p class="note"> 2299 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2300 * </p> 2301 * 2302 * @see #EXTRA_PERMISSION_GROUP_NAME 2303 * 2304 * @hide 2305 */ 2306 @SystemApi 2307 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2308 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2309 public static final String ACTION_REVIEW_PERMISSION_HISTORY = 2310 "android.intent.action.REVIEW_PERMISSION_HISTORY"; 2311 2312 /** 2313 * Activity action: Launch UI to review ongoing app uses of permissions. 2314 * <p> 2315 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent 2316 * activity to show (optional). Must be non-negative. 2317 * </p> 2318 * <p> 2319 * Output: Nothing. 2320 * </p> 2321 * <p class="note"> 2322 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission. 2323 * </p> 2324 * 2325 * @see #EXTRA_DURATION_MILLIS 2326 * 2327 * @hide 2328 */ 2329 @SystemApi 2330 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 2331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2332 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE = 2333 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE"; 2334 2335 /** 2336 * Activity action: Launch UI to review running accessibility services. 2337 * <p> 2338 * Input: Nothing. 2339 * </p> 2340 * <p> 2341 * Output: Nothing. 2342 * </p> 2343 * 2344 * @hide 2345 */ 2346 @SystemApi 2347 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES) 2348 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2349 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES = 2350 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"; 2351 2352 /** 2353 * Activity action: Launch UI to manage the usage of a given permission group. 2354 * This action would be handled by apps that want to show controls about the features 2355 * which use the permission group. 2356 * 2357 * <p> 2358 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for 2359 * which the launched UI would be targeted. 2360 * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry. 2361 * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in 2362 * millis). If both start time and end time are present, start time must be <= end time. 2363 * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in 2364 * millis). If the end time is empty, that implies that the permission usage is still in use. 2365 * If both start time and end time are present, start time must be <= end time. 2366 * Input: {@link #EXTRA_SHOWING_ATTRIBUTION} specifies whether the subattribution was shown 2367 * in the UI. 2368 * </p> 2369 * <p> 2370 * Output: Nothing. 2371 * </p> 2372 * <p class="note"> 2373 * You must protect the activity that handles this action with the 2374 * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that 2375 * only the system can launch this activity. The system will not launch activities 2376 * that are not properly protected. 2377 * </p> 2378 * 2379 * @see #EXTRA_PERMISSION_GROUP_NAME 2380 * @see #EXTRA_ATTRIBUTION_TAGS 2381 * @see #EXTRA_START_TIME 2382 * @see #EXTRA_END_TIME 2383 * @see #EXTRA_SHOWING_ATTRIBUTION 2384 * 2385 * @hide 2386 */ 2387 @SystemApi 2388 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE) 2389 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2390 public static final String ACTION_MANAGE_PERMISSION_USAGE = 2391 "android.intent.action.MANAGE_PERMISSION_USAGE"; 2392 2393 /** 2394 * Activity action: Launch UI to view the app's feature's information. 2395 * 2396 * <p> 2397 * Output: Nothing. 2398 * </p> 2399 * <p class="note"> 2400 * You must protect the activity that handles this action with the 2401 * {@link android.Manifest.permission#START_VIEW_APP_FEATURES} permission to ensure that 2402 * only the system can launch this activity. The system will not launch activities 2403 * that are not properly protected. 2404 * 2405 * An optional <meta-data> tag in the activity's manifest with 2406 * android:name=app_features_preference_summary and android:resource=@string/<string name> will 2407 * be used to add a summary line for the "All Services" preference in settings. 2408 * </p> 2409 * @hide 2410 */ 2411 @SystemApi 2412 @RequiresPermission(android.Manifest.permission.START_VIEW_APP_FEATURES) 2413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2414 public static final String ACTION_VIEW_APP_FEATURES = 2415 "android.intent.action.VIEW_APP_FEATURES"; 2416 2417 /** 2418 * Activity action: Launch UI to open the Safety Center, which highlights the user's security 2419 * and privacy status. 2420 */ 2421 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2422 public static final String ACTION_SAFETY_CENTER = 2423 "android.intent.action.SAFETY_CENTER"; 2424 2425 // --------------------------------------------------------------------- 2426 // --------------------------------------------------------------------- 2427 // Standard intent broadcast actions (see action variable). 2428 2429 /** 2430 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive. 2431 * <p> 2432 * For historical reasons, the name of this broadcast action refers to the power 2433 * state of the screen but it is actually sent in response to changes in the 2434 * overall interactive state of the device. 2435 * </p><p> 2436 * This broadcast is sent when the device becomes non-interactive which may have 2437 * nothing to do with the screen turning off. To determine the 2438 * actual state of the screen, use {@link android.view.Display#getState}. 2439 * </p><p> 2440 * See {@link android.os.PowerManager#isInteractive} for details. 2441 * </p> 2442 * You <em>cannot</em> receive this through components declared in 2443 * manifests, only by explicitly registering for it with 2444 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2445 * Context.registerReceiver()}. 2446 * 2447 * <p class="note">This is a protected intent that can only be sent 2448 * by the system. 2449 */ 2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2451 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF"; 2452 2453 /** 2454 * Broadcast Action: Sent when the device wakes up and becomes interactive. 2455 * <p> 2456 * For historical reasons, the name of this broadcast action refers to the power 2457 * state of the screen but it is actually sent in response to changes in the 2458 * overall interactive state of the device. 2459 * </p><p> 2460 * This broadcast is sent when the device becomes interactive which may have 2461 * nothing to do with the screen turning on. To determine the 2462 * actual state of the screen, use {@link android.view.Display#getState}. 2463 * </p><p> 2464 * See {@link android.os.PowerManager#isInteractive} for details. 2465 * </p> 2466 * You <em>cannot</em> receive this through components declared in 2467 * manifests, only by explicitly registering for it with 2468 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2469 * Context.registerReceiver()}. 2470 * 2471 * <p class="note">This is a protected intent that can only be sent 2472 * by the system. 2473 */ 2474 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2475 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON"; 2476 2477 /** 2478 * Broadcast Action: Sent after the system stops dreaming. 2479 * 2480 * <p class="note">This is a protected intent that can only be sent by the system. 2481 * It is only sent to registered receivers.</p> 2482 */ 2483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2484 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED"; 2485 2486 /** 2487 * Broadcast Action: Sent after the system starts dreaming. 2488 * 2489 * <p class="note">This is a protected intent that can only be sent by the system. 2490 * It is only sent to registered receivers.</p> 2491 */ 2492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2493 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED"; 2494 2495 /** 2496 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the 2497 * keyguard is gone). 2498 * 2499 * <p class="note">This is a protected intent that can only be sent 2500 * by the system. 2501 */ 2502 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2503 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT"; 2504 2505 /** 2506 * Broadcast Action: The current time has changed. Sent every 2507 * minute. You <em>cannot</em> receive this through components declared 2508 * in manifests, only by explicitly registering for it with 2509 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 2510 * Context.registerReceiver()}. 2511 * 2512 * <p class="note">This is a protected intent that can only be sent 2513 * by the system. 2514 */ 2515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2516 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK"; 2517 /** 2518 * Broadcast Action: The time was set. 2519 */ 2520 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2521 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET"; 2522 /** 2523 * Broadcast Action: The date has changed. 2524 */ 2525 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2526 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED"; 2527 /** 2528 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p> 2529 * <ul> 2530 * <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new 2531 * time zone.</li> 2532 * </ul> 2533 * 2534 * <p class="note">This is a protected intent that can only be sent 2535 * by the system. 2536 */ 2537 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2538 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED"; 2539 /** 2540 * Alarm Changed Action: This is broadcast when the AlarmClock 2541 * application's alarm is set or unset. It is used by the 2542 * AlarmClock application and the StatusBar service. 2543 * @hide 2544 */ 2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2546 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2547 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; 2548 2549 /** 2550 * Broadcast Action: This is broadcast once, after the user has finished 2551 * booting, but while still in the "locked" state. It can be used to perform 2552 * application-specific initialization, such as installing alarms. You must 2553 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} 2554 * permission in order to receive this broadcast. 2555 * <p> 2556 * This broadcast is sent immediately at boot by all devices (regardless of 2557 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or 2558 * higher. Upon receipt of this broadcast, the user is still locked and only 2559 * device-protected storage can be accessed safely. If you want to access 2560 * credential-protected storage, you need to wait for the user to be 2561 * unlocked (typically by entering their lock pattern or PIN for the first 2562 * time), after which the {@link #ACTION_USER_UNLOCKED} and 2563 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent. 2564 * <p> 2565 * To receive this broadcast, your receiver component must be marked as 2566 * being {@link ComponentInfo#directBootAware}. 2567 * <p class="note"> 2568 * This is a protected intent that can only be sent by the system. 2569 * 2570 * @see Context#createDeviceProtectedStorageContext() 2571 */ 2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2573 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED"; 2574 2575 /** 2576 * Broadcast Action: This is broadcast once, after the user has finished 2577 * booting. It can be used to perform application-specific initialization, 2578 * such as installing alarms. You must hold the 2579 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in 2580 * order to receive this broadcast. 2581 * <p> 2582 * This broadcast is sent at boot by all devices (both with and without 2583 * direct boot support). Upon receipt of this broadcast, the user is 2584 * unlocked and both device-protected and credential-protected storage can 2585 * accessed safely. 2586 * <p> 2587 * If you need to run while the user is still locked (before they've entered 2588 * their lock pattern or PIN for the first time), you can listen for the 2589 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast. 2590 * <p class="note"> 2591 * This is a protected intent that can only be sent by the system. 2592 */ 2593 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2594 @BroadcastBehavior(includeBackground = true) 2595 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"; 2596 2597 /** 2598 * Broadcast Action: This is broadcast when a user action should request a 2599 * temporary system dialog to dismiss. Some examples of temporary system 2600 * dialogs are the notification window-shade and the recent tasks dialog. 2601 * 2602 * @deprecated This intent is deprecated for third-party applications starting from Android 2603 * {@link Build.VERSION_CODES#S} for security reasons. Unauthorized usage by applications 2604 * will result in the broadcast intent being dropped for apps targeting API level less than 2605 * {@link Build.VERSION_CODES#S} and in a {@link SecurityException} for apps targeting SDK 2606 * level {@link Build.VERSION_CODES#S} or higher. Instrumentation initiated from the shell 2607 * (eg. tests) is still able to use the intent. The platform will automatically collapse 2608 * the proper system dialogs in the proper use-cases. For all others, the user is the one in 2609 * control of closing dialogs. 2610 * 2611 * @see AccessibilityService#GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE 2612 */ 2613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2614 @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS) 2615 @Deprecated 2616 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS"; 2617 /** 2618 * Broadcast Action: Trigger the download and eventual installation 2619 * of a package. 2620 * <p>Input: {@link #getData} is the URI of the package file to download. 2621 * 2622 * <p class="note">This is a protected intent that can only be sent 2623 * by the system. 2624 * 2625 * @deprecated This constant has never been used. 2626 */ 2627 @Deprecated 2628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2629 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL"; 2630 /** 2631 * Broadcast Action: A new application package has been installed on the 2632 * device. The data contains the name of the package. Note that the 2633 * newly installed package does <em>not</em> receive this broadcast. 2634 * <p>May include the following extras: 2635 * <ul> 2636 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2637 * <li> {@link #EXTRA_REPLACING} is set to true if this is following 2638 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package. 2639 * </ul> 2640 * 2641 * <p class="note">This is a protected intent that can only be sent 2642 * by the system. 2643 */ 2644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2645 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED"; 2646 /** 2647 * Broadcast Action: A new version of an application package has been 2648 * installed, replacing an existing version that was previously installed. 2649 * The data contains the name of the package. 2650 * <p>May include the following extras: 2651 * <ul> 2652 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package. 2653 * </ul> 2654 * 2655 * <p class="note">This is a protected intent that can only be sent 2656 * by the system. 2657 */ 2658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2659 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED"; 2660 /** 2661 * Broadcast Action: A new version of your application has been installed 2662 * over an existing one. This is only sent to the application that was 2663 * replaced. It does not contain any additional data; to receive it, just 2664 * use an intent filter for this action. 2665 * 2666 * <p class="note">This is a protected intent that can only be sent 2667 * by the system. 2668 */ 2669 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2670 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED"; 2671 /** 2672 * Broadcast Action: An existing application package has been removed from 2673 * the device. The data contains the name of the package. The package 2674 * that is being removed does <em>not</em> receive this Intent. 2675 * <ul> 2676 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2677 * to the package. 2678 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2679 * application -- data and code -- is being removed. 2680 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2681 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2682 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal that the application 2683 * was removed with the user-initiated action. 2684 * </ul> 2685 * 2686 * <p class="note">This is a protected intent that can only be sent 2687 * by the system. 2688 */ 2689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2690 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED"; 2691 /** 2692 * Broadcast Action: An existing application package has been removed from 2693 * the device. The data contains the name of the package and the visibility 2694 * allow list. The package that is being removed does <em>not</em> receive 2695 * this Intent. 2696 * <ul> 2697 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2698 * to the package. 2699 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire 2700 * application -- data and code -- is being removed. 2701 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed 2702 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package. 2703 * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal 2704 * that the application was removed with the user-initiated action. 2705 * <li> {@link #EXTRA_VISIBILITY_ALLOW_LIST} containing an int array to 2706 * indicate the visibility allow list. 2707 * </ul> 2708 * 2709 * <p class="note">This is a protected intent that can only be sent 2710 * by the system. 2711 * 2712 * @hide This broadcast is used internally by the system. 2713 */ 2714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2715 public static final String ACTION_PACKAGE_REMOVED_INTERNAL = 2716 "android.intent.action.PACKAGE_REMOVED_INTERNAL"; 2717 /** 2718 * Broadcast Action: An existing application package has been completely 2719 * removed from the device. The data contains the name of the package. 2720 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when 2721 * {@link #EXTRA_DATA_REMOVED} is true and 2722 * {@link #EXTRA_REPLACING} is false of that broadcast. 2723 * 2724 * <ul> 2725 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned 2726 * to the package. 2727 * </ul> 2728 * 2729 * <p class="note">This is a protected intent that can only be sent 2730 * by the system. 2731 */ 2732 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2733 public static final String ACTION_PACKAGE_FULLY_REMOVED 2734 = "android.intent.action.PACKAGE_FULLY_REMOVED"; 2735 /** 2736 * Broadcast Action: An existing application package has been changed (for 2737 * example, a component has been enabled or disabled). The data contains 2738 * the name of the package. 2739 * <ul> 2740 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2741 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name 2742 * of the changed components (or the package name itself). 2743 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the 2744 * default action of restarting the application. 2745 * </ul> 2746 * 2747 * <p class="note">This is a protected intent that can only be sent 2748 * by the system. 2749 */ 2750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2751 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED"; 2752 /** 2753 * Broadcast Action: Sent to the system rollback manager when a package 2754 * needs to have rollback enabled. 2755 * <p class="note"> 2756 * This is a protected intent that can only be sent by the system. 2757 * </p> 2758 * 2759 * @hide This broadcast is used internally by the system. 2760 */ 2761 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2762 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK = 2763 "android.intent.action.PACKAGE_ENABLE_ROLLBACK"; 2764 /** 2765 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain 2766 * package needs to be cancelled. 2767 * 2768 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager 2769 * that enabling a specific rollback has timed out. 2770 * 2771 * @hide 2772 */ 2773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2774 public static final String ACTION_CANCEL_ENABLE_ROLLBACK = 2775 "android.intent.action.CANCEL_ENABLE_ROLLBACK"; 2776 /** 2777 * Broadcast Action: A rollback has been committed. 2778 * 2779 * <p class="note">This is a protected intent that can only be sent 2780 * by the system. The receiver must hold MANAGE_ROLLBACK permission. 2781 * 2782 * @hide 2783 */ 2784 @SystemApi 2785 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2786 public static final String ACTION_ROLLBACK_COMMITTED = 2787 "android.intent.action.ROLLBACK_COMMITTED"; 2788 /** 2789 * @hide 2790 * Broadcast Action: Ask system services if there is any reason to 2791 * restart the given package. The data contains the name of the 2792 * package. 2793 * <ul> 2794 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2795 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check. 2796 * </ul> 2797 * 2798 * <p class="note">This is a protected intent that can only be sent 2799 * by the system. 2800 */ 2801 @SystemApi 2802 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2803 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; 2804 /** 2805 * Broadcast Action: The user has restarted a package, and all of its 2806 * processes have been killed. All runtime state 2807 * associated with it (processes, alarms, notifications, etc) should 2808 * be removed. Note that the restarted package does <em>not</em> 2809 * receive this broadcast. 2810 * The data contains the name of the package. 2811 * <ul> 2812 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. 2813 * </ul> 2814 * 2815 * <p class="note">This is a protected intent that can only be sent 2816 * by the system. 2817 */ 2818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2819 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED"; 2820 /** 2821 * Broadcast Action: The user has cleared the data of a package. This should 2822 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of 2823 * its persistent data is erased and this broadcast sent. 2824 * Note that the cleared package does <em>not</em> 2825 * receive this broadcast. The data contains the name of the package. 2826 * <ul> 2827 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the 2828 * package whose data was cleared is an uninstalled instant app, then the UID 2829 * will be -1. The platform keeps some meta-data associated with instant apps 2830 * after they are uninstalled. 2831 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared 2832 * data was for an instant app. 2833 * </ul> 2834 * 2835 * <p class="note">This is a protected intent that can only be sent 2836 * by the system. 2837 */ 2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2839 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED"; 2840 /** 2841 * Broadcast Action: Packages have been suspended. 2842 * <p>Includes the following extras: 2843 * <ul> 2844 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended 2845 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended 2846 * </ul> 2847 * 2848 * <p class="note">This is a protected intent that can only be sent 2849 * by the system. It is only sent to registered receivers. 2850 */ 2851 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2852 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED"; 2853 /** 2854 * Broadcast Action: Packages have been unsuspended. 2855 * <p>Includes the following extras: 2856 * <ul> 2857 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended 2858 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended 2859 * </ul> 2860 * 2861 * <p class="note">This is a protected intent that can only be sent 2862 * by the system. It is only sent to registered receivers. 2863 */ 2864 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2865 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED"; 2866 /** 2867 * Broadcast Action: One of the suspend conditions have been modified for the packages. 2868 * <p>Includes the following extras: 2869 * <ul> 2870 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been modified 2871 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been modified 2872 * </ul> 2873 * 2874 * <p class="note">This is a protected intent that can only be sent 2875 * by the system. It is only sent to registered receivers. 2876 * 2877 * @hide 2878 */ 2879 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2880 public static final String ACTION_PACKAGES_SUSPENSION_CHANGED = 2881 "android.intent.action.PACKAGES_SUSPENSION_CHANGED"; 2882 2883 /** 2884 * Broadcast Action: Distracting packages have been changed. 2885 * <p>Includes the following extras: 2886 * <ul> 2887 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed. 2888 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed. 2889 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages. 2890 * </ul> 2891 * 2892 * <p class="note">This is a protected intent that can only be sent 2893 * by the system. It is only sent to registered receivers. 2894 * 2895 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 2896 * @hide 2897 */ 2898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2899 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED = 2900 "android.intent.action.DISTRACTING_PACKAGES_CHANGED"; 2901 2902 /** 2903 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent 2904 * whenever a package is put into a suspended state or any of its app extras change while in the 2905 * suspended state. 2906 * <p> Optionally includes the following extras: 2907 * <ul> 2908 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain 2909 * useful information for the app being suspended. 2910 * </ul> 2911 * <p class="note">This is a protected intent that can only be sent 2912 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2913 * the manifest.</em> 2914 * 2915 * @see #ACTION_MY_PACKAGE_UNSUSPENDED 2916 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2917 * @see PackageManager#isPackageSuspended() 2918 * @see PackageManager#getSuspendedPackageAppExtras() 2919 */ 2920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2921 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED"; 2922 2923 /** 2924 * Activity Action: Started to show more details about why an application was suspended. 2925 * 2926 * <p>Whenever the system detects an activity launch for a suspended app, this action can 2927 * be used to show more details about the reason for suspension. 2928 * 2929 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity 2930 * handling this intent and protect it with 2931 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}. 2932 * 2933 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package. 2934 * 2935 * <p class="note">This is a protected intent that can only be sent 2936 * by the system. 2937 * 2938 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2939 * PersistableBundle, String) 2940 * @see PackageManager#isPackageSuspended() 2941 * @see #ACTION_PACKAGES_SUSPENDED 2942 * 2943 * @hide 2944 */ 2945 @SystemApi 2946 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 2947 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS = 2948 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS"; 2949 2950 /** 2951 * Broadcast Action: Sent to indicate that the user unsuspended a package. 2952 * 2953 * <p>This can happen when the user taps on the neutral button of the 2954 * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using 2955 * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the 2956 * suspending app that originally specified this dialog while calling 2957 * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2958 * PersistableBundle, SuspendDialogInfo)}. 2959 * 2960 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just 2961 * got unsuspended. 2962 * 2963 * <p class="note">This is a protected intent that can only be sent 2964 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2965 * the manifest.</em> 2966 * 2967 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, 2968 * PersistableBundle, SuspendDialogInfo) 2969 * @see PackageManager#isPackageSuspended() 2970 * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS 2971 * @hide 2972 */ 2973 @SystemApi 2974 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2975 public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY = 2976 "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY"; 2977 2978 /** 2979 * Broadcast Action: Sent to a package that has been unsuspended. 2980 * 2981 * <p class="note">This is a protected intent that can only be sent 2982 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in 2983 * the manifest.</em> 2984 * 2985 * @see #ACTION_MY_PACKAGE_SUSPENDED 2986 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS 2987 * @see PackageManager#isPackageSuspended() 2988 * @see PackageManager#getSuspendedPackageAppExtras() 2989 */ 2990 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 2991 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED"; 2992 2993 /** 2994 * Broadcast Action: A uid has been removed from the system. The uid 2995 * number is stored in the extra data under {@link #EXTRA_UID}. 2996 * 2997 * In certain instances, {@link #EXTRA_REPLACING} is set to true if the UID is not being 2998 * fully removed. 2999 * 3000 * <p class="note">This is a protected intent that can only be sent 3001 * by the system. 3002 */ 3003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3004 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; 3005 3006 /** 3007 * Broadcast Action: Sent to the installer package of an application when 3008 * that application is first launched (that is the first time it is moved 3009 * out of the stopped state). The data contains the name of the package. 3010 * 3011 * <p>When the application is first launched, the application itself doesn't receive this 3012 * broadcast.</p> 3013 * 3014 * <p class="note">This is a protected intent that can only be sent 3015 * by the system. 3016 */ 3017 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3018 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH"; 3019 3020 /** 3021 * Broadcast Action: Sent to the system package verifier when a package 3022 * needs to be verified. The data contains the package URI. 3023 * <p class="note"> 3024 * This is a protected intent that can only be sent by the system. 3025 * </p> 3026 */ 3027 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3028 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION"; 3029 3030 /** 3031 * Broadcast Action: Sent to the system package verifier when a package is 3032 * verified. The data contains the package URI. 3033 * <p class="note"> 3034 * This is a protected intent that can only be sent by the system. 3035 */ 3036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3037 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED"; 3038 3039 /** 3040 * Broadcast Action: Sent to the system intent filter verifier when an 3041 * intent filter needs to be verified. The data contains the filter data 3042 * hosts to be verified against. 3043 * <p class="note"> 3044 * This is a protected intent that can only be sent by the system. 3045 * </p> 3046 * 3047 * @hide 3048 * @deprecated Superseded by domain verification APIs. See {@link DomainVerificationManager}. 3049 */ 3050 @Deprecated 3051 @SystemApi 3052 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3053 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = 3054 "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION"; 3055 3056 3057 /** 3058 * Broadcast Action: Sent to the system domain verification agent when an app's domains need 3059 * to be verified. The data contains the domains hosts to be verified against. 3060 * <p class="note"> 3061 * This is a protected intent that can only be sent by the system. 3062 * </p> 3063 * 3064 * @hide 3065 */ 3066 @SystemApi 3067 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3068 public static final String ACTION_DOMAINS_NEED_VERIFICATION = 3069 "android.intent.action.DOMAINS_NEED_VERIFICATION"; 3070 3071 /** 3072 * Broadcast Action: Resources for a set of packages (which were 3073 * previously unavailable) are currently 3074 * available since the media on which they exist is available. 3075 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 3076 * list of packages whose availability changed. 3077 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 3078 * list of uids of packages whose availability changed. 3079 * Note that the 3080 * packages in this list do <em>not</em> receive this broadcast. 3081 * The specified set of packages are now available on the system. 3082 * <p>Includes the following extras: 3083 * <ul> 3084 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 3085 * whose resources(were previously unavailable) are currently available. 3086 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the 3087 * packages whose resources(were previously unavailable) 3088 * are currently available. 3089 * </ul> 3090 * 3091 * <p class="note">This is a protected intent that can only be sent 3092 * by the system. 3093 */ 3094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3095 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE = 3096 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"; 3097 3098 /** 3099 * Broadcast Action: Resources for a set of packages are currently 3100 * unavailable since the media on which they exist is unavailable. 3101 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a 3102 * list of packages whose availability changed. 3103 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a 3104 * list of uids of packages whose availability changed. 3105 * The specified set of packages can no longer be 3106 * launched and are practically unavailable on the system. 3107 * <p>Inclues the following extras: 3108 * <ul> 3109 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages 3110 * whose resources are no longer available. 3111 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages 3112 * whose resources are no longer available. 3113 * </ul> 3114 * 3115 * <p class="note">This is a protected intent that can only be sent 3116 * by the system. 3117 */ 3118 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3119 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE = 3120 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"; 3121 3122 /** 3123 * Broadcast Action: preferred activities have changed *explicitly*. 3124 * 3125 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g. 3126 * when an app is installed or uninstalled, but in such cases this broadcast will *not* 3127 * be sent. 3128 * 3129 * {@link #EXTRA_USER_HANDLE} contains the user ID in question. 3130 * 3131 * @hide 3132 */ 3133 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3134 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED = 3135 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED"; 3136 3137 3138 /** 3139 * Broadcast Action: The current system wallpaper has changed. See 3140 * {@link android.app.WallpaperManager} for retrieving the new wallpaper. 3141 * This should <em>only</em> be used to determine when the wallpaper 3142 * has changed to show the new wallpaper to the user. You should certainly 3143 * never, in response to this, change the wallpaper or other attributes of 3144 * it such as the suggested size. That would be unexpected, right? You'd cause 3145 * all kinds of loops, especially if other apps are doing similar things, 3146 * right? Of course. So please don't do this. 3147 * 3148 * @deprecated Modern applications should use 3149 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER 3150 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper 3151 * shown behind their UI, rather than watching for this broadcast and 3152 * rendering the wallpaper on their own. 3153 */ 3154 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3155 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED"; 3156 /** 3157 * Broadcast Action: The current device {@link android.content.res.Configuration} 3158 * (orientation, locale, etc) has changed. When such a change happens, the 3159 * UIs (view hierarchy) will need to be rebuilt based on this new 3160 * information; for the most part, applications don't need to worry about 3161 * this, because the system will take care of stopping and restarting the 3162 * application to make sure it sees the new changes. Some system code that 3163 * can not be restarted will need to watch for this action and handle it 3164 * appropriately. 3165 * 3166 * <p class="note"> 3167 * You <em>cannot</em> receive this through components declared 3168 * in manifests, only by explicitly registering for it with 3169 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3170 * Context.registerReceiver()}. 3171 * 3172 * <p class="note">This is a protected intent that can only be sent 3173 * by the system. 3174 * 3175 * @see android.content.res.Configuration 3176 */ 3177 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3178 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED"; 3179 3180 /** 3181 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed 3182 * such that the device may be eligible for the installation of additional configuration splits. 3183 * Configuration properties that can trigger this broadcast include locale and display density. 3184 * 3185 * <p class="note"> 3186 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through 3187 * components declared in manifests. However, the receiver <em>must</em> hold the 3188 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. 3189 * 3190 * <p class="note"> 3191 * This is a protected intent that can only be sent by the system. 3192 * 3193 * @hide 3194 */ 3195 @SystemApi 3196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3197 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = 3198 "android.intent.action.SPLIT_CONFIGURATION_CHANGED"; 3199 /** 3200 * Broadcast Action: The receiver's effective locale has changed. 3201 * 3202 * This happens when the device locale, or the receiving app's locale 3203 * (set via {@link android.app.LocaleManager#setApplicationLocales}) changed. 3204 * 3205 * Can be received by manifest-declared receivers. 3206 * 3207 * <p class="note"> If only the app locale changed, includes the following extras: 3208 * <ul> 3209 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed. 3210 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app 3211 * </ul> 3212 * 3213 * <p class="note">This is a protected intent that can only be sent 3214 * by the system. 3215 */ 3216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3217 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED"; 3218 /** 3219 * Broadcast Action: Locale of a particular app has changed. 3220 * 3221 * <p class="note"> This broadcast is explicitly sent to the 3222 * {@link android.content.pm.InstallSourceInfo#getInstallingPackageName} installer 3223 * of the app whose locale has changed. 3224 * <p class="note"> The broadcast could also be received by manifest-declared receivers with 3225 * {@code android.permission.READ_APP_SPECIFIC_LOCALES} 3226 * 3227 * <p class="note">This is a protected intent that can only be sent 3228 * by the system. 3229 * 3230 * <p>Includes the following extras: 3231 * <ul> 3232 * <li>{@link #EXTRA_PACKAGE_NAME} is the name of the package for which locale changed. 3233 * <li>{@link #EXTRA_LOCALE_LIST} contains locales that are currently set for specified app 3234 * </ul> 3235 */ 3236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3237 public static final String ACTION_APPLICATION_LOCALE_CHANGED = 3238 "android.intent.action.APPLICATION_LOCALE_CHANGED"; 3239 /** 3240 * Broadcast Action: This is a <em>sticky broadcast</em> containing the 3241 * charging state, level, and other information about the battery. 3242 * See {@link android.os.BatteryManager} for documentation on the 3243 * contents of the Intent. 3244 * 3245 * <p class="note"> 3246 * You <em>cannot</em> receive this through components declared 3247 * in manifests, only by explicitly registering for it with 3248 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3249 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW}, 3250 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED}, 3251 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related 3252 * broadcasts that are sent and can be received through manifest 3253 * receivers. 3254 * 3255 * <p class="note">This is a protected intent that can only be sent 3256 * by the system. 3257 */ 3258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3259 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED"; 3260 3261 3262 /** 3263 * Broadcast Action: Sent when the current battery level or plug type changes. 3264 * 3265 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle} 3266 * instances representing individual battery level changes with associated 3267 * extras from {@link #ACTION_BATTERY_CHANGED}. 3268 * 3269 * <p class="note"> 3270 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission. 3271 * 3272 * @hide 3273 */ 3274 @SystemApi 3275 public static final String ACTION_BATTERY_LEVEL_CHANGED = 3276 "android.intent.action.BATTERY_LEVEL_CHANGED"; 3277 /** 3278 * Broadcast Action: Indicates low battery condition on the device. 3279 * This broadcast corresponds to the "Low battery warning" system dialog. 3280 * 3281 * <p class="note">This is a protected intent that can only be sent 3282 * by the system. 3283 */ 3284 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3285 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW"; 3286 /** 3287 * Broadcast Action: Indicates the battery is now okay after being low. 3288 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has 3289 * gone back up to an okay state. 3290 * 3291 * <p class="note">This is a protected intent that can only be sent 3292 * by the system. 3293 */ 3294 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3295 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY"; 3296 /** 3297 * Broadcast Action: External power has been connected to the device. 3298 * This is intended for applications that wish to register specifically to this notification. 3299 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3300 * stay active to receive this notification. This action can be used to implement actions 3301 * that wait until power is available to trigger. 3302 * 3303 * <p class="note">This is a protected intent that can only be sent 3304 * by the system. 3305 */ 3306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3307 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED"; 3308 /** 3309 * Broadcast Action: External power has been removed from the device. 3310 * This is intended for applications that wish to register specifically to this notification. 3311 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to 3312 * stay active to receive this notification. This action can be used to implement actions 3313 * that wait until power is available to trigger. 3314 * 3315 * <p class="note">This is a protected intent that can only be sent 3316 * by the system. 3317 */ 3318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3319 public static final String ACTION_POWER_DISCONNECTED = 3320 "android.intent.action.ACTION_POWER_DISCONNECTED"; 3321 /** 3322 * Broadcast Action: Device is shutting down. 3323 * This is broadcast when the device is being shut down (completely turned 3324 * off, not sleeping). Once the broadcast is complete, the final shutdown 3325 * will proceed and all unsaved data lost. Apps will not normally need 3326 * to handle this, since the foreground activity will be paused as well. 3327 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered 3328 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3329 * Context.registerReceiver}. 3330 * 3331 * <p class="note">This is a protected intent that can only be sent 3332 * by the system. 3333 * <p>May include the following extras: 3334 * <ul> 3335 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this 3336 * shutdown is only for userspace processes. If not set, assumed to be false. 3337 * </ul> 3338 */ 3339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3340 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN"; 3341 /** 3342 * Activity Action: Start this activity to request system shutdown. 3343 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true 3344 * to request confirmation from the user before shutting down. The optional boolean 3345 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to 3346 * indicate that the shutdown is requested by the user. 3347 * 3348 * <p class="note">This is a protected intent that can only be sent 3349 * by the system. 3350 * 3351 * {@hide} 3352 */ 3353 public static final String ACTION_REQUEST_SHUTDOWN 3354 = "com.android.internal.intent.action.REQUEST_SHUTDOWN"; 3355 /** 3356 * Broadcast Action: A sticky broadcast that indicates low storage space 3357 * condition on the device 3358 * <p class="note"> 3359 * This is a protected intent that can only be sent by the system. 3360 * 3361 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3362 * or above, this broadcast will no longer be delivered to any 3363 * {@link BroadcastReceiver} defined in your manifest. Instead, 3364 * apps are strongly encouraged to use the improved 3365 * {@link Context#getCacheDir()} behavior so the system can 3366 * automatically free up storage when needed. 3367 */ 3368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3369 @Deprecated 3370 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW"; 3371 /** 3372 * Broadcast Action: Indicates low storage space condition on the device no 3373 * longer exists 3374 * <p class="note"> 3375 * This is a protected intent that can only be sent by the system. 3376 * 3377 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3378 * or above, this broadcast will no longer be delivered to any 3379 * {@link BroadcastReceiver} defined in your manifest. Instead, 3380 * apps are strongly encouraged to use the improved 3381 * {@link Context#getCacheDir()} behavior so the system can 3382 * automatically free up storage when needed. 3383 */ 3384 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3385 @Deprecated 3386 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK"; 3387 /** 3388 * Broadcast Action: A sticky broadcast that indicates a storage space full 3389 * condition on the device. This is intended for activities that want to be 3390 * able to fill the data partition completely, leaving only enough free 3391 * space to prevent system-wide SQLite failures. 3392 * <p class="note"> 3393 * This is a protected intent that can only be sent by the system. 3394 * 3395 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3396 * or above, this broadcast will no longer be delivered to any 3397 * {@link BroadcastReceiver} defined in your manifest. Instead, 3398 * apps are strongly encouraged to use the improved 3399 * {@link Context#getCacheDir()} behavior so the system can 3400 * automatically free up storage when needed. 3401 * @hide 3402 */ 3403 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3404 @Deprecated 3405 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL"; 3406 /** 3407 * Broadcast Action: Indicates storage space full condition on the device no 3408 * longer exists. 3409 * <p class="note"> 3410 * This is a protected intent that can only be sent by the system. 3411 * 3412 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O} 3413 * or above, this broadcast will no longer be delivered to any 3414 * {@link BroadcastReceiver} defined in your manifest. Instead, 3415 * apps are strongly encouraged to use the improved 3416 * {@link Context#getCacheDir()} behavior so the system can 3417 * automatically free up storage when needed. 3418 * @hide 3419 */ 3420 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3421 @Deprecated 3422 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL"; 3423 /** 3424 * Broadcast Action: Indicates low memory condition notification acknowledged by user 3425 * and package management should be started. 3426 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW 3427 * notification. 3428 */ 3429 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3430 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE"; 3431 /** 3432 * Broadcast Action: The device has entered USB Mass Storage mode. 3433 * This is used mainly for the USB Settings panel. 3434 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3435 * when the SD card file system is mounted or unmounted 3436 * @deprecated replaced by android.os.storage.StorageEventListener 3437 */ 3438 @Deprecated 3439 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3440 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED"; 3441 3442 /** 3443 * Broadcast Action: The device has exited USB Mass Storage mode. 3444 * This is used mainly for the USB Settings panel. 3445 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified 3446 * when the SD card file system is mounted or unmounted 3447 * @deprecated replaced by android.os.storage.StorageEventListener 3448 */ 3449 @Deprecated 3450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3451 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED"; 3452 3453 /** 3454 * Broadcast Action: External media has been removed. 3455 * The path to the mount point for the removed media is contained in the Intent.mData field. 3456 */ 3457 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3458 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED"; 3459 3460 /** 3461 * Broadcast Action: External media is present, but not mounted at its mount point. 3462 * The path to the mount point for the unmounted media is contained in the Intent.mData field. 3463 */ 3464 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3465 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED"; 3466 3467 /** 3468 * Broadcast Action: External media is present, and being disk-checked 3469 * The path to the mount point for the checking media is contained in the Intent.mData field. 3470 */ 3471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3472 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING"; 3473 3474 /** 3475 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank) 3476 * The path to the mount point for the checking media is contained in the Intent.mData field. 3477 */ 3478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3479 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS"; 3480 3481 /** 3482 * Broadcast Action: External media is present and mounted at its mount point. 3483 * The path to the mount point for the mounted media is contained in the Intent.mData field. 3484 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the 3485 * media was mounted read only. 3486 */ 3487 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3488 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED"; 3489 3490 /** 3491 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage. 3492 * The path to the mount point for the shared media is contained in the Intent.mData field. 3493 */ 3494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3495 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED"; 3496 3497 /** 3498 * Broadcast Action: External media is no longer being shared via USB mass storage. 3499 * The path to the mount point for the previously shared media is contained in the Intent.mData field. 3500 * 3501 * @hide 3502 */ 3503 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED"; 3504 3505 /** 3506 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted. 3507 * The path to the mount point for the removed media is contained in the Intent.mData field. 3508 */ 3509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3510 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL"; 3511 3512 /** 3513 * Broadcast Action: External media is present but cannot be mounted. 3514 * The path to the mount point for the unmountable media is contained in the Intent.mData field. 3515 */ 3516 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3517 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE"; 3518 3519 /** 3520 * Broadcast Action: User has expressed the desire to remove the external storage media. 3521 * Applications should close all files they have open within the mount point when they receive this intent. 3522 * The path to the mount point for the media to be ejected is contained in the Intent.mData field. 3523 */ 3524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3525 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT"; 3526 3527 /** 3528 * Broadcast Action: The media scanner has started scanning a directory. 3529 * The path to the directory being scanned is contained in the Intent.mData field. 3530 */ 3531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3532 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED"; 3533 3534 /** 3535 * Broadcast Action: The media scanner has finished scanning a directory. 3536 * The path to the scanned directory is contained in the Intent.mData field. 3537 */ 3538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3539 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED"; 3540 3541 /** 3542 * Broadcast Action: Request the media scanner to scan a file and add it to 3543 * the media database. 3544 * <p> 3545 * The path to the file is contained in {@link Intent#getData()}. 3546 * 3547 * @deprecated Callers should migrate to inserting items directly into 3548 * {@link MediaStore}, where they will be automatically scanned 3549 * after each mutation. 3550 */ 3551 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3552 @Deprecated 3553 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE"; 3554 3555 /** 3556 * Broadcast Action: The "Media Button" was pressed. Includes a single 3557 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3558 * caused the broadcast. 3559 */ 3560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3561 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON"; 3562 3563 /** 3564 * Broadcast Action: The "Camera Button" was pressed. Includes a single 3565 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 3566 * caused the broadcast. 3567 */ 3568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3569 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON"; 3570 3571 // *** NOTE: @todo(*) The following really should go into a more domain-specific 3572 // location; they are not general-purpose actions. 3573 3574 /** 3575 * Broadcast Action: A GTalk connection has been established. 3576 */ 3577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3578 public static final String ACTION_GTALK_SERVICE_CONNECTED = 3579 "android.intent.action.GTALK_CONNECTED"; 3580 3581 /** 3582 * Broadcast Action: A GTalk connection has been disconnected. 3583 */ 3584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3585 public static final String ACTION_GTALK_SERVICE_DISCONNECTED = 3586 "android.intent.action.GTALK_DISCONNECTED"; 3587 3588 /** 3589 * Broadcast Action: An input method has been changed. 3590 */ 3591 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3592 public static final String ACTION_INPUT_METHOD_CHANGED = 3593 "android.intent.action.INPUT_METHOD_CHANGED"; 3594 3595 /** 3596 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or 3597 * more radios have been turned off or on. The intent will have the following extra value:</p> 3598 * <ul> 3599 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true, 3600 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been 3601 * turned off</li> 3602 * </ul> 3603 * 3604 * <p class="note">This is a protected intent that can only be sent by the system.</p> 3605 */ 3606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3607 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE"; 3608 3609 /** 3610 * Broadcast Action: Some content providers have parts of their namespace 3611 * where they publish new events or items that the user may be especially 3612 * interested in. For these things, they may broadcast this action when the 3613 * set of interesting items change. 3614 * 3615 * For example, GmailProvider sends this notification when the set of unread 3616 * mail in the inbox changes. 3617 * 3618 * <p>The data of the intent identifies which part of which provider 3619 * changed. When queried through the content resolver, the data URI will 3620 * return the data set in question. 3621 * 3622 * <p>The intent will have the following extra values: 3623 * <ul> 3624 * <li><em>count</em> - The number of items in the data set. This is the 3625 * same as the number of items in the cursor returned by querying the 3626 * data URI. </li> 3627 * </ul> 3628 * 3629 * This intent will be sent at boot (if the count is non-zero) and when the 3630 * data set changes. It is possible for the data set to change without the 3631 * count changing (for example, if a new unread message arrives in the same 3632 * sync operation in which a message is archived). The phone should still 3633 * ring/vibrate/etc as normal in this case. 3634 */ 3635 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3636 public static final String ACTION_PROVIDER_CHANGED = 3637 "android.intent.action.PROVIDER_CHANGED"; 3638 3639 /** 3640 * Broadcast Action: Wired Headset plugged in or unplugged. 3641 * 3642 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value 3643 * and documentation. 3644 * <p>If the minimum SDK version of your application is 3645 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer 3646 * to the <code>AudioManager</code> constant in your receiver registration code instead. 3647 */ 3648 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3649 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG; 3650 3651 /** 3652 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p> 3653 * <ul> 3654 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li> 3655 * </ul> 3656 * 3657 * <p class="note">This is a protected intent that can only be sent 3658 * by the system. 3659 * 3660 * @hide 3661 */ 3662 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3663 public static final String ACTION_ADVANCED_SETTINGS_CHANGED 3664 = "android.intent.action.ADVANCED_SETTINGS"; 3665 3666 /** 3667 * Broadcast Action: Sent after application restrictions are changed. 3668 * 3669 * <p class="note">This is a protected intent that can only be sent 3670 * by the system.</p> 3671 */ 3672 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3673 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED = 3674 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED"; 3675 3676 /** 3677 * Broadcast Action: An outgoing call is about to be placed. 3678 * 3679 * <p>The Intent will have the following extra value:</p> 3680 * <ul> 3681 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> - 3682 * the phone number originally intended to be dialed.</li> 3683 * </ul> 3684 * <p>Once the broadcast is finished, the resultData is used as the actual 3685 * number to call. If <code>null</code>, no call will be placed.</p> 3686 * <p>It is perfectly acceptable for multiple receivers to process the 3687 * outgoing call in turn: for example, a parental control application 3688 * might verify that the user is authorized to place the call at that 3689 * time, then a number-rewriting application might add an area code if 3690 * one was not specified.</p> 3691 * <p>For consistency, any receiver whose purpose is to prohibit phone 3692 * calls should have a priority of 0, to ensure it will see the final 3693 * phone number to be dialed. 3694 * Any receiver whose purpose is to rewrite phone numbers to be called 3695 * should have a positive priority. 3696 * Negative priorities are reserved for the system for this broadcast; 3697 * using them may cause problems.</p> 3698 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em> 3699 * abort the broadcast.</p> 3700 * <p>Emergency calls cannot be intercepted using this mechanism, and 3701 * other calls cannot be modified to call emergency numbers using this 3702 * mechanism. 3703 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing 3704 * call to use their own service instead. Those apps should first prevent 3705 * the call from being placed by setting resultData to <code>null</code> 3706 * and then start their own app to make the call. 3707 * <p>You must hold the 3708 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS} 3709 * permission to receive this Intent.</p> 3710 * 3711 * <p class="note">This is a protected intent that can only be sent 3712 * by the system. 3713 * 3714 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to 3715 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast. 3716 * This means that attempts to re-write the outgoing call by other apps using this intent will 3717 * be ignored. 3718 * </p> 3719 * 3720 * @deprecated Apps that redirect outgoing calls should use the 3721 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening 3722 * should use the {@link android.telecom.CallScreeningService} API. Apps which need to be 3723 * notified of basic call state should use 3724 * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine 3725 * when a new outgoing call is placed. 3726 */ 3727 @Deprecated 3728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3729 public static final String ACTION_NEW_OUTGOING_CALL = 3730 "android.intent.action.NEW_OUTGOING_CALL"; 3731 3732 /** 3733 * Broadcast Action: Have the device reboot. This is only for use by 3734 * system code. 3735 * 3736 * <p class="note">This is a protected intent that can only be sent 3737 * by the system. 3738 */ 3739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3740 public static final String ACTION_REBOOT = 3741 "android.intent.action.REBOOT"; 3742 3743 /** 3744 * Broadcast Action: A sticky broadcast for changes in the physical 3745 * docking state of the device. 3746 * 3747 * <p>The intent will have the following extra values: 3748 * <ul> 3749 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock 3750 * state, indicating which dock the device is physically in.</li> 3751 * </ul> 3752 * <p>This is intended for monitoring the current physical dock state. 3753 * See {@link android.app.UiModeManager} for the normal API dealing with 3754 * dock mode changes. 3755 */ 3756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3757 public static final String ACTION_DOCK_EVENT = 3758 "android.intent.action.DOCK_EVENT"; 3759 3760 /** 3761 * Broadcast Action: A broadcast when idle maintenance can be started. 3762 * This means that the user is not interacting with the device and is 3763 * not expected to do so soon. Typical use of the idle maintenance is 3764 * to perform somehow expensive tasks that can be postponed at a moment 3765 * when they will not degrade user experience. 3766 * <p> 3767 * <p class="note">In order to keep the device responsive in case of an 3768 * unexpected user interaction, implementations of a maintenance task 3769 * should be interruptible. In such a scenario a broadcast with action 3770 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you 3771 * should not do the maintenance work in 3772 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a 3773 * maintenance service by {@link Context#startService(Intent)}. Also 3774 * you should hold a wake lock while your maintenance service is running 3775 * to prevent the device going to sleep. 3776 * </p> 3777 * <p> 3778 * <p class="note">This is a protected intent that can only be sent by 3779 * the system. 3780 * </p> 3781 * 3782 * @see #ACTION_IDLE_MAINTENANCE_END 3783 * 3784 * @hide 3785 */ 3786 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3787 public static final String ACTION_IDLE_MAINTENANCE_START = 3788 "android.intent.action.ACTION_IDLE_MAINTENANCE_START"; 3789 3790 /** 3791 * Broadcast Action: A broadcast when idle maintenance should be stopped. 3792 * This means that the user was not interacting with the device as a result 3793 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START} 3794 * was sent and now the user started interacting with the device. Typical 3795 * use of the idle maintenance is to perform somehow expensive tasks that 3796 * can be postponed at a moment when they will not degrade user experience. 3797 * <p> 3798 * <p class="note">In order to keep the device responsive in case of an 3799 * unexpected user interaction, implementations of a maintenance task 3800 * should be interruptible. Hence, on receiving a broadcast with this 3801 * action, the maintenance task should be interrupted as soon as possible. 3802 * In other words, you should not do the maintenance work in 3803 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the 3804 * maintenance service that was started on receiving of 3805 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake 3806 * lock you acquired when your maintenance service started. 3807 * </p> 3808 * <p class="note">This is a protected intent that can only be sent 3809 * by the system. 3810 * 3811 * @see #ACTION_IDLE_MAINTENANCE_START 3812 * 3813 * @hide 3814 */ 3815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 3816 public static final String ACTION_IDLE_MAINTENANCE_END = 3817 "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; 3818 3819 /** 3820 * Broadcast Action: a remote intent is to be broadcasted. 3821 * 3822 * A remote intent is used for remote RPC between devices. The remote intent 3823 * is serialized and sent from one device to another device. The receiving 3824 * device parses the remote intent and broadcasts it. Note that anyone can 3825 * broadcast a remote intent. However, if the intent receiver of the remote intent 3826 * does not trust intent broadcasts from arbitrary intent senders, it should require 3827 * the sender to hold certain permissions so only trusted sender's broadcast will be 3828 * let through. 3829 * @hide 3830 */ 3831 public static final String ACTION_REMOTE_INTENT = 3832 "com.google.android.c2dm.intent.RECEIVE"; 3833 3834 /** 3835 * Broadcast Action: This is broadcast once when the user is booting after a 3836 * system update. It can be used to perform cleanup or upgrades after a 3837 * system update. 3838 * <p> 3839 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED} 3840 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's 3841 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only 3842 * sent to receivers in the system image. 3843 * 3844 * @hide 3845 */ 3846 @SystemApi 3847 public static final String ACTION_PRE_BOOT_COMPLETED = 3848 "android.intent.action.PRE_BOOT_COMPLETED"; 3849 3850 /** 3851 * Broadcast to a specific application to query any supported restrictions to impose 3852 * on restricted users. The broadcast intent contains an extra 3853 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted 3854 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or 3855 * String[] depending on the restriction type.<p/> 3856 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST}, 3857 * which is of type <code>ArrayList<RestrictionEntry></code>. It can also 3858 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>. 3859 * The activity specified by that intent will be launched for a result which must contain 3860 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}. 3861 * The keys and values of the returned restrictions will be persisted. 3862 * @see RestrictionEntry 3863 */ 3864 public static final String ACTION_GET_RESTRICTION_ENTRIES = 3865 "android.intent.action.GET_RESTRICTION_ENTRIES"; 3866 3867 /** 3868 * Sent the first time a user is starting, to allow system apps to 3869 * perform one time initialization. (This will not be seen by third 3870 * party applications because a newly initialized user does not have any 3871 * third party applications installed for it.) This is sent early in 3872 * starting the user, around the time the home app is started, before 3873 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground 3874 * broadcast, since it is part of a visible user interaction; be as quick 3875 * as possible when handling it. 3876 */ 3877 public static final String ACTION_USER_INITIALIZE = 3878 "android.intent.action.USER_INITIALIZE"; 3879 3880 /** 3881 * Sent when a user switch is happening, causing the process's user to be 3882 * brought to the foreground. This is only sent to receivers registered 3883 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3884 * Context.registerReceiver}. It is sent to the user that is going to the 3885 * foreground. This is sent as a foreground 3886 * broadcast, since it is part of a visible user interaction; be as quick 3887 * as possible when handling it. 3888 */ 3889 public static final String ACTION_USER_FOREGROUND = 3890 "android.intent.action.USER_FOREGROUND"; 3891 3892 /** 3893 * Sent when a user switch is happening, causing the process's user to be 3894 * sent to the background. This is only sent to receivers registered 3895 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter) 3896 * Context.registerReceiver}. It is sent to the user that is going to the 3897 * background. This is sent as a foreground 3898 * broadcast, since it is part of a visible user interaction; be as quick 3899 * as possible when handling it. 3900 */ 3901 public static final String ACTION_USER_BACKGROUND = 3902 "android.intent.action.USER_BACKGROUND"; 3903 3904 /** 3905 * Broadcast sent to the system when a user is added. 3906 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the new user 3907 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 3908 * user's user ID). 3909 * It is sent to all running users. 3910 * You must hold {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 3911 * @hide 3912 */ 3913 @SystemApi 3914 public static final String ACTION_USER_ADDED = 3915 "android.intent.action.USER_ADDED"; 3916 3917 /** 3918 * Broadcast sent by the system when a user is started. Carries an extra 3919 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only sent to 3920 * registered receivers, not manifest receivers. It is sent to the user 3921 * that has been started. This is sent as a foreground 3922 * broadcast, since it is part of a visible user interaction; be as quick 3923 * as possible when handling it. 3924 * 3925 * <p> 3926 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 3927 * received. For example, the user could have been removed, started or stopped already, 3928 * regardless of which broadcast you receive. Because of that, receivers should always check 3929 * the current state of the user. 3930 * @hide 3931 */ 3932 public static final String ACTION_USER_STARTED = 3933 "android.intent.action.USER_STARTED"; 3934 3935 /** 3936 * Broadcast sent when a user is in the process of starting. Carries an extra 3937 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only 3938 * sent to registered receivers, not manifest receivers. It is sent to all 3939 * users (including the one that is being started). You must hold 3940 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3941 * this broadcast. This is sent as a background broadcast, since 3942 * its result is not part of the primary UX flow; to safely keep track of 3943 * started/stopped state of a user you can use this in conjunction with 3944 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with 3945 * other user state broadcasts since those are foreground broadcasts so can 3946 * execute in a different order. 3947 * 3948 * <p> 3949 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 3950 * received. For example, the user could have been removed, started or stopped already, 3951 * regardless of which broadcast you receive. Because of that, receivers should always check 3952 * the current state of the user. 3953 * @hide 3954 */ 3955 public static final String ACTION_USER_STARTING = 3956 "android.intent.action.USER_STARTING"; 3957 3958 /** 3959 * Broadcast sent when a user is going to be stopped. Carries an extra 3960 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is only 3961 * sent to registered receivers, not manifest receivers. It is sent to all 3962 * users (including the one that is being stopped). You must hold 3963 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive 3964 * this broadcast. The user will not stop until all receivers have 3965 * handled the broadcast. This is sent as a background broadcast, since 3966 * its result is not part of the primary UX flow; to safely keep track of 3967 * started/stopped state of a user you can use this in conjunction with 3968 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with 3969 * other user state broadcasts since those are foreground broadcasts so can 3970 * execute in a different order. 3971 * <p> 3972 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 3973 * received. For example, the user could have been removed, started or stopped already, 3974 * regardless of which broadcast you receive. Because of that, receivers should always check 3975 * the current state of the user. 3976 * @hide 3977 */ 3978 public static final String ACTION_USER_STOPPING = 3979 "android.intent.action.USER_STOPPING"; 3980 3981 /** 3982 * Broadcast sent to the system when a user is stopped. Carries an extra 3983 * {@link #EXTRA_USER_HANDLE} that has the user ID of the user. This is similar to 3984 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a 3985 * specific package. This is only sent to registered receivers, not manifest 3986 * receivers. It is sent to all running users <em>except</em> the one that 3987 * has just been stopped (which is no longer running). 3988 * 3989 * <p> 3990 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 3991 * received. For example, the user could have been removed, started or stopped already, 3992 * regardless of which broadcast you receive. Because of that, receivers should always check 3993 * the current state of the user. 3994 * @hide 3995 */ 3996 @TestApi 3997 public static final String ACTION_USER_STOPPED = 3998 "android.intent.action.USER_STOPPED"; 3999 4000 /** 4001 * Broadcast sent to the system when a user is removed. 4002 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the user that 4003 * was removed 4004 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 4005 * user's user ID). 4006 * It is sent to all running users except the 4007 * one that has been removed. The user will not be completely removed until all receivers have 4008 * handled the broadcast. You must hold 4009 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 4010 * @hide 4011 */ 4012 @SystemApi 4013 public static final String ACTION_USER_REMOVED = 4014 "android.intent.action.USER_REMOVED"; 4015 4016 /** 4017 * Broadcast sent to the system when the user switches. 4018 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} 4019 * of the user to become the current one 4020 * (and for legacy reasons, also carries an int extra {@link #EXTRA_USER_HANDLE} specifying that 4021 * user's user ID). 4022 * This is only sent to registered receivers, not manifest receivers. 4023 * It is sent to all running users. 4024 * You must hold 4025 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast. 4026 * 4027 * <p> 4028 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4029 * received. For example, the user could have been removed, started or stopped already, 4030 * regardless of which broadcast you receive. Because of that, receivers should always check 4031 * the current state of the user. 4032 * @hide 4033 */ 4034 @SystemApi 4035 public static final String ACTION_USER_SWITCHED = 4036 "android.intent.action.USER_SWITCHED"; 4037 4038 /** 4039 * Broadcast Action: Sent when the credential-encrypted private storage has 4040 * become unlocked for the target user. This is only sent to registered 4041 * receivers, not manifest receivers. 4042 * 4043 * <p> 4044 * <b>Note:</b> The user's actual state might have changed by the time the broadcast is 4045 * received. For example, the user could have been removed, started or stopped already, 4046 * regardless of which broadcast you receive. Because of that, receivers should always check 4047 * the current state of the user. 4048 */ 4049 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4050 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED"; 4051 4052 /** 4053 * Broadcast sent to the system when a user's information changes. Carries an extra 4054 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed. 4055 * This is only sent to registered receivers, not manifest receivers. It is sent to all users. 4056 * @hide 4057 */ 4058 public static final String ACTION_USER_INFO_CHANGED = 4059 "android.intent.action.USER_INFO_CHANGED"; 4060 4061 /** 4062 * Broadcast sent to the primary user when an associated managed profile is added (the profile 4063 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies 4064 * the {@link UserHandle} of the profile that was added. Only applications (for example 4065 * Launchers) that need to display merged content across both primary and managed profiles need 4066 * to worry about this broadcast. This is only sent to registered receivers, 4067 * not manifest receivers. 4068 */ 4069 public static final String ACTION_MANAGED_PROFILE_ADDED = 4070 "android.intent.action.MANAGED_PROFILE_ADDED"; 4071 4072 /** 4073 * Broadcast sent to the primary user when an associated managed profile is removed. 4074 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile 4075 * that was removed. 4076 * Only applications (for example Launchers) that need to display merged content across both 4077 * primary and managed profiles need to worry about this broadcast. This is only sent to 4078 * registered receivers, not manifest receivers. 4079 */ 4080 public static final String ACTION_MANAGED_PROFILE_REMOVED = 4081 "android.intent.action.MANAGED_PROFILE_REMOVED"; 4082 4083 /** 4084 * Broadcast sent to the primary user when the credential-encrypted private storage for 4085 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that 4086 * specifies the {@link UserHandle} of the profile that was unlocked. Only applications (for 4087 * example Launchers) that need to display merged content across both primary and managed 4088 * profiles need to worry about this broadcast. This is only sent to registered receivers, 4089 * not manifest receivers. 4090 */ 4091 public static final String ACTION_MANAGED_PROFILE_UNLOCKED = 4092 "android.intent.action.MANAGED_PROFILE_UNLOCKED"; 4093 4094 /** 4095 * Broadcast sent to the primary user when an associated managed profile has become available. 4096 * Currently this includes when the user disables quiet mode for the profile. Carries an extra 4097 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4098 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4099 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4100 */ 4101 public static final String ACTION_MANAGED_PROFILE_AVAILABLE = 4102 "android.intent.action.MANAGED_PROFILE_AVAILABLE"; 4103 4104 /** 4105 * Broadcast sent to the primary user when an associated managed profile has become unavailable. 4106 * Currently this includes when the user enables quiet mode for the profile. Carries an extra 4107 * {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. When quiet mode is 4108 * changed, this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the 4109 * new state of quiet mode. This is only sent to registered receivers, not manifest receivers. 4110 */ 4111 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE = 4112 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE"; 4113 4114 /** 4115 * Broadcast sent to the parent user when an associated profile has been started and unlocked. 4116 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 4117 * This is only sent to registered receivers, not manifest receivers. 4118 */ 4119 public static final String ACTION_PROFILE_ACCESSIBLE = 4120 "android.intent.action.PROFILE_ACCESSIBLE"; 4121 4122 /** 4123 * Broadcast sent to the parent user when an associated profile has stopped. 4124 * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile. 4125 * This is only sent to registered receivers, not manifest receivers. 4126 */ 4127 public static final String ACTION_PROFILE_INACCESSIBLE = 4128 "android.intent.action.PROFILE_INACCESSIBLE"; 4129 4130 /** 4131 * Broadcast sent to the system user when the 'device locked' state changes for any user. 4132 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which 4133 * the device was locked or unlocked. 4134 * 4135 * This is only sent to registered receivers. 4136 * 4137 * @hide 4138 */ 4139 public static final String ACTION_DEVICE_LOCKED_CHANGED = 4140 "android.intent.action.DEVICE_LOCKED_CHANGED"; 4141 4142 /** 4143 * Sent when the user taps on the clock widget in the system's "quick settings" area. 4144 */ 4145 public static final String ACTION_QUICK_CLOCK = 4146 "android.intent.action.QUICK_CLOCK"; 4147 4148 /** 4149 * Activity Action: Shows the brightness setting dialog. 4150 * @hide 4151 */ 4152 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = 4153 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG"; 4154 4155 /** 4156 * Broadcast Action: A global button was pressed. Includes a single 4157 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that 4158 * caused the broadcast. 4159 * @hide 4160 */ 4161 @SystemApi 4162 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON"; 4163 4164 /** 4165 * Broadcast Action: Sent when media resource is granted. 4166 * <p> 4167 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource 4168 * granted. 4169 * </p> 4170 * <p class="note"> 4171 * This is a protected intent that can only be sent by the system. 4172 * </p> 4173 * <p class="note"> 4174 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission. 4175 * </p> 4176 * 4177 * @hide 4178 */ 4179 public static final String ACTION_MEDIA_RESOURCE_GRANTED = 4180 "android.intent.action.MEDIA_RESOURCE_GRANTED"; 4181 4182 /** 4183 * Broadcast Action: An overlay package has changed. The data contains the 4184 * name of the overlay package which has changed. This is broadcast on all 4185 * changes to the OverlayInfo returned by {@link 4186 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The 4187 * most common change is a state change that will change whether the 4188 * overlay is enabled or not. 4189 * @hide 4190 */ 4191 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED"; 4192 4193 /** 4194 * Activity Action: Allow the user to select and return one or more existing 4195 * documents. When invoked, the system will display the various 4196 * {@link DocumentsProvider} instances installed on the device, letting the 4197 * user interactively navigate through them. These documents include local 4198 * media, such as photos and video, and documents provided by installed 4199 * cloud storage providers. 4200 * <p> 4201 * Each document is represented as a {@code content://} URI backed by a 4202 * {@link DocumentsProvider}, which can be opened as a stream with 4203 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 4204 * {@link android.provider.DocumentsContract.Document} metadata. 4205 * <p> 4206 * All selected documents are returned to the calling application with 4207 * persistable read and write permission grants. If you want to maintain 4208 * access to the documents across device reboots, you need to explicitly 4209 * take the persistable permissions using 4210 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}. 4211 * <p> 4212 * Callers must indicate the acceptable document MIME types through 4213 * {@link #setType(String)}. For example, to select photos, use 4214 * {@code image/*}. If multiple disjoint MIME types are acceptable, define 4215 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to 4216 * {@literal *}/*. 4217 * <p> 4218 * If the caller can handle multiple returned items (the user performing 4219 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE} 4220 * to indicate this. 4221 * <p> 4222 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4223 * URIs that can be opened with 4224 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4225 * <p> 4226 * Callers can set a document URI through 4227 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4228 * location of documents navigator. System will do its best to launch the 4229 * navigator in the specified document if it's a folder, or the folder that 4230 * contains the specified document if not. 4231 * <p> 4232 * Output: The URI of the item that was picked, returned in 4233 * {@link #getData()}. This must be a {@code content://} URI so that any 4234 * receiver can access it. If multiple documents were selected, they are 4235 * returned in {@link #getClipData()}. 4236 * 4237 * @see DocumentsContract 4238 * @see #ACTION_OPEN_DOCUMENT_TREE 4239 * @see #ACTION_CREATE_DOCUMENT 4240 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4241 */ 4242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4243 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT"; 4244 4245 /** 4246 * Activity Action: Allow the user to create a new document. When invoked, 4247 * the system will display the various {@link DocumentsProvider} instances 4248 * installed on the device, letting the user navigate through them. The 4249 * returned document may be a newly created document with no content, or it 4250 * may be an existing document with the requested MIME type. 4251 * <p> 4252 * Each document is represented as a {@code content://} URI backed by a 4253 * {@link DocumentsProvider}, which can be opened as a stream with 4254 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for 4255 * {@link android.provider.DocumentsContract.Document} metadata. 4256 * <p> 4257 * Callers must indicate the concrete MIME type of the document being 4258 * created by setting {@link #setType(String)}. This MIME type cannot be 4259 * changed after the document is created. 4260 * <p> 4261 * Callers can provide an initial display name through {@link #EXTRA_TITLE}, 4262 * but the user may change this value before creating the file. 4263 * <p> 4264 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain 4265 * URIs that can be opened with 4266 * {@link ContentResolver#openFileDescriptor(Uri, String)}. 4267 * <p> 4268 * Callers can set a document URI through 4269 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4270 * location of documents navigator. System will do its best to launch the 4271 * navigator in the specified document if it's a folder, or the folder that 4272 * contains the specified document if not. 4273 * <p> 4274 * Output: The URI of the item that was created. This must be a 4275 * {@code content://} URI so that any receiver can access it. 4276 * 4277 * @see DocumentsContract 4278 * @see #ACTION_OPEN_DOCUMENT 4279 * @see #ACTION_OPEN_DOCUMENT_TREE 4280 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION 4281 */ 4282 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4283 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT"; 4284 4285 /** 4286 * Activity Action: Allow the user to pick a directory subtree. When 4287 * invoked, the system will display the various {@link DocumentsProvider} 4288 * instances installed on the device, letting the user navigate through 4289 * them. Apps can fully manage documents within the returned directory. 4290 * <p> 4291 * To gain access to descendant (child, grandchild, etc) documents, use 4292 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and 4293 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)} 4294 * with the returned URI. 4295 * <p> 4296 * Callers can set a document URI through 4297 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial 4298 * location of documents navigator. System will do its best to launch the 4299 * navigator in the specified document if it's a folder, or the folder that 4300 * contains the specified document if not. 4301 * <p> 4302 * Output: The URI representing the selected directory tree. 4303 * 4304 * @see DocumentsContract 4305 */ 4306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4307 public static final String 4308 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE"; 4309 4310 4311 /** 4312 * Activity Action: Perform text translation. 4313 * <p> 4314 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate. 4315 * <p> 4316 * Output: nothing. 4317 */ 4318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4319 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE"; 4320 4321 /** 4322 * Activity Action: Define the meaning of the selected word(s). 4323 * <p> 4324 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define. 4325 * <p> 4326 * Output: nothing. 4327 */ 4328 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4329 public static final String ACTION_DEFINE = "android.intent.action.DEFINE"; 4330 4331 /** 4332 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or 4333 * exisiting sensor being disconnected. 4334 * 4335 * <p class="note">This is a protected intent that can only be sent by the system.</p> 4336 * 4337 * {@hide} 4338 */ 4339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4340 public static final String 4341 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED"; 4342 4343 /** 4344 * Deprecated - use ACTION_FACTORY_RESET instead. 4345 * @hide 4346 * @removed 4347 */ 4348 @Deprecated 4349 @SystemApi 4350 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR"; 4351 4352 /** 4353 * Broadcast intent sent by the RecoverySystem to inform listeners that a global clear (wipe) 4354 * is about to be performed. 4355 * @hide 4356 */ 4357 @SystemApi 4358 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4359 public static final String ACTION_MASTER_CLEAR_NOTIFICATION 4360 = "android.intent.action.MASTER_CLEAR_NOTIFICATION"; 4361 4362 /** 4363 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4364 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4365 * 4366 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead. 4367 * 4368 * @hide 4369 */ 4370 @Deprecated 4371 public static final String EXTRA_FORCE_MASTER_CLEAR = 4372 "android.intent.extra.FORCE_MASTER_CLEAR"; 4373 4374 /** 4375 * A broadcast action to trigger a factory reset. 4376 * 4377 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The 4378 * reason for the factory reset should be specified as {@link #EXTRA_REASON}. 4379 * 4380 * <p>Not for use by third-party applications. 4381 * 4382 * @see #EXTRA_FORCE_FACTORY_RESET 4383 * 4384 * {@hide} 4385 */ 4386 @SystemApi 4387 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4388 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET"; 4389 4390 /** 4391 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory 4392 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set. 4393 * 4394 * <p>Not for use by third-party applications. 4395 * 4396 * @hide 4397 */ 4398 @SystemApi 4399 public static final String EXTRA_FORCE_FACTORY_RESET = 4400 "android.intent.extra.FORCE_FACTORY_RESET"; 4401 4402 /** 4403 * Broadcast action: report that a settings element is being restored from backup. The intent 4404 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting, 4405 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE 4406 * is the value of that settings entry prior to the restore operation, and 4407 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been 4408 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three 4409 * values are represented as strings, the fourth one as int. 4410 * 4411 * <p>This broadcast is sent only for settings provider entries known to require special 4412 * handling around restore time to specific receivers. These entries are found in the 4413 * BROADCAST_ON_RESTORE table within the provider's backup agent implementation. 4414 * 4415 * @see #EXTRA_SETTING_NAME 4416 * @see #EXTRA_SETTING_PREVIOUS_VALUE 4417 * @see #EXTRA_SETTING_NEW_VALUE 4418 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT 4419 * {@hide} 4420 */ 4421 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4422 @SuppressLint("ActionValue") 4423 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED"; 4424 4425 /** 4426 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4427 * Contain the name of the restored setting. 4428 * {@hide} 4429 */ 4430 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4431 @SuppressLint("ActionValue") 4432 public static final String EXTRA_SETTING_NAME = "setting_name"; 4433 4434 /** 4435 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4436 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry prior to the restore 4437 * operation. 4438 * {@hide} 4439 */ 4440 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4441 @SuppressLint("ActionValue") 4442 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value"; 4443 4444 /** 4445 * String intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4446 * Contain the value of the {@link EXTRA_SETTING_NAME} settings entry being restored. 4447 * {@hide} 4448 */ 4449 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4450 @SuppressLint("ActionValue") 4451 public static final String EXTRA_SETTING_NEW_VALUE = "new_value"; 4452 4453 /** 4454 * Int intent extra to be used with {@link ACTION_SETTING_RESTORED}. 4455 * Contain the version of the SDK that the setting has been restored from (corresponds to 4456 * {@link android.os.Build.VERSION#SDK_INT}). 4457 * {@hide} 4458 */ 4459 @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) 4460 @SuppressLint("ActionValue") 4461 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int"; 4462 4463 /** 4464 * Activity Action: Process a piece of text. 4465 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed. 4466 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p> 4467 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p> 4468 */ 4469 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4470 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT"; 4471 4472 /** 4473 * Broadcast Action: The sim card state has changed. 4474 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here 4475 * because TelephonyIntents is an internal class. 4476 * The intent will have following extras.</p> 4477 * <p> 4478 * @see #EXTRA_SIM_STATE 4479 * @see #EXTRA_SIM_LOCKED_REASON 4480 * @see #EXTRA_REBROADCAST_ON_UNLOCK 4481 * 4482 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or 4483 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4484 * 4485 * @hide 4486 */ 4487 @Deprecated 4488 @SystemApi 4489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 4490 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED"; 4491 4492 /** 4493 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4494 * This will have one of the following intent values. 4495 * @see #SIM_STATE_UNKNOWN 4496 * @see #SIM_STATE_NOT_READY 4497 * @see #SIM_STATE_ABSENT 4498 * @see #SIM_STATE_PRESENT 4499 * @see #SIM_STATE_CARD_IO_ERROR 4500 * @see #SIM_STATE_CARD_RESTRICTED 4501 * @see #SIM_STATE_LOCKED 4502 * @see #SIM_STATE_READY 4503 * @see #SIM_STATE_IMSI 4504 * @see #SIM_STATE_LOADED 4505 * @hide 4506 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4507 */ 4508 public static final String EXTRA_SIM_STATE = "ss"; 4509 4510 /** 4511 * The intent value UNKNOWN represents the SIM state unknown 4512 * @hide 4513 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4514 */ 4515 public static final String SIM_STATE_UNKNOWN = "UNKNOWN"; 4516 4517 /** 4518 * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on 4519 * @hide 4520 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4521 */ 4522 public static final String SIM_STATE_NOT_READY = "NOT_READY"; 4523 4524 /** 4525 * The intent value ABSENT means the SIM card is missing 4526 * @hide 4527 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4528 */ 4529 public static final String SIM_STATE_ABSENT = "ABSENT"; 4530 4531 /** 4532 * The intent value PRESENT means the device has a SIM card inserted 4533 * @hide 4534 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4535 */ 4536 public static final String SIM_STATE_PRESENT = "PRESENT"; 4537 4538 /** 4539 * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error 4540 * @hide 4541 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4542 */ 4543 static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR"; 4544 4545 /** 4546 * The intent value CARD_RESTRICTED means card is present but not usable due to carrier 4547 * restrictions 4548 * @hide 4549 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4550 */ 4551 static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED"; 4552 4553 /** 4554 * The intent value LOCKED means the SIM is locked by PIN or by network 4555 * @hide 4556 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4557 */ 4558 public static final String SIM_STATE_LOCKED = "LOCKED"; 4559 4560 /** 4561 * The intent value READY means the SIM is ready to be accessed 4562 * @hide 4563 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4564 */ 4565 public static final String SIM_STATE_READY = "READY"; 4566 4567 /** 4568 * The intent value IMSI means the SIM IMSI is ready in property 4569 * @hide 4570 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4571 */ 4572 public static final String SIM_STATE_IMSI = "IMSI"; 4573 4574 /** 4575 * The intent value LOADED means all SIM records, including IMSI, are loaded 4576 * @hide 4577 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} 4578 */ 4579 public static final String SIM_STATE_LOADED = "LOADED"; 4580 4581 /** 4582 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE. 4583 * This extra will have one of the following intent values. 4584 * <p> 4585 * @see #SIM_LOCKED_ON_PIN 4586 * @see #SIM_LOCKED_ON_PUK 4587 * @see #SIM_LOCKED_NETWORK 4588 * @see #SIM_ABSENT_ON_PERM_DISABLED 4589 * 4590 * @hide 4591 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4592 */ 4593 public static final String EXTRA_SIM_LOCKED_REASON = "reason"; 4594 4595 /** 4596 * The intent value PIN means the SIM is locked on PIN1 4597 * @hide 4598 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4599 */ 4600 public static final String SIM_LOCKED_ON_PIN = "PIN"; 4601 4602 /** 4603 * The intent value PUK means the SIM is locked on PUK1 4604 * @hide 4605 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4606 */ 4607 /* PUK means ICC is locked on PUK1 */ 4608 public static final String SIM_LOCKED_ON_PUK = "PUK"; 4609 4610 /** 4611 * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION 4612 * @hide 4613 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4614 */ 4615 public static final String SIM_LOCKED_NETWORK = "NETWORK"; 4616 4617 /** 4618 * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails 4619 * @hide 4620 * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4621 */ 4622 public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED"; 4623 4624 /** 4625 * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast 4626 * is a rebroadcast on unlock. Defaults to {@code false} if not specified. 4627 * 4628 * @hide 4629 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or 4630 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED} 4631 */ 4632 public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock"; 4633 4634 /** 4635 * Broadcast Action: indicate that the phone service state has changed. 4636 * The intent will have the following extra values:</p> 4637 * <p> 4638 * @see #EXTRA_VOICE_REG_STATE 4639 * @see #EXTRA_DATA_REG_STATE 4640 * @see #EXTRA_VOICE_ROAMING_TYPE 4641 * @see #EXTRA_DATA_ROAMING_TYPE 4642 * @see #EXTRA_OPERATOR_ALPHA_LONG 4643 * @see #EXTRA_OPERATOR_ALPHA_SHORT 4644 * @see #EXTRA_OPERATOR_NUMERIC 4645 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG 4646 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT 4647 * @see #EXTRA_DATA_OPERATOR_NUMERIC 4648 * @see #EXTRA_MANUAL 4649 * @see #EXTRA_VOICE_RADIO_TECH 4650 * @see #EXTRA_DATA_RADIO_TECH 4651 * @see #EXTRA_CSS_INDICATOR 4652 * @see #EXTRA_NETWORK_ID 4653 * @see #EXTRA_SYSTEM_ID 4654 * @see #EXTRA_CDMA_ROAMING_INDICATOR 4655 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR 4656 * @see #EXTRA_EMERGENCY_ONLY 4657 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION 4658 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION 4659 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST 4660 * 4661 * <p class="note"> 4662 * Requires the READ_PHONE_STATE permission. 4663 * 4664 * <p class="note">This is a protected intent that can only be sent by the system. 4665 * @hide 4666 * @removed 4667 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper 4668 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and 4669 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState 4670 * for a given subscription id and field with a ContentObserver or using JobScheduler. 4671 */ 4672 @Deprecated 4673 @SystemApi 4674 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) 4675 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE"; 4676 4677 /** 4678 * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService} 4679 * for querying Data Loader Service providers. Data loader service providers register this 4680 * intent filter in their manifests, so that they can be looked up and bound to by 4681 * {@code DataLoaderManagerService}. 4682 * 4683 * <p class="note">This is a protected intent that can only be sent by the system. 4684 * 4685 * Data loader service providers must be privileged apps. 4686 * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such 4687 * data loader service provider. 4688 * 4689 * @hide 4690 */ 4691 @SystemApi 4692 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) 4693 public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA"; 4694 4695 /** 4696 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration 4697 * state. 4698 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4699 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4700 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4701 * @see android.telephony.ServiceState#STATE_POWER_OFF 4702 * @hide 4703 * @removed 4704 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}. 4705 */ 4706 @Deprecated 4707 @SystemApi 4708 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState"; 4709 4710 /** 4711 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state. 4712 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY 4713 * @see android.telephony.ServiceState#STATE_IN_SERVICE 4714 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE 4715 * @see android.telephony.ServiceState#STATE_POWER_OFF 4716 * @hide 4717 * @removed 4718 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}. 4719 */ 4720 @Deprecated 4721 @SystemApi 4722 public static final String EXTRA_DATA_REG_STATE = "dataRegState"; 4723 4724 /** 4725 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming 4726 * type. 4727 * @hide 4728 * @removed 4729 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}. 4730 */ 4731 @Deprecated 4732 @SystemApi 4733 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType"; 4734 4735 /** 4736 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming 4737 * type. 4738 * @hide 4739 * @removed 4740 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}. 4741 */ 4742 @Deprecated 4743 @SystemApi 4744 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType"; 4745 4746 /** 4747 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4748 * registered voice operator name in long alphanumeric format. 4749 * {@code null} if the operator name is not known or unregistered. 4750 * @hide 4751 * @removed 4752 * @deprecated Use 4753 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}. 4754 */ 4755 @Deprecated 4756 @SystemApi 4757 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long"; 4758 4759 /** 4760 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4761 * registered voice operator name in short alphanumeric format. 4762 * {@code null} if the operator name is not known or unregistered. 4763 * @hide 4764 * @removed 4765 * @deprecated Use 4766 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}. 4767 */ 4768 @Deprecated 4769 @SystemApi 4770 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short"; 4771 4772 /** 4773 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4774 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile 4775 * network. 4776 * @hide 4777 * @removed 4778 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}. 4779 */ 4780 @Deprecated 4781 @SystemApi 4782 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric"; 4783 4784 /** 4785 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4786 * registered data operator name in long alphanumeric format. 4787 * {@code null} if the operator name is not known or unregistered. 4788 * @hide 4789 * @removed 4790 * @deprecated Use 4791 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}. 4792 */ 4793 @Deprecated 4794 @SystemApi 4795 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long"; 4796 4797 /** 4798 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current 4799 * registered data operator name in short alphanumeric format. 4800 * {@code null} if the operator name is not known or unregistered. 4801 * @hide 4802 * @removed 4803 * @deprecated Use 4804 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}. 4805 */ 4806 @Deprecated 4807 @SystemApi 4808 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short"; 4809 4810 /** 4811 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC 4812 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the 4813 * data operator. 4814 * @hide 4815 * @removed 4816 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}. 4817 */ 4818 @Deprecated 4819 @SystemApi 4820 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric"; 4821 4822 /** 4823 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current 4824 * network selection mode is manual. 4825 * Will be {@code true} if manual mode, {@code false} if automatic mode. 4826 * @hide 4827 * @removed 4828 * @deprecated Use 4829 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}. 4830 */ 4831 @Deprecated 4832 @SystemApi 4833 public static final String EXTRA_MANUAL = "manual"; 4834 4835 /** 4836 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice 4837 * radio technology. 4838 * @hide 4839 * @removed 4840 * @deprecated Use 4841 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}. 4842 */ 4843 @Deprecated 4844 @SystemApi 4845 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology"; 4846 4847 /** 4848 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data 4849 * radio technology. 4850 * @hide 4851 * @removed 4852 * @deprecated Use 4853 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}. 4854 */ 4855 @Deprecated 4856 @SystemApi 4857 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology"; 4858 4859 /** 4860 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service 4861 * support on CDMA network. 4862 * Will be {@code true} if support, {@code false} otherwise. 4863 * @hide 4864 * @removed 4865 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}. 4866 */ 4867 @Deprecated 4868 @SystemApi 4869 public static final String EXTRA_CSS_INDICATOR = "cssIndicator"; 4870 4871 /** 4872 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network 4873 * id. {@code Integer.MAX_VALUE} if unknown. 4874 * @hide 4875 * @removed 4876 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}. 4877 */ 4878 @Deprecated 4879 @SystemApi 4880 public static final String EXTRA_NETWORK_ID = "networkId"; 4881 4882 /** 4883 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id. 4884 * {@code Integer.MAX_VALUE} if unknown. 4885 * @hide 4886 * @removed 4887 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}. 4888 */ 4889 @Deprecated 4890 @SystemApi 4891 public static final String EXTRA_SYSTEM_ID = "systemId"; 4892 4893 /** 4894 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming 4895 * indicator if registered on a CDMA or EVDO system or {@code -1} if not. 4896 * @hide 4897 * @removed 4898 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}. 4899 */ 4900 @Deprecated 4901 @SystemApi 4902 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator"; 4903 4904 /** 4905 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming 4906 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not. 4907 * @hide 4908 * @removed 4909 * @deprecated Use 4910 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}. 4911 */ 4912 @Deprecated 4913 @SystemApi 4914 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator"; 4915 4916 /** 4917 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency 4918 * only mode. 4919 * {@code true} if in emergency only mode, {@code false} otherwise. 4920 * @hide 4921 * @removed 4922 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}. 4923 */ 4924 @Deprecated 4925 @SystemApi 4926 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly"; 4927 4928 /** 4929 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network 4930 * registration state is roaming. 4931 * {@code true} if registration indicates roaming, {@code false} otherwise 4932 * @hide 4933 * @removed 4934 * @deprecated Use 4935 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}. 4936 */ 4937 @Deprecated 4938 @SystemApi 4939 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION = 4940 "isDataRoamingFromRegistration"; 4941 4942 /** 4943 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier 4944 * aggregation is in use. 4945 * {@code true} if carrier aggregation is in use, {@code false} otherwise. 4946 * @hide 4947 * @removed 4948 * @deprecated Use 4949 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}. 4950 */ 4951 @Deprecated 4952 @SystemApi 4953 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation"; 4954 4955 /** 4956 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which 4957 * is reduced from the rsrp threshold while calculating signal strength level. 4958 * @hide 4959 * @removed 4960 */ 4961 @Deprecated 4962 @SystemApi 4963 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost"; 4964 4965 /** 4966 * The name of the extra used to define the text to be processed, as a 4967 * CharSequence. Note that this may be a styled CharSequence, so you must use 4968 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it. 4969 */ 4970 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT"; 4971 /** 4972 * The name of the boolean extra used to define if the processed text will be used as read-only. 4973 */ 4974 public static final String EXTRA_PROCESS_TEXT_READONLY = 4975 "android.intent.extra.PROCESS_TEXT_READONLY"; 4976 4977 /** 4978 * Broadcast action: reports when a new thermal event has been reached. When the device 4979 * is reaching its maximum temperatue, the thermal level reported 4980 * {@hide} 4981 */ 4982 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 4983 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT"; 4984 4985 /** {@hide} */ 4986 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE"; 4987 4988 /** 4989 * Thermal state when the device is normal. This state is sent in the 4990 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4991 * {@hide} 4992 */ 4993 public static final int EXTRA_THERMAL_STATE_NORMAL = 0; 4994 4995 /** 4996 * Thermal state where the device is approaching its maximum threshold. This state is sent in 4997 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 4998 * {@hide} 4999 */ 5000 public static final int EXTRA_THERMAL_STATE_WARNING = 1; 5001 5002 /** 5003 * Thermal state where the device has reached its maximum threshold. This state is sent in the 5004 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}. 5005 * {@hide} 5006 */ 5007 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2; 5008 5009 /** 5010 * Broadcast Action: Indicates the dock in idle state while device is docked. 5011 * 5012 * <p class="note">This is a protected intent that can only be sent 5013 * by the system. 5014 * 5015 * @hide 5016 */ 5017 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE"; 5018 5019 /** 5020 * Broadcast Action: Indicates the dock in active state while device is docked. 5021 * 5022 * <p class="note">This is a protected intent that can only be sent 5023 * by the system. 5024 * 5025 * @hide 5026 */ 5027 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE"; 5028 5029 /** 5030 * Broadcast Action: Indicates that a new device customization has been 5031 * downloaded and applied (packages installed, runtime resource overlays 5032 * enabled, xml files copied, ...), and that it is time for components that 5033 * need to for example clear their caches to do so now. 5034 * 5035 * @hide 5036 */ 5037 @SystemApi 5038 public static final String ACTION_DEVICE_CUSTOMIZATION_READY = 5039 "android.intent.action.DEVICE_CUSTOMIZATION_READY"; 5040 5041 5042 /** 5043 * Activity Action: Display an activity state associated with an unique {@link LocusId}. 5044 * 5045 * <p>For example, a chat app could use the context to resume a conversation between 2 users. 5046 * 5047 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the 5048 * app domain. Should be stable across reboots and backup / restore. 5049 * <p>Output: nothing. 5050 */ 5051 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) 5052 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS"; 5053 5054 /** 5055 * Broadcast Action: Sent to the integrity component when a package 5056 * needs to be verified. The data contains the package URI along with other relevant 5057 * information. 5058 * 5059 * <p class="note"> 5060 * This is a protected intent that can only be sent by the system. 5061 * </p> 5062 * 5063 * @hide 5064 */ 5065 @SystemApi 5066 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 5067 public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION = 5068 "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION"; 5069 5070 /** 5071 * Broadcast Action: Start the foreground service manager. 5072 * 5073 * <p class="note"> 5074 * This is a protected intent that can only be sent by the system. 5075 * </p> 5076 * 5077 * @hide 5078 */ 5079 public static final String ACTION_SHOW_FOREGROUND_SERVICE_MANAGER = 5080 "android.intent.action.SHOW_FOREGROUND_SERVICE_MANAGER"; 5081 5082 // --------------------------------------------------------------------- 5083 // --------------------------------------------------------------------- 5084 // Standard intent categories (see addCategory()). 5085 5086 /** 5087 * Set if the activity should be an option for the default action 5088 * (center press) to perform on a piece of data. Setting this will 5089 * hide from the user any activities without it set when performing an 5090 * action on some data. Note that this is normally -not- set in the 5091 * Intent when initiating an action -- it is for use in intent filters 5092 * specified in packages. 5093 */ 5094 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5095 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT"; 5096 /** 5097 * Activities that can be safely invoked from a browser must support this 5098 * category. For example, if the user is viewing a web page or an e-mail 5099 * and clicks on a link in the text, the Intent generated execute that 5100 * link will require the BROWSABLE category, so that only activities 5101 * supporting this category will be considered as possible actions. By 5102 * supporting this category, you are promising that there is nothing 5103 * damaging (without user intervention) that can happen by invoking any 5104 * matching Intent. 5105 */ 5106 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5107 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE"; 5108 /** 5109 * Categories for activities that can participate in voice interaction. 5110 * An activity that supports this category must be prepared to run with 5111 * no UI shown at all (though in some case it may have a UI shown), and 5112 * rely on {@link android.app.VoiceInteractor} to interact with the user. 5113 */ 5114 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5115 public static final String CATEGORY_VOICE = "android.intent.category.VOICE"; 5116 /** 5117 * Set if the activity should be considered as an alternative action to 5118 * the data the user is currently viewing. See also 5119 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that 5120 * applies to the selection in a list of items. 5121 * 5122 * <p>Supporting this category means that you would like your activity to be 5123 * displayed in the set of alternative things the user can do, usually as 5124 * part of the current activity's options menu. You will usually want to 5125 * include a specific label in the <intent-filter> of this action 5126 * describing to the user what it does. 5127 * 5128 * <p>The action of IntentFilter with this category is important in that it 5129 * describes the specific action the target will perform. This generally 5130 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather 5131 * a specific name such as "com.android.camera.action.CROP. Only one 5132 * alternative of any particular action will be shown to the user, so using 5133 * a specific action like this makes sure that your alternative will be 5134 * displayed while also allowing other applications to provide their own 5135 * overrides of that particular action. 5136 */ 5137 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5138 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE"; 5139 /** 5140 * Set if the activity should be considered as an alternative selection 5141 * action to the data the user has currently selected. This is like 5142 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list 5143 * of items from which the user can select, giving them alternatives to the 5144 * default action that will be performed on it. 5145 */ 5146 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5147 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE"; 5148 /** 5149 * Intended to be used as a tab inside of a containing TabActivity. 5150 */ 5151 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5152 public static final String CATEGORY_TAB = "android.intent.category.TAB"; 5153 /** 5154 * Should be displayed in the top-level launcher. 5155 */ 5156 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5157 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER"; 5158 /** 5159 * Indicates an activity optimized for Leanback mode, and that should 5160 * be displayed in the Leanback launcher. 5161 */ 5162 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5163 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER"; 5164 /** 5165 * Indicates the preferred entry-point activity when an application is launched from a Car 5166 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a 5167 * fallback, or exclude the application entirely. 5168 * @hide 5169 */ 5170 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5171 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER"; 5172 /** 5173 * Used to indicate that the activity can be used in communal mode. 5174 * @hide 5175 */ 5176 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5177 public static final String CATEGORY_COMMUNAL_MODE = "android.intent.category.COMMUNAL_MODE"; 5178 /** 5179 * Indicates a Leanback settings activity to be displayed in the Leanback launcher. 5180 * @hide 5181 */ 5182 @SystemApi 5183 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS"; 5184 /** 5185 * Provides information about the package it is in; typically used if 5186 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide 5187 * a front-door to the user without having to be shown in the all apps list. 5188 */ 5189 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5190 public static final String CATEGORY_INFO = "android.intent.category.INFO"; 5191 /** 5192 * This is the home activity, that is the first activity that is displayed 5193 * when the device boots. 5194 */ 5195 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5196 public static final String CATEGORY_HOME = "android.intent.category.HOME"; 5197 /** 5198 * This is the home activity that is displayed when the device is finished setting up and ready 5199 * for use. 5200 * @hide 5201 */ 5202 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5203 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN"; 5204 /** 5205 * The home activity shown on secondary displays that support showing home activities. 5206 */ 5207 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5208 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME"; 5209 /** 5210 * This is the setup wizard activity, that is the first activity that is displayed 5211 * when the user sets up the device for the first time. 5212 * @hide 5213 */ 5214 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5215 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD"; 5216 /** 5217 * This is the home activity, that is the activity that serves as the launcher app 5218 * from there the user can start other apps. Often components with lower/higher 5219 * priority intent filters handle the home intent, for example SetupWizard, to 5220 * setup the device and we need to be able to distinguish the home app from these 5221 * setup helpers. 5222 * @hide 5223 */ 5224 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5225 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP"; 5226 /** 5227 * This activity is a preference panel. 5228 */ 5229 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5230 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE"; 5231 /** 5232 * This activity is a development preference panel. 5233 */ 5234 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5235 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE"; 5236 /** 5237 * Capable of running inside a parent activity container. 5238 */ 5239 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5240 public static final String CATEGORY_EMBED = "android.intent.category.EMBED"; 5241 /** 5242 * This activity allows the user to browse and download new applications. 5243 */ 5244 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5245 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET"; 5246 /** 5247 * This activity may be exercised by the monkey or other automated test tools. 5248 */ 5249 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5250 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY"; 5251 /** 5252 * To be used as a test (not part of the normal user experience). 5253 */ 5254 public static final String CATEGORY_TEST = "android.intent.category.TEST"; 5255 /** 5256 * To be used as a unit test (run through the Test Harness). 5257 */ 5258 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST"; 5259 /** 5260 * To be used as a sample code example (not part of the normal user 5261 * experience). 5262 */ 5263 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE"; 5264 5265 /** 5266 * Used to indicate that an intent only wants URIs that can be opened with 5267 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs 5268 * must support at least the columns defined in {@link OpenableColumns} when 5269 * queried. 5270 * 5271 * @see #ACTION_GET_CONTENT 5272 * @see #ACTION_OPEN_DOCUMENT 5273 * @see #ACTION_CREATE_DOCUMENT 5274 */ 5275 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5276 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE"; 5277 5278 /** 5279 * Used to indicate that an intent filter can accept files which are not necessarily 5280 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but 5281 * at least streamable via 5282 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)} 5283 * using one of the stream types exposed via 5284 * {@link ContentResolver#getStreamTypes(Uri, String)}. 5285 * 5286 * @see #ACTION_SEND 5287 * @see #ACTION_SEND_MULTIPLE 5288 */ 5289 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5290 public static final String CATEGORY_TYPED_OPENABLE = 5291 "android.intent.category.TYPED_OPENABLE"; 5292 5293 /** 5294 * To be used as code under test for framework instrumentation tests. 5295 */ 5296 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = 5297 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"; 5298 /** 5299 * An activity to run when device is inserted into a car dock. 5300 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5301 * information, see {@link android.app.UiModeManager}. 5302 */ 5303 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5304 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK"; 5305 /** 5306 * An activity to run when device is inserted into a desk dock. 5307 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5308 * information, see {@link android.app.UiModeManager}. 5309 */ 5310 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5311 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK"; 5312 /** 5313 * An activity to run when device is inserted into a analog (low end) dock. 5314 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5315 * information, see {@link android.app.UiModeManager}. 5316 */ 5317 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5318 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK"; 5319 5320 /** 5321 * An activity to run when device is inserted into a digital (high end) dock. 5322 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5323 * information, see {@link android.app.UiModeManager}. 5324 */ 5325 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5326 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK"; 5327 5328 /** 5329 * Used to indicate that the activity can be used in a car environment. 5330 */ 5331 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5332 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE"; 5333 5334 /** 5335 * An activity to use for the launcher when the device is placed in a VR Headset viewer. 5336 * Used with {@link #ACTION_MAIN} to launch an activity. For more 5337 * information, see {@link android.app.UiModeManager}. 5338 */ 5339 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5340 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME"; 5341 5342 /** 5343 * The accessibility shortcut is a global gesture for users with disabilities to trigger an 5344 * important for them accessibility feature to help developers determine whether they want to 5345 * make their activity a shortcut target. 5346 * <p> 5347 * An activity of interest to users with accessibility needs may request to be the target of 5348 * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category, 5349 * which will be dispatched by the system when the user activates the shortcut when it is 5350 * configured to point at this target. 5351 * </p> 5352 * <p> 5353 * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must 5354 * also do two things: 5355 * <ul> 5356 * <ol> 5357 * Specify that it handles the <code>android.intent.action.MAIN</code> 5358 * {@link android.content.Intent} 5359 * with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>. 5360 * </ol> 5361 * <ol> 5362 * Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the 5363 * manifest when declaring the activity. 5364 * </ol> 5365 * </ul> 5366 * If either of these items is missing, the system will ignore the accessibility shortcut 5367 * target. Following is an example declaration: 5368 * </p> 5369 * <pre> 5370 * <activity android:name=".MainActivity" 5371 * . . . 5372 * <intent-filter> 5373 * <action android:name="android.intent.action.MAIN" /> 5374 * <category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /> 5375 * </intent-filter> 5376 * <meta-data android:name="android.accessibilityshortcut.target" 5377 * android:resource="@xml/accessibilityshortcut" /> 5378 * </activity> 5379 * </pre> 5380 * <p> This is a sample XML file configuring a accessibility shortcut target: </p> 5381 * <pre> 5382 * <accessibility-shortcut-target 5383 * android:description="@string/shortcut_target_description" 5384 * android:summary="@string/shortcut_target_summary" 5385 * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" 5386 * android:htmlDescription="@string/shortcut_target_html_description" 5387 * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /> 5388 * </pre> 5389 * <p> 5390 * Both description and summary are necessary. The system will ignore the accessibility 5391 * shortcut target if they are missing. The animated image and html description are supported 5392 * to help users understand how to use the shortcut target. The settings activity is a 5393 * component name that allows the user to modify the settings for this accessibility shortcut 5394 * target. 5395 * </p> 5396 */ 5397 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5398 public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET = 5399 "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET"; 5400 // --------------------------------------------------------------------- 5401 // --------------------------------------------------------------------- 5402 // Application launch intent categories (see addCategory()). 5403 5404 /** 5405 * Used with {@link #ACTION_MAIN} to launch the browser application. 5406 * The activity should be able to browse the Internet. 5407 * <p>NOTE: This should not be used as the primary key of an Intent, 5408 * since it will not result in the app launching with the correct 5409 * action and category. Instead, use this with 5410 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5411 * Intent with this category in the selector.</p> 5412 */ 5413 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5414 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER"; 5415 5416 /** 5417 * Used with {@link #ACTION_MAIN} to launch the calculator application. 5418 * The activity should be able to perform standard arithmetic operations. 5419 * <p>NOTE: This should not be used as the primary key of an Intent, 5420 * since it will not result in the app launching with the correct 5421 * action and category. Instead, use this with 5422 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5423 * Intent with this category in the selector.</p> 5424 */ 5425 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5426 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR"; 5427 5428 /** 5429 * Used with {@link #ACTION_MAIN} to launch the calendar application. 5430 * The activity should be able to view and manipulate calendar entries. 5431 * <p>NOTE: This should not be used as the primary key of an Intent, 5432 * since it will not result in the app launching with the correct 5433 * action and category. Instead, use this with 5434 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5435 * Intent with this category in the selector.</p> 5436 */ 5437 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5438 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR"; 5439 5440 /** 5441 * Used with {@link #ACTION_MAIN} to launch the contacts application. 5442 * The activity should be able to view and manipulate address book entries. 5443 * <p>NOTE: This should not be used as the primary key of an Intent, 5444 * since it will not result in the app launching with the correct 5445 * action and category. Instead, use this with 5446 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5447 * Intent with this category in the selector.</p> 5448 */ 5449 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5450 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS"; 5451 5452 /** 5453 * Used with {@link #ACTION_MAIN} to launch the email application. 5454 * The activity should be able to send and receive email. 5455 * <p>NOTE: This should not be used as the primary key of an Intent, 5456 * since it will not result in the app launching with the correct 5457 * action and category. Instead, use this with 5458 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5459 * Intent with this category in the selector.</p> 5460 */ 5461 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5462 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL"; 5463 5464 /** 5465 * Used with {@link #ACTION_MAIN} to launch the gallery application. 5466 * The activity should be able to view and manipulate image and video files 5467 * stored on the device. 5468 * <p>NOTE: This should not be used as the primary key of an Intent, 5469 * since it will not result in the app launching with the correct 5470 * action and category. Instead, use this with 5471 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5472 * Intent with this category in the selector.</p> 5473 */ 5474 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5475 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY"; 5476 5477 /** 5478 * Used with {@link #ACTION_MAIN} to launch the maps application. 5479 * The activity should be able to show the user's current location and surroundings. 5480 * <p>NOTE: This should not be used as the primary key of an Intent, 5481 * since it will not result in the app launching with the correct 5482 * action and category. Instead, use this with 5483 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5484 * Intent with this category in the selector.</p> 5485 */ 5486 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5487 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS"; 5488 5489 /** 5490 * Used with {@link #ACTION_MAIN} to launch the messaging application. 5491 * The activity should be able to send and receive text messages. 5492 * <p>NOTE: This should not be used as the primary key of an Intent, 5493 * since it will not result in the app launching with the correct 5494 * action and category. Instead, use this with 5495 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5496 * Intent with this category in the selector.</p> 5497 */ 5498 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5499 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING"; 5500 5501 /** 5502 * Used with {@link #ACTION_MAIN} to launch the music application. 5503 * The activity should be able to play, browse, or manipulate music files 5504 * stored on the device. 5505 * <p>NOTE: This should not be used as the primary key of an Intent, 5506 * since it will not result in the app launching with the correct 5507 * action and category. Instead, use this with 5508 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5509 * Intent with this category in the selector.</p> 5510 */ 5511 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5512 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC"; 5513 5514 /** 5515 * Used with {@link #ACTION_MAIN} to launch the files application. 5516 * The activity should be able to browse and manage files stored on the device. 5517 * <p>NOTE: This should not be used as the primary key of an Intent, 5518 * since it will not result in the app launching with the correct 5519 * action and category. Instead, use this with 5520 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5521 * Intent with this category in the selector.</p> 5522 */ 5523 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5524 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES"; 5525 5526 /** 5527 * Used with {@link #ACTION_MAIN} to launch the weather application. 5528 * The activity should be able to give the user information about the weather 5529 * <p>NOTE: This should not be used as the primary key of an Intent, 5530 * since it will not result in the app launching with the correct 5531 * action and category. Instead, use this with 5532 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5533 * Intent with this category in the selector.</p> 5534 */ 5535 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5536 public static final String CATEGORY_APP_WEATHER = "android.intent.category.APP_WEATHER"; 5537 5538 /** 5539 * Used with {@link #ACTION_MAIN} to launch the fitness application. 5540 * The activity should be able to give the user fitness information and manage workouts 5541 * <p>NOTE: This should not be used as the primary key of an Intent, 5542 * since it will not result in the app launching with the correct 5543 * action and category. Instead, use this with 5544 * {@link #makeMainSelectorActivity(String, String)} to generate a main 5545 * Intent with this category in the selector.</p> 5546 */ 5547 @SdkConstant(SdkConstantType.INTENT_CATEGORY) 5548 public static final String CATEGORY_APP_FITNESS = "android.intent.category.APP_FITNESS"; 5549 5550 // --------------------------------------------------------------------- 5551 // --------------------------------------------------------------------- 5552 // Standard extra data keys. 5553 5554 /** 5555 * The initial data to place in a newly created record. Use with 5556 * {@link #ACTION_INSERT}. The data here is a Map containing the same 5557 * fields as would be given to the underlying ContentProvider.insert() 5558 * call. 5559 */ 5560 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE"; 5561 5562 /** 5563 * A constant CharSequence that is associated with the Intent, used with 5564 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that 5565 * this may be a styled CharSequence, so you must use 5566 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to 5567 * retrieve it. 5568 */ 5569 public static final String EXTRA_TEXT = "android.intent.extra.TEXT"; 5570 5571 /** 5572 * A constant String that is associated with the Intent, used with 5573 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT} 5574 * as HTML formatted text. Note that you <em>must</em> also supply 5575 * {@link #EXTRA_TEXT}. 5576 */ 5577 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT"; 5578 5579 /** 5580 * A content: URI holding a stream of data associated with the Intent, 5581 * used with {@link #ACTION_SEND} to supply the data being sent. 5582 */ 5583 public static final String EXTRA_STREAM = "android.intent.extra.STREAM"; 5584 5585 /** 5586 * A String[] holding e-mail addresses that should be delivered to. 5587 */ 5588 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL"; 5589 5590 /** 5591 * A String[] holding e-mail addresses that should be carbon copied. 5592 */ 5593 public static final String EXTRA_CC = "android.intent.extra.CC"; 5594 5595 /** 5596 * A String[] holding e-mail addresses that should be blind carbon copied. 5597 */ 5598 public static final String EXTRA_BCC = "android.intent.extra.BCC"; 5599 5600 /** 5601 * A constant string holding the desired subject line of a message. 5602 */ 5603 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT"; 5604 5605 /** 5606 * An Intent describing the choices you would like shown with 5607 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}. 5608 */ 5609 public static final String EXTRA_INTENT = "android.intent.extra.INTENT"; 5610 5611 /** 5612 * An int representing the user ID to be used. 5613 * 5614 * @hide 5615 */ 5616 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID"; 5617 5618 /** 5619 * An int representing the task id to be retrieved. This is used when a launch from recents is 5620 * intercepted by another action such as credentials confirmation to remember which task should 5621 * be resumed when complete. 5622 * 5623 * @hide 5624 */ 5625 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID"; 5626 5627 /** 5628 * A String[] holding attribution tags when used with 5629 * {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5630 * and ACTION_MANAGE_PERMISSION_USAGE 5631 * 5632 * E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc. 5633 */ 5634 public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS"; 5635 5636 /** 5637 * A long representing the start timestamp (epoch time in millis) of the permission usage 5638 * when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5639 * and ACTION_MANAGE_PERMISSION_USAGE 5640 */ 5641 public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME"; 5642 5643 /** 5644 * A long representing the end timestamp (epoch time in millis) of the permission usage when 5645 * used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5646 * and ACTION_MANAGE_PERMISSION_USAGE 5647 */ 5648 public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME"; 5649 5650 /** 5651 * A boolean extra, when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD} 5652 * and {@link #ACTION_MANAGE_PERMISSION_USAGE}, 5653 * that specifies whether the permission usage system UI is showing attribution information 5654 * for the chosen entry. 5655 * 5656 * <p> The extra can only be true if application has specified attributionsAreUserVisible 5657 * in its manifest. </p> 5658 * 5659 * <p> Applications can use this extra to improve their permission usage explanation 5660 * experience. </p> 5661 * @hide 5662 */ 5663 @SystemApi 5664 public static final String EXTRA_SHOWING_ATTRIBUTION = 5665 "android.intent.extra.SHOWING_ATTRIBUTION"; 5666 5667 /** 5668 * An Intent[] describing additional, alternate choices you would like shown with 5669 * {@link #ACTION_CHOOSER}. 5670 * 5671 * <p>An app may be capable of providing several different payload types to complete a 5672 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos 5673 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer 5674 * several different supported sending mechanisms for sharing, such as the actual "image/*" 5675 * photo data or a hosted link where the photos can be viewed.</p> 5676 * 5677 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the 5678 * first/primary/preferred intent in the set. Additional intents specified in 5679 * this extra are ordered; by default intents that appear earlier in the array will be 5680 * preferred over intents that appear later in the array as matches for the same 5681 * target component. To alter this preference, a calling app may also supply 5682 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p> 5683 */ 5684 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; 5685 5686 /** 5687 * A {@link ComponentName ComponentName[]} describing components that should be filtered out 5688 * and omitted from a list of components presented to the user. 5689 * 5690 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components 5691 * in this array if it otherwise would have shown them. Useful for omitting specific targets 5692 * from your own package or other apps from your organization if the idea of sending to those 5693 * targets would be redundant with other app functionality. Filtered components will not 5694 * be able to present targets from an associated <code>ChooserTargetService</code>.</p> 5695 */ 5696 public static final String EXTRA_EXCLUDE_COMPONENTS 5697 = "android.intent.extra.EXCLUDE_COMPONENTS"; 5698 5699 /** 5700 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER} 5701 * describing additional high-priority deep-link targets for the chooser to present to the user. 5702 * 5703 * <p>Targets provided in this way will be presented inline with all other targets provided 5704 * by services from other apps. They will be prioritized before other service targets, but 5705 * after those targets provided by sources that the user has manually pinned to the front. 5706 * You can provide up to two targets on this extra (the limit of two targets 5707 * starts in Android 10).</p> 5708 * 5709 * @see #ACTION_CHOOSER 5710 */ 5711 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; 5712 5713 /** 5714 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection 5715 * from the chooser activity presented by {@link #ACTION_CHOOSER}. 5716 * 5717 * <p>An app preparing an action for another app to complete may wish to allow the user to 5718 * disambiguate between several options for completing the action based on the chosen target 5719 * or otherwise refine the action before it is invoked. 5720 * </p> 5721 * 5722 * <p>When sent, this IntentSender may be filled in with the following extras:</p> 5723 * <ul> 5724 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li> 5725 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's 5726 * chosen target beyond the first</li> 5727 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity 5728 * should fill in and send once the disambiguation is complete</li> 5729 * </ul> 5730 */ 5731 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER 5732 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; 5733 5734 /** 5735 * A Parcelable[] of {@link ChooserAction} objects to provide the Android Sharesheet with 5736 * app-specific actions to be presented to the user when invoking {@link #ACTION_CHOOSER}. 5737 * @hide 5738 */ 5739 public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS = 5740 "android.intent.extra.CHOOSER_CUSTOM_ACTIONS"; 5741 5742 /** 5743 * Optional argument to be used with {@link #ACTION_CHOOSER}. 5744 * A {@link android.app.PendingIntent} to be sent when the user wants to modify the content that 5745 * they're sharing. This can be used to allow the user to return to the source app to, for 5746 * example, select different media. 5747 * @hide 5748 */ 5749 public static final String EXTRA_CHOOSER_MODIFY_SHARE_ACTION = 5750 "android.intent.extra.CHOOSER_MODIFY_SHARE_ACTION"; 5751 5752 /** 5753 * An {@code ArrayList} of {@code String} annotations describing content for 5754 * {@link #ACTION_CHOOSER}. 5755 * 5756 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a 5757 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p> 5758 * 5759 * <p>Annotations should describe the major components or topics of the content. It is up to 5760 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be 5761 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to 5762 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon 5763 * character. Performance on customized annotations can suffer, if they are rarely used for 5764 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the 5765 * following annotations when applicable.</p> 5766 * <ul> 5767 * <li>"product" represents that the topic of the content is mainly about products, e.g., 5768 * health & beauty, and office supplies.</li> 5769 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g., 5770 * happy, and sad.</li> 5771 * <li>"person" represents that the topic of the content is mainly about persons, e.g., 5772 * face, finger, standing, and walking.</li> 5773 * <li>"child" represents that the topic of the content is mainly about children, e.g., 5774 * child, and baby.</li> 5775 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li> 5776 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li> 5777 * <li>"party" represents that the topic of the content is mainly about parties.</li> 5778 * <li>"animal" represent that the topic of the content is mainly about animals.</li> 5779 * <li>"plant" represents that the topic of the content is mainly about plants, e.g., 5780 * flowers.</li> 5781 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li> 5782 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g. 5783 * sunglasses, jewelry, handbags and clothing.</li> 5784 * <li>"material" represents that the topic of the content is mainly about materials, e.g., 5785 * paper, and silk.</li> 5786 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like 5787 * cars, and boats.</li> 5788 * <li>"document" represents that the topic of the content is mainly about documents, e.g. 5789 * posters.</li> 5790 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts 5791 * and designs of houses.</li> 5792 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g., 5793 * Christmas and Thanksgiving.</li> 5794 * </ul> 5795 */ 5796 public static final String EXTRA_CONTENT_ANNOTATIONS 5797 = "android.intent.extra.CONTENT_ANNOTATIONS"; 5798 5799 /** 5800 * A {@link ResultReceiver} used to return data back to the sender. 5801 * 5802 * <p>Used to complete an app-specific 5803 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p> 5804 * 5805 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent 5806 * used to start a {@link #ACTION_CHOOSER} activity this extra will be 5807 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent 5808 * when the user selects a target component from the chooser. It is up to the recipient 5809 * to send a result to this ResultReceiver to signal that disambiguation is complete 5810 * and that the chooser should invoke the user's choice.</p> 5811 * 5812 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent 5813 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser 5814 * to match and fill in the final Intent or ChooserTarget before starting it. 5815 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from 5816 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to 5817 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p> 5818 * 5819 * <p>The result code passed to the ResultReceiver should be 5820 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's 5821 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if 5822 * the chooser should finish without starting a target.</p> 5823 */ 5824 public static final String EXTRA_RESULT_RECEIVER 5825 = "android.intent.extra.RESULT_RECEIVER"; 5826 5827 /** 5828 * A CharSequence dialog title to provide to the user when used with a 5829 * {@link #ACTION_CHOOSER}. 5830 */ 5831 public static final String EXTRA_TITLE = "android.intent.extra.TITLE"; 5832 5833 /** 5834 * A Parcelable[] of {@link Intent} or 5835 * {@link android.content.pm.LabeledIntent} objects as set with 5836 * {@link #putExtra(String, Parcelable[])} to place 5837 * at the front of the list of choices, when shown to the user with an 5838 * {@link #ACTION_CHOOSER}. You can choose up to two additional activities 5839 * to show before the app suggestions (the limit of two additional activities starts in 5840 * Android 10). 5841 */ 5842 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS"; 5843 5844 /** 5845 * A {@link IntentSender} to start after instant app installation success. 5846 * @hide 5847 */ 5848 @SystemApi 5849 public static final String EXTRA_INSTANT_APP_SUCCESS = 5850 "android.intent.extra.INSTANT_APP_SUCCESS"; 5851 5852 /** 5853 * A {@link IntentSender} to start after instant app installation failure. 5854 * @hide 5855 */ 5856 @SystemApi 5857 public static final String EXTRA_INSTANT_APP_FAILURE = 5858 "android.intent.extra.INSTANT_APP_FAILURE"; 5859 5860 /** 5861 * The host name that triggered an instant app resolution. 5862 * @hide 5863 */ 5864 @SystemApi 5865 public static final String EXTRA_INSTANT_APP_HOSTNAME = 5866 "android.intent.extra.INSTANT_APP_HOSTNAME"; 5867 5868 /** 5869 * An opaque token to track instant app resolution. 5870 * @hide 5871 */ 5872 @SystemApi 5873 public static final String EXTRA_INSTANT_APP_TOKEN = 5874 "android.intent.extra.INSTANT_APP_TOKEN"; 5875 5876 /** 5877 * The action that triggered an instant application resolution. 5878 * @hide 5879 */ 5880 @SystemApi 5881 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION"; 5882 5883 /** 5884 * An array of {@link Bundle}s containing details about resolved instant apps.. 5885 * @hide 5886 */ 5887 @SystemApi 5888 public static final String EXTRA_INSTANT_APP_BUNDLES = 5889 "android.intent.extra.INSTANT_APP_BUNDLES"; 5890 5891 /** 5892 * A {@link Bundle} of metadata that describes the instant application that needs to be 5893 * installed. This data is populated from the response to 5894 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered 5895 * instant application resolver. 5896 * @hide 5897 */ 5898 @SystemApi 5899 public static final String EXTRA_INSTANT_APP_EXTRAS = 5900 "android.intent.extra.INSTANT_APP_EXTRAS"; 5901 5902 /** 5903 * A boolean value indicating that the instant app resolver was unable to state with certainty 5904 * that it did or did not have an app for the sanitized {@link Intent} defined at 5905 * {@link #EXTRA_INTENT}. 5906 * @hide 5907 */ 5908 @SystemApi 5909 public static final String EXTRA_UNKNOWN_INSTANT_APP = 5910 "android.intent.extra.UNKNOWN_INSTANT_APP"; 5911 5912 /** 5913 * The version code of the app to install components from. 5914 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE). 5915 * @hide 5916 */ 5917 @Deprecated 5918 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE"; 5919 5920 /** 5921 * The version code of the app to install components from. 5922 * @hide 5923 */ 5924 @SystemApi 5925 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE"; 5926 5927 /** 5928 * The app that triggered the instant app installation. 5929 * @hide 5930 */ 5931 @SystemApi 5932 public static final String EXTRA_CALLING_PACKAGE 5933 = "android.intent.extra.CALLING_PACKAGE"; 5934 5935 /** 5936 * Optional calling app provided bundle containing additional launch information the 5937 * installer may use. 5938 * @hide 5939 */ 5940 @SystemApi 5941 public static final String EXTRA_VERIFICATION_BUNDLE 5942 = "android.intent.extra.VERIFICATION_BUNDLE"; 5943 5944 /** 5945 * A Bundle forming a mapping of potential target package names to different extras Bundles 5946 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with 5947 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not 5948 * be currently installed on the device. 5949 * 5950 * <p>An application may choose to provide alternate extras for the case where a user 5951 * selects an activity from a predetermined set of target packages. If the activity 5952 * the user selects from the chooser belongs to a package with its package name as 5953 * a key in this bundle, the corresponding extras for that package will be merged with 5954 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement 5955 * extra has the same key as an extra already present in the intent it will overwrite 5956 * the extra from the intent.</p> 5957 * 5958 * <p><em>Examples:</em> 5959 * <ul> 5960 * <li>An application may offer different {@link #EXTRA_TEXT} to an application 5961 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query 5962 * parameters for that target.</li> 5963 * <li>An application may offer additional metadata for known targets of a given intent 5964 * to pass along information only relevant to that target such as account or content 5965 * identifiers already known to that application.</li> 5966 * </ul></p> 5967 */ 5968 public static final String EXTRA_REPLACEMENT_EXTRAS = 5969 "android.intent.extra.REPLACEMENT_EXTRAS"; 5970 5971 /** 5972 * An {@link IntentSender} that will be notified if a user successfully chooses a target 5973 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender 5974 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the 5975 * {@link ComponentName} of the chosen component. 5976 * 5977 * <p>In some situations this callback may never come, for example if the user abandons 5978 * the chooser, switches to another task or any number of other reasons. Apps should not 5979 * be written assuming that this callback will always occur.</p> 5980 */ 5981 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = 5982 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER"; 5983 5984 /** 5985 * The {@link ComponentName} chosen by the user to complete an action. 5986 * 5987 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER 5988 */ 5989 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; 5990 5991 /** 5992 * A {@link android.view.KeyEvent} object containing the event that 5993 * triggered the creation of the Intent it is in. 5994 */ 5995 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT"; 5996 5997 /** 5998 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user 5999 * before shutting down. 6000 * 6001 * {@hide} 6002 */ 6003 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM"; 6004 6005 /** 6006 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is 6007 * requested by the user. 6008 * 6009 * {@hide} 6010 */ 6011 public static final String EXTRA_USER_REQUESTED_SHUTDOWN = 6012 "android.intent.extra.USER_REQUESTED_SHUTDOWN"; 6013 6014 /** 6015 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 6016 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action 6017 * of restarting the application. 6018 */ 6019 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP"; 6020 6021 /** 6022 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6023 * intents to signal that the application was removed with the user-initiated action. 6024 */ 6025 public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED"; 6026 6027 /** 6028 * A String holding the phone number originally entered in 6029 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual 6030 * number to call in a {@link android.content.Intent#ACTION_CALL}. 6031 */ 6032 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER"; 6033 6034 /** 6035 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED} 6036 * intents to supply the uid the package had been assigned. Also an optional 6037 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or 6038 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same 6039 * purpose. 6040 */ 6041 public static final String EXTRA_UID = "android.intent.extra.UID"; 6042 6043 /** 6044 * @hide String array of package names. 6045 */ 6046 @SystemApi 6047 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; 6048 6049 /** 6050 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6051 * intents to indicate whether this represents a full uninstall (removing 6052 * both the code and its data) or a partial uninstall (leaving its data, 6053 * implying that this is an update). 6054 */ 6055 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED"; 6056 6057 /** 6058 * @hide 6059 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6060 * intents to indicate that at this point the package has been removed for 6061 * all users on the device. 6062 */ 6063 public static final String EXTRA_REMOVED_FOR_ALL_USERS 6064 = "android.intent.extra.REMOVED_FOR_ALL_USERS"; 6065 6066 /** 6067 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} 6068 * intents to indicate that this is a replacement of the package, so this 6069 * broadcast will immediately be followed by an add broadcast for a 6070 * different version of the same package. 6071 */ 6072 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING"; 6073 6074 /** 6075 * Used as an int extra field in {@link android.app.AlarmManager} pending intents 6076 * to tell the application being invoked how many pending alarms are being 6077 * delivered with the intent. For one-shot alarms this will always be 1. 6078 * For recurring alarms, this might be greater than 1 if the device was 6079 * asleep or powered off at the time an earlier alarm would have been 6080 * delivered. 6081 * 6082 * <p>Note: You must supply a <b>mutable</b> {@link android.app.PendingIntent} to 6083 * {@code AlarmManager} while setting your alarms to be able to read this value on receiving 6084 * them. <em>Mutability of pending intents must be explicitly specified by apps targeting 6085 * {@link Build.VERSION_CODES#S} or higher</em>. 6086 * 6087 * @see android.app.PendingIntent#FLAG_MUTABLE 6088 * 6089 */ 6090 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT"; 6091 6092 /** 6093 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT} 6094 * intents to request the dock state. Possible values are 6095 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED}, 6096 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or 6097 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or 6098 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or 6099 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}. 6100 */ 6101 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE"; 6102 6103 /** 6104 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6105 * to represent that the phone is not in any dock. 6106 */ 6107 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0; 6108 6109 /** 6110 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6111 * to represent that the phone is in a desk dock. 6112 */ 6113 public static final int EXTRA_DOCK_STATE_DESK = 1; 6114 6115 /** 6116 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6117 * to represent that the phone is in a car dock. 6118 */ 6119 public static final int EXTRA_DOCK_STATE_CAR = 2; 6120 6121 /** 6122 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6123 * to represent that the phone is in a analog (low end) dock. 6124 */ 6125 public static final int EXTRA_DOCK_STATE_LE_DESK = 3; 6126 6127 /** 6128 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE} 6129 * to represent that the phone is in a digital (high end) dock. 6130 */ 6131 public static final int EXTRA_DOCK_STATE_HE_DESK = 4; 6132 6133 /** 6134 * Boolean that can be supplied as meta-data with a dock activity, to 6135 * indicate that the dock should take over the home key when it is active. 6136 */ 6137 public static final String METADATA_DOCK_HOME = "android.dock_home"; 6138 6139 /** 6140 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing 6141 * the bug report. 6142 */ 6143 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT"; 6144 6145 /** 6146 * Used in the extra field in the remote intent. It's a string token passed with the 6147 * remote intent. 6148 */ 6149 public static final String EXTRA_REMOTE_INTENT_TOKEN = 6150 "android.intent.extra.remote_intent_token"; 6151 6152 /** 6153 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field 6154 * will contain only the first name in the list. 6155 */ 6156 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME = 6157 "android.intent.extra.changed_component_name"; 6158 6159 /** 6160 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, 6161 * and contains a string array of all of the components that have changed. If 6162 * the state of the overall package has changed, then it will contain an entry 6163 * with the package name itself. 6164 */ 6165 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = 6166 "android.intent.extra.changed_component_name_list"; 6167 6168 /** 6169 * This field is part of 6170 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 6171 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}, 6172 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED}, 6173 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED} 6174 * and contains a string array of all of the components that have changed. 6175 */ 6176 public static final String EXTRA_CHANGED_PACKAGE_LIST = 6177 "android.intent.extra.changed_package_list"; 6178 6179 /** 6180 * This field is part of 6181 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE}, 6182 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE} 6183 * and contains an integer array of uids of all of the components 6184 * that have changed. 6185 */ 6186 public static final String EXTRA_CHANGED_UID_LIST = 6187 "android.intent.extra.changed_uid_list"; 6188 6189 /** 6190 * An integer denoting a bitwise combination of restrictions set on distracting packages via 6191 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)} 6192 * 6193 * @hide 6194 * @see PackageManager.DistractionRestriction 6195 * @see PackageManager#setDistractingPackageRestrictions(String[], int) 6196 */ 6197 public static final String EXTRA_DISTRACTION_RESTRICTIONS = 6198 "android.intent.extra.distraction_restrictions"; 6199 6200 /** 6201 * @hide 6202 * Magic extra system code can use when binding, to give a label for 6203 * who it is that has bound to a service. This is an integer giving 6204 * a framework string resource that can be displayed to the user. 6205 */ 6206 public static final String EXTRA_CLIENT_LABEL = 6207 "android.intent.extra.client_label"; 6208 6209 /** 6210 * @hide 6211 * Magic extra system code can use when binding, to give a PendingIntent object 6212 * that can be launched for the user to disable the system's use of this 6213 * service. 6214 */ 6215 public static final String EXTRA_CLIENT_INTENT = 6216 "android.intent.extra.client_intent"; 6217 6218 /** 6219 * Extra used to indicate that an intent should only return data that is on 6220 * the local device. This is a boolean extra; the default is false. If true, 6221 * an implementation should only allow the user to select data that is 6222 * already on the device, not requiring it be downloaded from a remote 6223 * service when opened. 6224 * 6225 * @see #ACTION_GET_CONTENT 6226 * @see #ACTION_OPEN_DOCUMENT 6227 * @see #ACTION_OPEN_DOCUMENT_TREE 6228 * @see #ACTION_CREATE_DOCUMENT 6229 */ 6230 public static final String EXTRA_LOCAL_ONLY = 6231 "android.intent.extra.LOCAL_ONLY"; 6232 6233 /** 6234 * Extra used to indicate that an intent can allow the user to select and 6235 * return multiple items. This is a boolean extra; the default is false. If 6236 * true, an implementation is allowed to present the user with a UI where 6237 * they can pick multiple items that are all returned to the caller. When 6238 * this happens, they should be returned as the {@link #getClipData()} part 6239 * of the result Intent. 6240 * 6241 * @see #ACTION_GET_CONTENT 6242 * @see #ACTION_OPEN_DOCUMENT 6243 */ 6244 public static final String EXTRA_ALLOW_MULTIPLE = 6245 "android.intent.extra.ALLOW_MULTIPLE"; 6246 6247 /** 6248 * The user ID integer carried with broadcast intents related to addition, 6249 * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED}, 6250 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}. 6251 * 6252 * @hide 6253 */ 6254 @SystemApi 6255 @SuppressLint("ActionValue") 6256 public static final String EXTRA_USER_HANDLE = 6257 "android.intent.extra.user_handle"; 6258 6259 /** 6260 * The {@link UserHandle} carried with intents. 6261 */ 6262 public static final String EXTRA_USER = 6263 "android.intent.extra.USER"; 6264 6265 /** 6266 * Extra used in the response from a BroadcastReceiver that handles 6267 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is 6268 * <code>ArrayList<RestrictionEntry></code>. 6269 */ 6270 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list"; 6271 6272 /** 6273 * Extra sent in the intent to the BroadcastReceiver that handles 6274 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing 6275 * the restrictions as key/value pairs. 6276 */ 6277 public static final String EXTRA_RESTRICTIONS_BUNDLE = 6278 "android.intent.extra.restrictions_bundle"; 6279 6280 /** 6281 * Extra used in the response from a BroadcastReceiver that handles 6282 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. 6283 */ 6284 public static final String EXTRA_RESTRICTIONS_INTENT = 6285 "android.intent.extra.restrictions_intent"; 6286 6287 /** 6288 * Extra used to communicate a set of acceptable MIME types. The type of the 6289 * extra is {@code String[]}. Values may be a combination of concrete MIME 6290 * types (such as "image/png") and/or partial MIME types (such as 6291 * "audio/*"). 6292 * 6293 * @see #ACTION_GET_CONTENT 6294 * @see #ACTION_OPEN_DOCUMENT 6295 */ 6296 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES"; 6297 6298 /** 6299 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that 6300 * this shutdown is only for the user space of the system, not a complete shutdown. 6301 * When this is true, hardware devices can use this information to determine that 6302 * they shouldn't do a complete shutdown of their device since this is not a 6303 * complete shutdown down to the kernel, but only user space restarting. 6304 * The default if not supplied is false. 6305 */ 6306 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY 6307 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY"; 6308 6309 /** 6310 * Optional extra specifying a time in milliseconds since the Epoch. The value must be 6311 * non-negative. 6312 * <p> 6313 * Type: long 6314 * </p> 6315 */ 6316 public static final String EXTRA_TIME = "android.intent.extra.TIME"; 6317 6318 /** 6319 * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device. 6320 * 6321 * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones. 6322 */ 6323 @SuppressLint("ActionValue") 6324 public static final String EXTRA_TIMEZONE = "time-zone"; 6325 6326 /** 6327 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the 6328 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR}, 6329 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and 6330 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative. 6331 * 6332 * @hide for internal use only. 6333 */ 6334 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT = 6335 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT"; 6336 /** @hide */ 6337 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0; 6338 /** @hide */ 6339 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1; 6340 /** @hide */ 6341 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2; 6342 6343 /** 6344 * Intent extra: the reason that the operation associated with this intent is being performed. 6345 * 6346 * <p>Type: String 6347 * @hide 6348 */ 6349 @SystemApi 6350 public static final String EXTRA_REASON = "android.intent.extra.REASON"; 6351 6352 /** 6353 * {@hide} 6354 * This extra will be send together with {@link #ACTION_FACTORY_RESET} 6355 */ 6356 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE"; 6357 6358 /** 6359 * {@hide} 6360 * This extra will be set to true when the user choose to wipe the data on eSIM during factory 6361 * reset for the device with eSIM. This extra will be sent together with 6362 * {@link #ACTION_FACTORY_RESET} 6363 */ 6364 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS"; 6365 6366 /** 6367 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM 6368 * activation request. 6369 * TODO: Add information about the structure and response data used with the pending intent. 6370 * @hide 6371 */ 6372 public static final String EXTRA_SIM_ACTIVATION_RESPONSE = 6373 "android.intent.extra.SIM_ACTIVATION_RESPONSE"; 6374 6375 /** 6376 * Optional index with semantics depending on the intent action. 6377 * 6378 * <p>The value must be an integer greater or equal to 0. 6379 * @see #ACTION_QUICK_VIEW 6380 */ 6381 public static final String EXTRA_INDEX = "android.intent.extra.INDEX"; 6382 6383 /** 6384 * Tells the quick viewer to show additional UI actions suitable for the passed Uris, 6385 * such as opening in other apps, sharing, opening, editing, printing, deleting, 6386 * casting, etc. 6387 * 6388 * <p>The value is boolean. By default false. 6389 * @see #ACTION_QUICK_VIEW 6390 * @removed 6391 */ 6392 @Deprecated 6393 public static final String EXTRA_QUICK_VIEW_ADVANCED = 6394 "android.intent.extra.QUICK_VIEW_ADVANCED"; 6395 6396 /** 6397 * An optional extra of {@code String[]} indicating which quick view features should be made 6398 * available to the user in the quick view UI while handing a 6399 * {@link Intent#ACTION_QUICK_VIEW} intent. 6400 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer. 6401 * Quick viewer can implement features not listed below. 6402 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW}, 6403 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE}, 6404 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND}, 6405 * {@link QuickViewConstants#FEATURE_PRINT}. 6406 * <p> 6407 * Requirements: 6408 * <li>Quick viewer shouldn't show a feature if the feature is absent in 6409 * {@link #EXTRA_QUICK_VIEW_FEATURES}. 6410 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow 6411 * internal policies. 6412 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a 6413 * requirement that the feature be shown. Quick viewer may, according to its own policies, 6414 * disable or hide features. 6415 * 6416 * @see #ACTION_QUICK_VIEW 6417 */ 6418 public static final String EXTRA_QUICK_VIEW_FEATURES = 6419 "android.intent.extra.QUICK_VIEW_FEATURES"; 6420 6421 /** 6422 * Optional boolean extra indicating whether quiet mode has been switched on or off. 6423 * When a profile goes into quiet mode, all apps in the profile are killed and the 6424 * profile user is stopped. Widgets originating from the profile are masked, and app 6425 * launcher icons are grayed out. 6426 */ 6427 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE"; 6428 6429 /** 6430 * Optional CharSequence extra to provide a search query. 6431 * The format of this query is dependent on the receiving application. 6432 * 6433 * <p>Applicable to {@link Intent} with actions: 6434 * <ul> 6435 * <li>{@link Intent#ACTION_GET_CONTENT}</li> 6436 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li> 6437 * </ul> 6438 */ 6439 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY"; 6440 6441 /** 6442 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED} 6443 * intents to specify the resource type granted. Possible values are 6444 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or 6445 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}. 6446 * 6447 * @hide 6448 */ 6449 public static final String EXTRA_MEDIA_RESOURCE_TYPE = 6450 "android.intent.extra.MEDIA_RESOURCE_TYPE"; 6451 6452 /** 6453 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify 6454 * whether to show the chooser or not when there is only one application available 6455 * to choose from. 6456 */ 6457 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE = 6458 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE"; 6459 6460 /** 6461 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6462 * to represent that a video codec is allowed to use. 6463 * 6464 * @hide 6465 */ 6466 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0; 6467 6468 /** 6469 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE} 6470 * to represent that a audio codec is allowed to use. 6471 * 6472 * @hide 6473 */ 6474 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1; 6475 6476 /** 6477 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}. 6478 * 6479 * <p> 6480 * Type: {@link LocusId} 6481 * </p> 6482 */ 6483 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID"; 6484 6485 /** 6486 * Used as an int array extra field in 6487 * {@link android.content.Intent#ACTION_PACKAGE_REMOVED_INTERNAL} 6488 * intents to indicate that visibility allow list of this removed package. 6489 * 6490 * @hide 6491 */ 6492 public static final String EXTRA_VISIBILITY_ALLOW_LIST = 6493 "android.intent.extra.VISIBILITY_ALLOW_LIST"; 6494 6495 // --------------------------------------------------------------------- 6496 // --------------------------------------------------------------------- 6497 // Intent flags (see mFlags variable). 6498 6499 /** @hide */ 6500 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6501 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION, 6502 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION }) 6503 @Retention(RetentionPolicy.SOURCE) 6504 public @interface GrantUriMode {} 6505 6506 /** @hide */ 6507 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = { 6508 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION }) 6509 @Retention(RetentionPolicy.SOURCE) 6510 public @interface AccessUriMode {} 6511 6512 /** 6513 * Test if given mode flags specify an access mode, which must be at least 6514 * read and/or write. 6515 * 6516 * @hide 6517 */ isAccessUriMode(int modeFlags)6518 public static boolean isAccessUriMode(int modeFlags) { 6519 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION 6520 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0; 6521 } 6522 6523 /** @hide */ 6524 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 6525 FLAG_GRANT_READ_URI_PERMISSION, 6526 FLAG_GRANT_WRITE_URI_PERMISSION, 6527 FLAG_FROM_BACKGROUND, 6528 FLAG_DEBUG_LOG_RESOLUTION, 6529 FLAG_EXCLUDE_STOPPED_PACKAGES, 6530 FLAG_INCLUDE_STOPPED_PACKAGES, 6531 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, 6532 FLAG_GRANT_PREFIX_URI_PERMISSION, 6533 FLAG_DEBUG_TRIAGED_MISSING, 6534 FLAG_IGNORE_EPHEMERAL, 6535 FLAG_ACTIVITY_MATCH_EXTERNAL, 6536 FLAG_ACTIVITY_NO_HISTORY, 6537 FLAG_ACTIVITY_SINGLE_TOP, 6538 FLAG_ACTIVITY_NEW_TASK, 6539 FLAG_ACTIVITY_MULTIPLE_TASK, 6540 FLAG_ACTIVITY_CLEAR_TOP, 6541 FLAG_ACTIVITY_FORWARD_RESULT, 6542 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 6543 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 6544 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 6545 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 6546 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 6547 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6548 FLAG_ACTIVITY_NEW_DOCUMENT, 6549 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6550 FLAG_ACTIVITY_NO_USER_ACTION, 6551 FLAG_ACTIVITY_REORDER_TO_FRONT, 6552 FLAG_ACTIVITY_NO_ANIMATION, 6553 FLAG_ACTIVITY_CLEAR_TASK, 6554 FLAG_ACTIVITY_TASK_ON_HOME, 6555 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 6556 FLAG_ACTIVITY_LAUNCH_ADJACENT, 6557 FLAG_ACTIVITY_REQUIRE_NON_BROWSER, 6558 FLAG_ACTIVITY_REQUIRE_DEFAULT, 6559 FLAG_RECEIVER_REGISTERED_ONLY, 6560 FLAG_RECEIVER_REPLACE_PENDING, 6561 FLAG_RECEIVER_FOREGROUND, 6562 FLAG_RECEIVER_NO_ABORT, 6563 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 6564 FLAG_RECEIVER_BOOT_UPGRADE, 6565 FLAG_RECEIVER_INCLUDE_BACKGROUND, 6566 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 6567 FLAG_RECEIVER_FROM_SHELL, 6568 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 6569 FLAG_RECEIVER_OFFLOAD, 6570 FLAG_RECEIVER_OFFLOAD_FOREGROUND, 6571 }) 6572 @Retention(RetentionPolicy.SOURCE) 6573 public @interface Flags {} 6574 6575 /** @hide */ 6576 @IntDef(flag = true, prefix = { "FLAG_" }, value = { 6577 FLAG_FROM_BACKGROUND, 6578 FLAG_DEBUG_LOG_RESOLUTION, 6579 FLAG_EXCLUDE_STOPPED_PACKAGES, 6580 FLAG_INCLUDE_STOPPED_PACKAGES, 6581 FLAG_DEBUG_TRIAGED_MISSING, 6582 FLAG_IGNORE_EPHEMERAL, 6583 FLAG_ACTIVITY_MATCH_EXTERNAL, 6584 FLAG_ACTIVITY_NO_HISTORY, 6585 FLAG_ACTIVITY_SINGLE_TOP, 6586 FLAG_ACTIVITY_NEW_TASK, 6587 FLAG_ACTIVITY_MULTIPLE_TASK, 6588 FLAG_ACTIVITY_CLEAR_TOP, 6589 FLAG_ACTIVITY_FORWARD_RESULT, 6590 FLAG_ACTIVITY_PREVIOUS_IS_TOP, 6591 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS, 6592 FLAG_ACTIVITY_BROUGHT_TO_FRONT, 6593 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, 6594 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY, 6595 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6596 FLAG_ACTIVITY_NEW_DOCUMENT, 6597 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET, 6598 FLAG_ACTIVITY_NO_USER_ACTION, 6599 FLAG_ACTIVITY_REORDER_TO_FRONT, 6600 FLAG_ACTIVITY_NO_ANIMATION, 6601 FLAG_ACTIVITY_CLEAR_TASK, 6602 FLAG_ACTIVITY_TASK_ON_HOME, 6603 FLAG_ACTIVITY_RETAIN_IN_RECENTS, 6604 FLAG_ACTIVITY_LAUNCH_ADJACENT, 6605 FLAG_RECEIVER_REGISTERED_ONLY, 6606 FLAG_RECEIVER_REPLACE_PENDING, 6607 FLAG_RECEIVER_FOREGROUND, 6608 FLAG_RECEIVER_NO_ABORT, 6609 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT, 6610 FLAG_RECEIVER_BOOT_UPGRADE, 6611 FLAG_RECEIVER_INCLUDE_BACKGROUND, 6612 FLAG_RECEIVER_EXCLUDE_BACKGROUND, 6613 FLAG_RECEIVER_FROM_SHELL, 6614 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS, 6615 FLAG_RECEIVER_OFFLOAD, 6616 FLAG_RECEIVER_OFFLOAD_FOREGROUND, 6617 }) 6618 @Retention(RetentionPolicy.SOURCE) 6619 public @interface MutableFlags {} 6620 6621 /** 6622 * If set, the recipient of this Intent will be granted permission to 6623 * perform read operations on the URI in the Intent's data and any URIs 6624 * specified in its ClipData. When applying to an Intent's ClipData, 6625 * all URIs as well as recursive traversals through data or other ClipData 6626 * in Intent items will be granted; only the grant flags of the top-level 6627 * Intent are used. 6628 */ 6629 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001; 6630 /** 6631 * If set, the recipient of this Intent will be granted permission to 6632 * perform write operations on the URI in the Intent's data and any URIs 6633 * specified in its ClipData. When applying to an Intent's ClipData, 6634 * all URIs as well as recursive traversals through data or other ClipData 6635 * in Intent items will be granted; only the grant flags of the top-level 6636 * Intent are used. 6637 */ 6638 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002; 6639 /** 6640 * Can be set by the caller to indicate that this Intent is coming from 6641 * a background operation, not from direct user interaction. 6642 */ 6643 public static final int FLAG_FROM_BACKGROUND = 0x00000004; 6644 /** 6645 * A flag you can enable for debugging: when set, log messages will be 6646 * printed during the resolution of this intent to show you what has 6647 * been found to create the final resolved list. 6648 */ 6649 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008; 6650 /** 6651 * If set, this intent will not match any components in packages that 6652 * are currently stopped. If this is not set, then the default behavior 6653 * is to include such applications in the result. 6654 */ 6655 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010; 6656 /** 6657 * If set, this intent will always match any components in packages that 6658 * are currently stopped. This is the default behavior when 6659 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these 6660 * flags are set, this one wins (it allows overriding of exclude for 6661 * places where the framework may automatically set the exclude flag). 6662 */ 6663 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020; 6664 6665 /** 6666 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 6667 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be 6668 * persisted across device reboots until explicitly revoked with 6669 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the 6670 * grant for possible persisting; the receiving application must call 6671 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to 6672 * actually persist. 6673 * 6674 * @see ContentResolver#takePersistableUriPermission(Uri, int) 6675 * @see ContentResolver#releasePersistableUriPermission(Uri, int) 6676 * @see ContentResolver#getPersistedUriPermissions() 6677 * @see ContentResolver#getOutgoingPersistedUriPermissions() 6678 */ 6679 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040; 6680 6681 /** 6682 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or 6683 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant 6684 * applies to any URI that is a prefix match against the original granted 6685 * URI. (Without this flag, the URI must match exactly for access to be 6686 * granted.) Another URI is considered a prefix match only when scheme, 6687 * authority, and all path segments defined by the prefix are an exact 6688 * match. 6689 */ 6690 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080; 6691 6692 /** 6693 * Flag used to automatically match intents based on their Direct Boot 6694 * awareness and the current user state. 6695 * <p> 6696 * Since the default behavior is to automatically apply the current user 6697 * state, this is effectively a sentinel value that doesn't change the 6698 * output of any queries based on its presence or absence. 6699 * <p> 6700 * Instead, this value can be useful in conjunction with 6701 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()} 6702 * to detect when a caller is relying on implicit automatic matching, 6703 * instead of confirming the explicit behavior they want. 6704 */ 6705 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100; 6706 6707 /** {@hide} */ 6708 @Deprecated 6709 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO; 6710 6711 /** 6712 * Internal flag used to indicate ephemeral applications should not be 6713 * considered when resolving the intent. 6714 * 6715 * @hide 6716 */ 6717 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200; 6718 6719 /** 6720 * If set, the new activity is not kept in the history stack. As soon as 6721 * the user navigates away from it, the activity is finished. This may also 6722 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory 6723 * noHistory} attribute. 6724 * 6725 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} 6726 * is never invoked when the current activity starts a new activity which 6727 * sets a result and finishes. 6728 */ 6729 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000; 6730 /** 6731 * If set, the activity will not be launched if it is already running 6732 * at the top of the history stack. See 6733 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes"> 6734 * Tasks and Back Stack</a> for more information. 6735 */ 6736 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000; 6737 /** 6738 * If set, this activity will become the start of a new task on this 6739 * history stack. A task (from the activity that started it to the 6740 * next task activity) defines an atomic group of activities that the 6741 * user can move to. Tasks can be moved to the foreground and background; 6742 * all of the activities inside of a particular task always remain in 6743 * the same order. See 6744 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6745 * Stack</a> for more information about tasks. 6746 * 6747 * <p>This flag is generally used by activities that want 6748 * to present a "launcher" style behavior: they give the user a list of 6749 * separate things that can be done, which otherwise run completely 6750 * independently of the activity launching them. 6751 * 6752 * <p>When using this flag, if a task is already running for the activity 6753 * you are now starting, then a new activity will not be started; instead, 6754 * the current task will simply be brought to the front of the screen with 6755 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag 6756 * to disable this behavior. 6757 * 6758 * <p>This flag can not be used when the caller is requesting a result from 6759 * the activity being launched. 6760 */ 6761 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000; 6762 /** 6763 * This flag is used to create a new task and launch an activity into it. 6764 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} 6765 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would 6766 * search through existing tasks for ones matching this Intent. Only if no such 6767 * task is found would a new task be created. When paired with 6768 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip 6769 * the search for a matching task and unconditionally start a new task. 6770 * 6771 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this 6772 * flag unless you are implementing your own 6773 * top-level application launcher.</strong> Used in conjunction with 6774 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the 6775 * behavior of bringing an existing task to the foreground. When set, 6776 * a new task is <em>always</em> started to host the Activity for the 6777 * Intent, regardless of whether there is already an existing task running 6778 * the same thing. 6779 * 6780 * <p><strong>Because the default system does not include graphical task management, 6781 * you should not use this flag unless you provide some way for a user to 6782 * return back to the tasks you have launched.</strong> 6783 * 6784 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for 6785 * creating new document tasks. 6786 * 6787 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or 6788 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. 6789 * 6790 * <p>See 6791 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6792 * Stack</a> for more information about tasks. 6793 * 6794 * @see #FLAG_ACTIVITY_NEW_DOCUMENT 6795 * @see #FLAG_ACTIVITY_NEW_TASK 6796 */ 6797 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000; 6798 /** 6799 * If set, and the activity being launched is already running in the 6800 * current task, then instead of launching a new instance of that activity, 6801 * all of the other activities on top of it will be closed and this Intent 6802 * will be delivered to the (now on top) old activity as a new Intent. 6803 * 6804 * <p>For example, consider a task consisting of the activities: A, B, C, D. 6805 * If D calls startActivity() with an Intent that resolves to the component 6806 * of activity B, then C and D will be finished and B receive the given 6807 * Intent, resulting in the stack now being: A, B. 6808 * 6809 * <p>The currently running instance of activity B in the above example will 6810 * either receive the new intent you are starting here in its 6811 * onNewIntent() method, or be itself finished and restarted with the 6812 * new intent. If it has declared its launch mode to be "multiple" (the 6813 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in 6814 * the same intent, then it will be finished and re-created; for all other 6815 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this 6816 * Intent will be delivered to the current instance's onNewIntent(). 6817 * 6818 * <p>This launch mode can also be used to good effect in conjunction with 6819 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity 6820 * of a task, it will bring any currently running instance of that task 6821 * to the foreground, and then clear it to its root state. This is 6822 * especially useful, for example, when launching an activity from the 6823 * notification manager. 6824 * 6825 * <p>See 6826 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 6827 * Stack</a> for more information about tasks. 6828 */ 6829 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000; 6830 /** 6831 * If set and this intent is being used to launch a new activity from an 6832 * existing one, then the reply target of the existing activity will be 6833 * transferred to the new activity. This way, the new activity can call 6834 * {@link android.app.Activity#setResult} and have that result sent back to 6835 * the reply target of the original activity. 6836 */ 6837 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000; 6838 /** 6839 * If set and this intent is being used to launch a new activity from an 6840 * existing one, the current activity will not be counted as the top 6841 * activity for deciding whether the new intent should be delivered to 6842 * the top instead of starting a new one. The previous activity will 6843 * be used as the top, with the assumption being that the current activity 6844 * will finish itself immediately. 6845 */ 6846 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000; 6847 /** 6848 * If set, the new activity is not kept in the list of recently launched 6849 * activities. 6850 */ 6851 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000; 6852 /** 6853 * This flag is not normally set by application code, but set for you by 6854 * the system as described in the 6855 * {@link android.R.styleable#AndroidManifestActivity_launchMode 6856 * launchMode} documentation for the singleTask mode. 6857 */ 6858 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000; 6859 /** 6860 * If set, and this activity is either being started in a new task or 6861 * bringing to the top an existing task, then it will be launched as 6862 * the front door of the task. This will result in the application of 6863 * any affinities needed to have that task in the proper state (either 6864 * moving activities to or from it), or simply resetting that task to 6865 * its initial state if needed. 6866 * 6867 * @see android.R.attr#allowTaskReparenting 6868 * @see android.R.attr#clearTaskOnLaunch 6869 * @see android.R.attr#finishOnTaskLaunch 6870 */ 6871 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000; 6872 /** 6873 * This flag is not normally set by application code, but set for you by 6874 * the system if this activity is being launched from history. 6875 */ 6876 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000; 6877 /** 6878 * @deprecated As of API 21 this performs identically to 6879 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this. 6880 */ 6881 @Deprecated 6882 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000; 6883 /** 6884 * This flag is used to open a document into a new task rooted at the activity launched 6885 * by this Intent. Through the use of this flag, or its equivalent attribute, 6886 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity 6887 * containing different documents will appear in the recent tasks list. 6888 * 6889 * <p>The use of the activity attribute form of this, 6890 * {@link android.R.attr#documentLaunchMode}, is 6891 * preferred over the Intent flag described here. The attribute form allows the 6892 * Activity to specify multiple document behavior for all launchers of the Activity 6893 * whereas using this flag requires each Intent that launches the Activity to specify it. 6894 * 6895 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for 6896 * it is kept after the activity is finished is different than the use of 6897 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if 6898 * this flag is being used to create a new recents entry, then by default that entry 6899 * will be removed once the activity is finished. You can modify this behavior with 6900 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. 6901 * 6902 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link 6903 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the 6904 * equivalent of the Activity manifest specifying {@link 6905 * android.R.attr#documentLaunchMode}="intoExisting". When used with 6906 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying 6907 * {@link android.R.attr#documentLaunchMode}="always". The flag is ignored even in 6908 * conjunction with {@link #FLAG_ACTIVITY_MULTIPLE_TASK} when the Activity manifest specifies 6909 * {@link android.R.attr#documentLaunchMode}="never". 6910 * 6911 * Refer to {@link android.R.attr#documentLaunchMode} for more information. 6912 * 6913 * @see android.R.attr#documentLaunchMode 6914 * @see #FLAG_ACTIVITY_MULTIPLE_TASK 6915 */ 6916 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET; 6917 /** 6918 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} 6919 * callback from occurring on the current frontmost activity before it is 6920 * paused as the newly-started activity is brought to the front. 6921 * 6922 * <p>Typically, an activity can rely on that callback to indicate that an 6923 * explicit user action has caused their activity to be moved out of the 6924 * foreground. The callback marks an appropriate point in the activity's 6925 * lifecycle for it to dismiss any notifications that it intends to display 6926 * "until the user has seen them," such as a blinking LED. 6927 * 6928 * <p>If an activity is ever started via any non-user-driven events such as 6929 * phone-call receipt or an alarm handler, this flag should be passed to {@link 6930 * Context#startActivity Context.startActivity}, ensuring that the pausing 6931 * activity does not think the user has acknowledged its notification. 6932 */ 6933 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000; 6934 /** 6935 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6936 * this flag will cause the launched activity to be brought to the front of its 6937 * task's history stack if it is already running. 6938 * 6939 * <p>For example, consider a task consisting of four activities: A, B, C, D. 6940 * If D calls startActivity() with an Intent that resolves to the component 6941 * of activity B, then B will be brought to the front of the history stack, 6942 * with this resulting order: A, C, D, B. 6943 * 6944 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also 6945 * specified. 6946 */ 6947 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000; 6948 /** 6949 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6950 * this flag will prevent the system from applying an activity transition 6951 * animation to go to the next activity state. This doesn't mean an 6952 * animation will never run -- if another activity change happens that doesn't 6953 * specify this flag before the activity started here is displayed, then 6954 * that transition will be used. This flag can be put to good use 6955 * when you are going to do a series of activity operations but the 6956 * animation seen by the user shouldn't be driven by the first activity 6957 * change but rather a later one. 6958 */ 6959 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000; 6960 /** 6961 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6962 * this flag will cause any existing task that would be associated with the 6963 * activity to be cleared before the activity is started. That is, the activity 6964 * becomes the new root of an otherwise empty task, and any old activities 6965 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 6966 */ 6967 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000; 6968 /** 6969 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 6970 * this flag will cause a newly launching task to be placed on top of the current 6971 * home activity task (if there is one). That is, pressing back from the task 6972 * will always return the user to home even if that was not the last activity they 6973 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. 6974 */ 6975 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000; 6976 /** 6977 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will 6978 * have its entry in recent tasks removed when the user closes it (with back 6979 * or however else it may finish()). If you would like to instead allow the 6980 * document to be kept in recents so that it can be re-launched, you can use 6981 * this flag. When set and the task's activity is finished, the recents 6982 * entry will remain in the interface for the user to re-launch it, like a 6983 * recents entry for a top-level application. 6984 * <p> 6985 * The receiving activity can override this request with 6986 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling 6987 * {@link android.app.Activity#finishAndRemoveTask() 6988 * Activity.finishAndRemoveTask()}. 6989 */ 6990 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000; 6991 6992 /** 6993 * This flag is only used for split-screen multi-window mode. The new activity will be displayed 6994 * adjacent to the one launching it. This can only be used in conjunction with 6995 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is 6996 * required if you want a new instance of an existing activity to be created. 6997 */ 6998 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000; 6999 7000 7001 /** 7002 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, 7003 * this flag will attempt to launch an instant app if no full app on the device can already 7004 * handle the intent. 7005 * <p> 7006 * When attempting to resolve instant apps externally, the following {@link Intent} properties 7007 * are supported: 7008 * <ul> 7009 * <li>{@link Intent#setAction(String)}</li> 7010 * <li>{@link Intent#addCategory(String)}</li> 7011 * <li>{@link Intent#setData(Uri)}</li> 7012 * <li>{@link Intent#setType(String)}</li> 7013 * <li>{@link Intent#setPackage(String)}</li> 7014 * <li>{@link Intent#addFlags(int)}</li> 7015 * </ul> 7016 * <p> 7017 * In the case that no instant app can be found, the installer will be launched to notify the 7018 * user that the intent could not be resolved. On devices that do not support instant apps, 7019 * the flag will be ignored. 7020 */ 7021 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800; 7022 7023 /** 7024 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 7025 * flag will only launch the intent if it resolves to a result that is not a browser. If no such 7026 * result exists, an {@link ActivityNotFoundException} will be thrown. 7027 */ 7028 public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400; 7029 7030 /** 7031 * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this 7032 * flag will only launch the intent if it resolves to a single result. If no such result exists 7033 * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException} 7034 * will be thrown. 7035 */ 7036 public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200; 7037 7038 /** 7039 * If set, when sending a broadcast only registered receivers will be 7040 * called -- no BroadcastReceiver components will be launched. 7041 */ 7042 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000; 7043 /** 7044 * If set, when sending a broadcast the new broadcast will replace 7045 * any existing pending broadcast that matches it. Matching is defined 7046 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning 7047 * true for the intents of the two broadcasts. When a match is found, 7048 * the new broadcast (and receivers associated with it) will replace the 7049 * existing one in the pending broadcast list, remaining at the same 7050 * position in the list. 7051 * 7052 * <p>This flag is most typically used with sticky broadcasts, which 7053 * only care about delivering the most recent values of the broadcast 7054 * to their receivers. 7055 */ 7056 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000; 7057 /** 7058 * If set, when sending a broadcast the recipient is allowed to run at 7059 * foreground priority, with a shorter timeout interval. During normal 7060 * broadcasts the receivers are not automatically hoisted out of the 7061 * background priority class. 7062 */ 7063 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000; 7064 /** 7065 * If set, when sending a broadcast the recipient will be run on the offload queue. 7066 * 7067 * @hide 7068 */ 7069 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000; 7070 /** 7071 * If set, when sending a broadcast the recipient will run on the system dedicated queue. 7072 * 7073 * @hide 7074 */ 7075 public static final int FLAG_RECEIVER_OFFLOAD_FOREGROUND = 0x00000800; 7076 7077 /** 7078 * If this is an ordered broadcast, don't allow receivers to abort the broadcast. 7079 * They can still propagate results through to later receivers, but they can not prevent 7080 * later receivers from seeing the broadcast. 7081 */ 7082 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000; 7083 /** 7084 * If set, when sending a broadcast <i>before the system has fully booted up 7085 * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only 7086 * registered receivers will be called -- no BroadcastReceiver components 7087 * will be launched. Sticky intent state will be recorded properly even 7088 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} 7089 * is specified in the broadcast intent, this flag is unnecessary. 7090 * 7091 * <p>This flag is only for use by system services (even services from mainline modules) as a 7092 * convenience to avoid having to implement a more complex mechanism around detection 7093 * of boot completion. 7094 * 7095 * <p>This is useful to system server mainline modules 7096 * 7097 * @hide 7098 */ 7099 @SystemApi 7100 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000; 7101 /** 7102 * Set when this broadcast is for a boot upgrade, a special mode that 7103 * allows the broadcast to be sent before the system is ready and launches 7104 * the app process with no providers running in it. 7105 * @hide 7106 */ 7107 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000; 7108 /** 7109 * If set, the broadcast will always go to manifest receivers in background (cached 7110 * or not running) apps, regardless of whether that would be done by default. By 7111 * default they will only receive broadcasts if the broadcast has specified an 7112 * explicit component or package name. 7113 * 7114 * NOTE: dumpstate uses this flag numerically, so when its value is changed 7115 * the broadcast code there must also be changed to match. 7116 * 7117 * @hide 7118 */ 7119 @SystemApi 7120 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000; 7121 /** 7122 * If set, the broadcast will never go to manifest receivers in background (cached 7123 * or not running) apps, regardless of whether that would be done by default. By 7124 * default they will receive broadcasts if the broadcast has specified an 7125 * explicit component or package name. 7126 * @hide 7127 */ 7128 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000; 7129 /** 7130 * If set, this broadcast is being sent from the shell. 7131 * @hide 7132 */ 7133 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000; 7134 7135 /** 7136 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps 7137 * will not receive broadcasts. 7138 * 7139 * <em>This flag has no effect when used by an Instant App.</em> 7140 */ 7141 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000; 7142 7143 /** 7144 * @hide Flags that can't be changed with PendingIntent. 7145 */ 7146 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION 7147 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION 7148 | FLAG_GRANT_PREFIX_URI_PERMISSION; 7149 7150 /** 7151 * Local flag indicating this instance was created by copy constructor. 7152 */ 7153 private static final int LOCAL_FLAG_FROM_COPY = 1 << 0; 7154 7155 /** 7156 * Local flag indicating this instance was created from a {@link Parcel}. 7157 */ 7158 private static final int LOCAL_FLAG_FROM_PARCEL = 1 << 1; 7159 7160 /** 7161 * Local flag indicating this instance was delivered through a protected 7162 * component, such as an activity that requires a signature permission, or a 7163 * protected broadcast. Note that this flag <em>cannot</em> be recursively 7164 * applied to any contained instances, since a malicious app may have 7165 * controlled them via {@link #fillIn(Intent, int)}. 7166 */ 7167 private static final int LOCAL_FLAG_FROM_PROTECTED_COMPONENT = 1 << 2; 7168 7169 /** 7170 * Local flag indicating this instance had unfiltered extras copied into it. This could be 7171 * from either {@link #putExtras(Intent)} when an unparceled Intent is provided or {@link 7172 * #putExtras(Bundle)} when the provided Bundle has not been unparceled. 7173 */ 7174 private static final int LOCAL_FLAG_UNFILTERED_EXTRAS = 1 << 3; 7175 7176 /** 7177 * Local flag indicating this instance was created from a {@link Uri}. 7178 */ 7179 private static final int LOCAL_FLAG_FROM_URI = 1 << 4; 7180 7181 // --------------------------------------------------------------------- 7182 // --------------------------------------------------------------------- 7183 // toUri() and parseUri() options. 7184 7185 /** @hide */ 7186 @IntDef(flag = true, prefix = { "URI_" }, value = { 7187 URI_ALLOW_UNSAFE, 7188 URI_ANDROID_APP_SCHEME, 7189 URI_INTENT_SCHEME, 7190 }) 7191 @Retention(RetentionPolicy.SOURCE) 7192 public @interface UriFlags {} 7193 7194 /** 7195 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 7196 * always has the "intent:" scheme. This syntax can be used when you want 7197 * to later disambiguate between URIs that are intended to describe an 7198 * Intent vs. all others that should be treated as raw URIs. When used 7199 * with {@link #parseUri}, any other scheme will result in a generic 7200 * VIEW action for that raw URI. 7201 */ 7202 public static final int URI_INTENT_SCHEME = 1<<0; 7203 7204 /** 7205 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string 7206 * always has the "android-app:" scheme. This is a variation of 7207 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an 7208 * http/https URI being delivered to a specific package name. The format 7209 * is: 7210 * 7211 * <pre class="prettyprint"> 7212 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre> 7213 * 7214 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host, 7215 * you must also include a scheme; including a path also requires both a host and a scheme. 7216 * The final #Intent; fragment can be used without a scheme, host, or path. 7217 * Note that this can not be 7218 * used with intents that have a {@link #setSelector}, since the base intent 7219 * will always have an explicit package name.</p> 7220 * 7221 * <p>Some examples of how this scheme maps to Intent objects:</p> 7222 * <table border="2" width="85%" align="center" frame="hsides" rules="rows"> 7223 * <colgroup align="left" /> 7224 * <colgroup align="left" /> 7225 * <thead> 7226 * <tr><th>URI</th> <th>Intent</th></tr> 7227 * </thead> 7228 * 7229 * <tbody> 7230 * <tr><td><code>android-app://com.example.app</code></td> 7231 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7232 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr> 7233 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7234 * </table></td> 7235 * </tr> 7236 * <tr><td><code>android-app://com.example.app/http/example.com</code></td> 7237 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7238 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 7239 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr> 7240 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7241 * </table></td> 7242 * </tr> 7243 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td> 7244 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7245 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr> 7246 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 7247 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7248 * </table></td> 7249 * </tr> 7250 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td> 7251 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7252 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7253 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7254 * </table></td> 7255 * </tr> 7256 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td> 7257 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0"> 7258 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7259 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr> 7260 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7261 * </table></td> 7262 * </tr> 7263 * <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> 7264 * <td><table border="" style="margin:0" > 7265 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr> 7266 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr> 7267 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr> 7268 * </table></td> 7269 * </tr> 7270 * </tbody> 7271 * </table> 7272 */ 7273 public static final int URI_ANDROID_APP_SCHEME = 1<<1; 7274 7275 /** 7276 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing 7277 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION}, 7278 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION}, 7279 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the 7280 * generated Intent can not cause unexpected data access to happen. 7281 * 7282 * <p>If you do not trust the source of the URI being parsed, you should still do further 7283 * processing to protect yourself from it. In particular, when using it to start an 7284 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities 7285 * that can handle it.</p> 7286 */ 7287 public static final int URI_ALLOW_UNSAFE = 1<<2; 7288 7289 // --------------------------------------------------------------------- 7290 7291 private String mAction; 7292 private Uri mData; 7293 private String mType; 7294 private String mIdentifier; 7295 private String mPackage; 7296 private ComponentName mComponent; 7297 private int mFlags; 7298 /** Set of in-process flags which are never parceled */ 7299 private int mLocalFlags; 7300 private ArraySet<String> mCategories; 7301 @UnsupportedAppUsage 7302 private Bundle mExtras; 7303 private Rect mSourceBounds; 7304 private Intent mSelector; 7305 private ClipData mClipData; 7306 private int mContentUserHint = UserHandle.USER_CURRENT; 7307 /** Token to track instant app launches. Local only; do not copy cross-process. */ 7308 private String mLaunchToken; 7309 private Intent mOriginalIntent; // Used for the experimental "component alias" feature. 7310 7311 // --------------------------------------------------------------------- 7312 7313 private static final int COPY_MODE_ALL = 0; 7314 private static final int COPY_MODE_FILTER = 1; 7315 private static final int COPY_MODE_HISTORY = 2; 7316 7317 /** @hide */ 7318 @IntDef(prefix = { "COPY_MODE_" }, value = { 7319 COPY_MODE_ALL, 7320 COPY_MODE_FILTER, 7321 COPY_MODE_HISTORY 7322 }) 7323 @Retention(RetentionPolicy.SOURCE) 7324 public @interface CopyMode {} 7325 7326 /** 7327 * Create an empty intent. 7328 */ Intent()7329 public Intent() { 7330 } 7331 7332 /** 7333 * Copy constructor. 7334 */ Intent(Intent o)7335 public Intent(Intent o) { 7336 this(o, COPY_MODE_ALL); 7337 } 7338 Intent(Intent o, @CopyMode int copyMode)7339 private Intent(Intent o, @CopyMode int copyMode) { 7340 this.mAction = o.mAction; 7341 this.mData = o.mData; 7342 this.mType = o.mType; 7343 this.mIdentifier = o.mIdentifier; 7344 this.mPackage = o.mPackage; 7345 this.mComponent = o.mComponent; 7346 this.mOriginalIntent = o.mOriginalIntent; 7347 7348 if (o.mCategories != null) { 7349 this.mCategories = new ArraySet<>(o.mCategories); 7350 } 7351 7352 // Inherit flags from the original, plus mark that we were 7353 // created by this copy constructor 7354 this.mLocalFlags = o.mLocalFlags; 7355 this.mLocalFlags |= LOCAL_FLAG_FROM_COPY; 7356 7357 if (copyMode != COPY_MODE_FILTER) { 7358 this.mFlags = o.mFlags; 7359 this.mContentUserHint = o.mContentUserHint; 7360 this.mLaunchToken = o.mLaunchToken; 7361 if (o.mSourceBounds != null) { 7362 this.mSourceBounds = new Rect(o.mSourceBounds); 7363 } 7364 if (o.mSelector != null) { 7365 this.mSelector = new Intent(o.mSelector); 7366 } 7367 7368 if (copyMode != COPY_MODE_HISTORY) { 7369 if (o.mExtras != null) { 7370 this.mExtras = new Bundle(o.mExtras); 7371 } 7372 if (o.mClipData != null) { 7373 this.mClipData = new ClipData(o.mClipData); 7374 } 7375 } else { 7376 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) { 7377 this.mExtras = Bundle.STRIPPED; 7378 } 7379 7380 // Also set "stripped" clip data when we ever log mClipData in the (broadcast) 7381 // history. 7382 } 7383 } 7384 } 7385 7386 @Override clone()7387 public Object clone() { 7388 return new Intent(this); 7389 } 7390 7391 /** 7392 * Make a clone of only the parts of the Intent that are relevant for 7393 * filter matching: the action, data, type, component, and categories. 7394 */ cloneFilter()7395 public @NonNull Intent cloneFilter() { 7396 return new Intent(this, COPY_MODE_FILTER); 7397 } 7398 7399 /** 7400 * Create an intent with a given action. All other fields (data, type, 7401 * class) are null. Note that the action <em>must</em> be in a 7402 * namespace because Intents are used globally in the system -- for 7403 * example the system VIEW action is android.intent.action.VIEW; an 7404 * application's custom action would be something like 7405 * com.google.app.myapp.CUSTOM_ACTION. 7406 * 7407 * @param action The Intent action, such as ACTION_VIEW. 7408 */ Intent(String action)7409 public Intent(String action) { 7410 setAction(action); 7411 } 7412 7413 /** 7414 * Create an intent with a given action and for a given data url. Note 7415 * that the action <em>must</em> be in a namespace because Intents are 7416 * used globally in the system -- for example the system VIEW action is 7417 * android.intent.action.VIEW; an application's custom action would be 7418 * something like com.google.app.myapp.CUSTOM_ACTION. 7419 * 7420 * <p><em>Note: scheme and host name matching in the Android framework is 7421 * case-sensitive, unlike the formal RFC. As a result, 7422 * you should always ensure that you write your Uri with these elements 7423 * using lower case letters, and normalize any Uris you receive from 7424 * outside of Android to ensure the scheme and host is lower case.</em></p> 7425 * 7426 * @param action The Intent action, such as ACTION_VIEW. 7427 * @param uri The Intent data URI. 7428 */ Intent(String action, Uri uri)7429 public Intent(String action, Uri uri) { 7430 setAction(action); 7431 mData = uri; 7432 } 7433 7434 /** 7435 * Create an intent for a specific component. All other fields (action, data, 7436 * type, class) are null, though they can be modified later with explicit 7437 * calls. This provides a convenient way to create an intent that is 7438 * intended to execute a hard-coded class name, rather than relying on the 7439 * system to find an appropriate class for you; see {@link #setComponent} 7440 * for more information on the repercussions of this. 7441 * 7442 * @param packageContext A Context of the application package implementing 7443 * this class. 7444 * @param cls The component class that is to be used for the intent. 7445 * 7446 * @see #setClass 7447 * @see #setComponent 7448 * @see #Intent(String, android.net.Uri , Context, Class) 7449 */ Intent(Context packageContext, Class<?> cls)7450 public Intent(Context packageContext, Class<?> cls) { 7451 mComponent = new ComponentName(packageContext, cls); 7452 } 7453 7454 /** 7455 * Create an intent for a specific component with a specified action and data. 7456 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to 7457 * construct the Intent and then calling {@link #setClass} to set its 7458 * class. 7459 * 7460 * <p><em>Note: scheme and host name matching in the Android framework is 7461 * case-sensitive, unlike the formal RFC. As a result, 7462 * you should always ensure that you write your Uri with these elements 7463 * using lower case letters, and normalize any Uris you receive from 7464 * outside of Android to ensure the scheme and host is lower case.</em></p> 7465 * 7466 * @param action The Intent action, such as ACTION_VIEW. 7467 * @param uri The Intent data URI. 7468 * @param packageContext A Context of the application package implementing 7469 * this class. 7470 * @param cls The component class that is to be used for the intent. 7471 * 7472 * @see #Intent(String, android.net.Uri) 7473 * @see #Intent(Context, Class) 7474 * @see #setClass 7475 * @see #setComponent 7476 */ Intent(String action, Uri uri, Context packageContext, Class<?> cls)7477 public Intent(String action, Uri uri, 7478 Context packageContext, Class<?> cls) { 7479 setAction(action); 7480 mData = uri; 7481 mComponent = new ComponentName(packageContext, cls); 7482 } 7483 7484 /** 7485 * Create an intent to launch the main (root) activity of a task. This 7486 * is the Intent that is started when the application's is launched from 7487 * Home. For anything else that wants to launch an application in the 7488 * same way, it is important that they use an Intent structured the same 7489 * way, and can use this function to ensure this is the case. 7490 * 7491 * <p>The returned Intent has the given Activity component as its explicit 7492 * component, {@link #ACTION_MAIN} as its action, and includes the 7493 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 7494 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 7495 * to do that through {@link #addFlags(int)} on the returned Intent. 7496 * 7497 * @param mainActivity The main activity component that this Intent will 7498 * launch. 7499 * @return Returns a newly created Intent that can be used to launch the 7500 * activity as a main application entry. 7501 * 7502 * @see #setClass 7503 * @see #setComponent 7504 */ makeMainActivity(ComponentName mainActivity)7505 public static Intent makeMainActivity(ComponentName mainActivity) { 7506 Intent intent = new Intent(ACTION_MAIN); 7507 intent.setComponent(mainActivity); 7508 intent.addCategory(CATEGORY_LAUNCHER); 7509 return intent; 7510 } 7511 7512 /** 7513 * Make an Intent for the main activity of an application, without 7514 * specifying a specific activity to run but giving a selector to find 7515 * the activity. This results in a final Intent that is structured 7516 * the same as when the application is launched from 7517 * Home. For anything else that wants to launch an application in the 7518 * same way, it is important that they use an Intent structured the same 7519 * way, and can use this function to ensure this is the case. 7520 * 7521 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the 7522 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have 7523 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want 7524 * to do that through {@link #addFlags(int)} on the returned Intent. 7525 * 7526 * @param selectorAction The action name of the Intent's selector. 7527 * @param selectorCategory The name of a category to add to the Intent's 7528 * selector. 7529 * @return Returns a newly created Intent that can be used to launch the 7530 * activity as a main application entry. 7531 * 7532 * @see #setSelector(Intent) 7533 */ makeMainSelectorActivity(String selectorAction, String selectorCategory)7534 public static Intent makeMainSelectorActivity(String selectorAction, 7535 String selectorCategory) { 7536 Intent intent = new Intent(ACTION_MAIN); 7537 intent.addCategory(CATEGORY_LAUNCHER); 7538 Intent selector = new Intent(); 7539 selector.setAction(selectorAction); 7540 selector.addCategory(selectorCategory); 7541 intent.setSelector(selector); 7542 return intent; 7543 } 7544 7545 /** 7546 * Make an Intent that can be used to re-launch an application's task 7547 * in its base state. This is like {@link #makeMainActivity(ComponentName)}, 7548 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and 7549 * {@link #FLAG_ACTIVITY_CLEAR_TASK}. 7550 * 7551 * @param mainActivity The activity component that is the root of the 7552 * task; this is the activity that has been published in the application's 7553 * manifest as the main launcher icon. 7554 * 7555 * @return Returns a newly created Intent that can be used to relaunch the 7556 * activity's task in its root state. 7557 */ makeRestartActivityTask(ComponentName mainActivity)7558 public static Intent makeRestartActivityTask(ComponentName mainActivity) { 7559 Intent intent = makeMainActivity(mainActivity); 7560 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK 7561 | Intent.FLAG_ACTIVITY_CLEAR_TASK); 7562 return intent; 7563 } 7564 7565 /** 7566 * Call {@link #parseUri} with 0 flags. 7567 * @deprecated Use {@link #parseUri} instead. 7568 */ 7569 @Deprecated getIntent(String uri)7570 public static Intent getIntent(String uri) throws URISyntaxException { 7571 return parseUri(uri, 0); 7572 } 7573 7574 /** 7575 * Create an intent from a URI. This URI may encode the action, 7576 * category, and other intent fields, if it was returned by 7577 * {@link #toUri}. If the Intent was not generate by toUri(), its data 7578 * will be the entire URI and its action will be ACTION_VIEW. 7579 * 7580 * <p>The URI given here must not be relative -- that is, it must include 7581 * the scheme and full path. 7582 * 7583 * @param uri The URI to turn into an Intent. 7584 * @param flags Additional processing flags. 7585 * 7586 * @return Intent The newly created Intent object. 7587 * 7588 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax 7589 * it bad (as parsed by the Uri class) or the Intent data within the 7590 * URI is invalid. 7591 * 7592 * @see #toUri 7593 */ parseUri(String uri, @UriFlags int flags)7594 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException { 7595 Intent intent = parseUriInternal(uri, flags); 7596 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 7597 return intent; 7598 } 7599 7600 /** 7601 * @see #parseUri(String, int) 7602 */ parseUriInternal(String uri, @UriFlags int flags)7603 private static Intent parseUriInternal(String uri, @UriFlags int flags) 7604 throws URISyntaxException { 7605 int i = 0; 7606 try { 7607 final boolean androidApp = uri.startsWith("android-app:"); 7608 7609 // Validate intent scheme if requested. 7610 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) { 7611 if (!uri.startsWith("intent:") && !androidApp) { 7612 Intent intent = new Intent(ACTION_VIEW); 7613 try { 7614 intent.setData(Uri.parse(uri)); 7615 } catch (IllegalArgumentException e) { 7616 throw new URISyntaxException(uri, e.getMessage()); 7617 } 7618 return intent; 7619 } 7620 } 7621 7622 i = uri.lastIndexOf("#"); 7623 // simple case 7624 if (i == -1) { 7625 if (!androidApp) { 7626 return new Intent(ACTION_VIEW, Uri.parse(uri)); 7627 } 7628 7629 // old format Intent URI 7630 } else if (!uri.startsWith("#Intent;", i)) { 7631 if (!androidApp) { 7632 return getIntentOld(uri, flags); 7633 } else { 7634 i = -1; 7635 } 7636 } 7637 7638 // new format 7639 Intent intent = new Intent(ACTION_VIEW); 7640 Intent baseIntent = intent; 7641 boolean explicitAction = false; 7642 boolean inSelector = false; 7643 7644 // fetch data part, if present 7645 String scheme = null; 7646 String data; 7647 if (i >= 0) { 7648 data = uri.substring(0, i); 7649 i += 8; // length of "#Intent;" 7650 } else { 7651 data = uri; 7652 } 7653 7654 // loop over contents of Intent, all name=value; 7655 while (i >= 0 && !uri.startsWith("end", i)) { 7656 int eq = uri.indexOf('=', i); 7657 if (eq < 0) eq = i-1; 7658 int semi = uri.indexOf(';', i); 7659 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : ""; 7660 7661 // action 7662 if (uri.startsWith("action=", i)) { 7663 intent.setAction(value); 7664 if (!inSelector) { 7665 explicitAction = true; 7666 } 7667 } 7668 7669 // categories 7670 else if (uri.startsWith("category=", i)) { 7671 intent.addCategory(value); 7672 } 7673 7674 // type 7675 else if (uri.startsWith("type=", i)) { 7676 intent.mType = value; 7677 } 7678 7679 // identifier 7680 else if (uri.startsWith("identifier=", i)) { 7681 intent.mIdentifier = value; 7682 } 7683 7684 // launch flags 7685 else if (uri.startsWith("launchFlags=", i)) { 7686 intent.mFlags = Integer.decode(value).intValue(); 7687 if ((flags& URI_ALLOW_UNSAFE) == 0) { 7688 intent.mFlags &= ~IMMUTABLE_FLAGS; 7689 } 7690 } 7691 7692 // package 7693 else if (uri.startsWith("package=", i)) { 7694 intent.mPackage = value; 7695 } 7696 7697 // component 7698 else if (uri.startsWith("component=", i)) { 7699 intent.mComponent = ComponentName.unflattenFromString(value); 7700 } 7701 7702 // scheme 7703 else if (uri.startsWith("scheme=", i)) { 7704 if (inSelector) { 7705 intent.mData = Uri.parse(value + ":"); 7706 } else { 7707 scheme = value; 7708 } 7709 } 7710 7711 // source bounds 7712 else if (uri.startsWith("sourceBounds=", i)) { 7713 intent.mSourceBounds = Rect.unflattenFromString(value); 7714 } 7715 7716 // selector 7717 else if (semi == (i+3) && uri.startsWith("SEL", i)) { 7718 intent = new Intent(); 7719 inSelector = true; 7720 } 7721 7722 // extra 7723 else { 7724 String key = Uri.decode(uri.substring(i + 2, eq)); 7725 // create Bundle if it doesn't already exist 7726 if (intent.mExtras == null) intent.mExtras = new Bundle(); 7727 Bundle b = intent.mExtras; 7728 // add EXTRA 7729 if (uri.startsWith("S.", i)) b.putString(key, value); 7730 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value)); 7731 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value)); 7732 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0)); 7733 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value)); 7734 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value)); 7735 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value)); 7736 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value)); 7737 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value)); 7738 else throw new URISyntaxException(uri, "unknown EXTRA type", i); 7739 } 7740 7741 // move to the next item 7742 i = semi + 1; 7743 } 7744 7745 if (inSelector) { 7746 // The Intent had a selector; fix it up. 7747 if (baseIntent.mPackage == null) { 7748 baseIntent.setSelector(intent); 7749 } 7750 intent = baseIntent; 7751 } 7752 7753 if (data != null) { 7754 if (data.startsWith("intent:")) { 7755 data = data.substring(7); 7756 if (scheme != null) { 7757 data = scheme + ':' + data; 7758 } 7759 } else if (data.startsWith("android-app:")) { 7760 if (data.charAt(12) == '/' && data.charAt(13) == '/') { 7761 // Correctly formed android-app, first part is package name. 7762 int end = data.indexOf('/', 14); 7763 if (end < 0) { 7764 // All we have is a package name. 7765 intent.mPackage = data.substring(14); 7766 if (!explicitAction) { 7767 intent.setAction(ACTION_MAIN); 7768 } 7769 data = ""; 7770 } else { 7771 // Target the Intent at the given package name always. 7772 String authority = null; 7773 intent.mPackage = data.substring(14, end); 7774 int newEnd; 7775 if ((end+1) < data.length()) { 7776 if ((newEnd=data.indexOf('/', end+1)) >= 0) { 7777 // Found a scheme, remember it. 7778 scheme = data.substring(end+1, newEnd); 7779 end = newEnd; 7780 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) { 7781 // Found a authority, remember it. 7782 authority = data.substring(end+1, newEnd); 7783 end = newEnd; 7784 } 7785 } else { 7786 // All we have is a scheme. 7787 scheme = data.substring(end+1); 7788 } 7789 } 7790 if (scheme == null) { 7791 // If there was no scheme, then this just targets the package. 7792 if (!explicitAction) { 7793 intent.setAction(ACTION_MAIN); 7794 } 7795 data = ""; 7796 } else if (authority == null) { 7797 data = scheme + ":"; 7798 } else { 7799 data = scheme + "://" + authority + data.substring(end); 7800 } 7801 } 7802 } else { 7803 data = ""; 7804 } 7805 } 7806 7807 if (data.length() > 0) { 7808 try { 7809 intent.mData = Uri.parse(data); 7810 } catch (IllegalArgumentException e) { 7811 throw new URISyntaxException(uri, e.getMessage()); 7812 } 7813 } 7814 } 7815 7816 return intent; 7817 7818 } catch (IndexOutOfBoundsException e) { 7819 throw new URISyntaxException(uri, "illegal Intent URI format", i); 7820 } 7821 } 7822 7823 public static Intent getIntentOld(String uri) throws URISyntaxException { 7824 Intent intent = getIntentOld(uri, 0); 7825 intent.mLocalFlags |= LOCAL_FLAG_FROM_URI; 7826 return intent; 7827 } 7828 7829 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException { 7830 Intent intent; 7831 7832 int i = uri.lastIndexOf('#'); 7833 if (i >= 0) { 7834 String action = null; 7835 final int intentFragmentStart = i; 7836 boolean isIntentFragment = false; 7837 7838 i++; 7839 7840 if (uri.regionMatches(i, "action(", 0, 7)) { 7841 isIntentFragment = true; 7842 i += 7; 7843 int j = uri.indexOf(')', i); 7844 action = uri.substring(i, j); 7845 i = j + 1; 7846 } 7847 7848 intent = new Intent(action); 7849 7850 if (uri.regionMatches(i, "categories(", 0, 11)) { 7851 isIntentFragment = true; 7852 i += 11; 7853 int j = uri.indexOf(')', i); 7854 while (i < j) { 7855 int sep = uri.indexOf('!', i); 7856 if (sep < 0 || sep > j) sep = j; 7857 if (i < sep) { 7858 intent.addCategory(uri.substring(i, sep)); 7859 } 7860 i = sep + 1; 7861 } 7862 i = j + 1; 7863 } 7864 7865 if (uri.regionMatches(i, "type(", 0, 5)) { 7866 isIntentFragment = true; 7867 i += 5; 7868 int j = uri.indexOf(')', i); 7869 intent.mType = uri.substring(i, j); 7870 i = j + 1; 7871 } 7872 7873 if (uri.regionMatches(i, "launchFlags(", 0, 12)) { 7874 isIntentFragment = true; 7875 i += 12; 7876 int j = uri.indexOf(')', i); 7877 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); 7878 if ((flags& URI_ALLOW_UNSAFE) == 0) { 7879 intent.mFlags &= ~IMMUTABLE_FLAGS; 7880 } 7881 i = j + 1; 7882 } 7883 7884 if (uri.regionMatches(i, "component(", 0, 10)) { 7885 isIntentFragment = true; 7886 i += 10; 7887 int j = uri.indexOf(')', i); 7888 int sep = uri.indexOf('!', i); 7889 if (sep >= 0 && sep < j) { 7890 String pkg = uri.substring(i, sep); 7891 String cls = uri.substring(sep + 1, j); 7892 intent.mComponent = new ComponentName(pkg, cls); 7893 } 7894 i = j + 1; 7895 } 7896 7897 if (uri.regionMatches(i, "extras(", 0, 7)) { 7898 isIntentFragment = true; 7899 i += 7; 7900 7901 final int closeParen = uri.indexOf(')', i); 7902 if (closeParen == -1) throw new URISyntaxException(uri, 7903 "EXTRA missing trailing ')'", i); 7904 7905 while (i < closeParen) { 7906 // fetch the key value 7907 int j = uri.indexOf('=', i); 7908 if (j <= i + 1 || i >= closeParen) { 7909 throw new URISyntaxException(uri, "EXTRA missing '='", i); 7910 } 7911 char type = uri.charAt(i); 7912 i++; 7913 String key = uri.substring(i, j); 7914 i = j + 1; 7915 7916 // get type-value 7917 j = uri.indexOf('!', i); 7918 if (j == -1 || j >= closeParen) j = closeParen; 7919 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i); 7920 String value = uri.substring(i, j); 7921 i = j; 7922 7923 // create Bundle if it doesn't already exist 7924 if (intent.mExtras == null) intent.mExtras = new Bundle(); 7925 7926 // add item to bundle 7927 try { 7928 switch (type) { 7929 case 'S': 7930 intent.mExtras.putString(key, Uri.decode(value)); 7931 break; 7932 case 'B': 7933 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value)); 7934 break; 7935 case 'b': 7936 intent.mExtras.putByte(key, Byte.parseByte(value)); 7937 break; 7938 case 'c': 7939 intent.mExtras.putChar(key, Uri.decode(value).charAt(0)); 7940 break; 7941 case 'd': 7942 intent.mExtras.putDouble(key, Double.parseDouble(value)); 7943 break; 7944 case 'f': 7945 intent.mExtras.putFloat(key, Float.parseFloat(value)); 7946 break; 7947 case 'i': 7948 intent.mExtras.putInt(key, Integer.parseInt(value)); 7949 break; 7950 case 'l': 7951 intent.mExtras.putLong(key, Long.parseLong(value)); 7952 break; 7953 case 's': 7954 intent.mExtras.putShort(key, Short.parseShort(value)); 7955 break; 7956 default: 7957 throw new URISyntaxException(uri, "EXTRA has unknown type", i); 7958 } 7959 } catch (NumberFormatException e) { 7960 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i); 7961 } 7962 7963 char ch = uri.charAt(i); 7964 if (ch == ')') break; 7965 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i); 7966 i++; 7967 } 7968 } 7969 7970 if (isIntentFragment) { 7971 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); 7972 } else { 7973 intent.mData = Uri.parse(uri); 7974 } 7975 7976 if (intent.mAction == null) { 7977 // By default, if no action is specified, then use VIEW. 7978 intent.mAction = ACTION_VIEW; 7979 } 7980 7981 } else { 7982 intent = new Intent(ACTION_VIEW, Uri.parse(uri)); 7983 } 7984 7985 return intent; 7986 } 7987 7988 /** @hide */ 7989 public interface CommandOptionHandler { 7990 boolean handleOption(String opt, ShellCommand cmd); 7991 } 7992 7993 /** @hide */ 7994 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 7995 @SuppressWarnings("AndroidFrameworkEfficientCollections") parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)7996 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler) 7997 throws URISyntaxException { 7998 Intent intent = new Intent(); 7999 Intent baseIntent = intent; 8000 boolean hasIntentInfo = false; 8001 8002 Uri data = null; 8003 String type = null; 8004 8005 String opt; 8006 while ((opt=cmd.getNextOption()) != null) { 8007 switch (opt) { 8008 case "-a": 8009 intent.setAction(cmd.getNextArgRequired()); 8010 if (intent == baseIntent) { 8011 hasIntentInfo = true; 8012 } 8013 break; 8014 case "-d": 8015 data = Uri.parse(cmd.getNextArgRequired()); 8016 if (intent == baseIntent) { 8017 hasIntentInfo = true; 8018 } 8019 break; 8020 case "-t": 8021 type = cmd.getNextArgRequired(); 8022 if (intent == baseIntent) { 8023 hasIntentInfo = true; 8024 } 8025 break; 8026 case "-i": 8027 intent.setIdentifier(cmd.getNextArgRequired()); 8028 if (intent == baseIntent) { 8029 hasIntentInfo = true; 8030 } 8031 break; 8032 case "-c": 8033 intent.addCategory(cmd.getNextArgRequired()); 8034 if (intent == baseIntent) { 8035 hasIntentInfo = true; 8036 } 8037 break; 8038 case "-e": 8039 case "--es": { 8040 String key = cmd.getNextArgRequired(); 8041 String value = cmd.getNextArgRequired(); 8042 intent.putExtra(key, value); 8043 } 8044 break; 8045 case "--esn": { 8046 String key = cmd.getNextArgRequired(); 8047 intent.putExtra(key, (String) null); 8048 } 8049 break; 8050 case "--ei": { 8051 String key = cmd.getNextArgRequired(); 8052 String value = cmd.getNextArgRequired(); 8053 intent.putExtra(key, Integer.decode(value)); 8054 } 8055 break; 8056 case "--eu": { 8057 String key = cmd.getNextArgRequired(); 8058 String value = cmd.getNextArgRequired(); 8059 intent.putExtra(key, Uri.parse(value)); 8060 } 8061 break; 8062 case "--ecn": { 8063 String key = cmd.getNextArgRequired(); 8064 String value = cmd.getNextArgRequired(); 8065 ComponentName cn = ComponentName.unflattenFromString(value); 8066 if (cn == null) 8067 throw new IllegalArgumentException("Bad component name: " + value); 8068 intent.putExtra(key, cn); 8069 } 8070 break; 8071 case "--eia": { 8072 String key = cmd.getNextArgRequired(); 8073 String value = cmd.getNextArgRequired(); 8074 String[] strings = value.split(","); 8075 int[] list = new int[strings.length]; 8076 for (int i = 0; i < strings.length; i++) { 8077 list[i] = Integer.decode(strings[i]); 8078 } 8079 intent.putExtra(key, list); 8080 } 8081 break; 8082 case "--eial": { 8083 String key = cmd.getNextArgRequired(); 8084 String value = cmd.getNextArgRequired(); 8085 String[] strings = value.split(","); 8086 ArrayList<Integer> list = new ArrayList<>(strings.length); 8087 for (int i = 0; i < strings.length; i++) { 8088 list.add(Integer.decode(strings[i])); 8089 } 8090 intent.putExtra(key, list); 8091 } 8092 break; 8093 case "--el": { 8094 String key = cmd.getNextArgRequired(); 8095 String value = cmd.getNextArgRequired(); 8096 intent.putExtra(key, Long.valueOf(value)); 8097 } 8098 break; 8099 case "--ela": { 8100 String key = cmd.getNextArgRequired(); 8101 String value = cmd.getNextArgRequired(); 8102 String[] strings = value.split(","); 8103 long[] list = new long[strings.length]; 8104 for (int i = 0; i < strings.length; i++) { 8105 list[i] = Long.valueOf(strings[i]); 8106 } 8107 intent.putExtra(key, list); 8108 hasIntentInfo = true; 8109 } 8110 break; 8111 case "--elal": { 8112 String key = cmd.getNextArgRequired(); 8113 String value = cmd.getNextArgRequired(); 8114 String[] strings = value.split(","); 8115 ArrayList<Long> list = new ArrayList<>(strings.length); 8116 for (int i = 0; i < strings.length; i++) { 8117 list.add(Long.valueOf(strings[i])); 8118 } 8119 intent.putExtra(key, list); 8120 hasIntentInfo = true; 8121 } 8122 break; 8123 case "--ef": { 8124 String key = cmd.getNextArgRequired(); 8125 String value = cmd.getNextArgRequired(); 8126 intent.putExtra(key, Float.valueOf(value)); 8127 hasIntentInfo = true; 8128 } 8129 break; 8130 case "--efa": { 8131 String key = cmd.getNextArgRequired(); 8132 String value = cmd.getNextArgRequired(); 8133 String[] strings = value.split(","); 8134 float[] list = new float[strings.length]; 8135 for (int i = 0; i < strings.length; i++) { 8136 list[i] = Float.valueOf(strings[i]); 8137 } 8138 intent.putExtra(key, list); 8139 hasIntentInfo = true; 8140 } 8141 break; 8142 case "--efal": { 8143 String key = cmd.getNextArgRequired(); 8144 String value = cmd.getNextArgRequired(); 8145 String[] strings = value.split(","); 8146 ArrayList<Float> list = new ArrayList<>(strings.length); 8147 for (int i = 0; i < strings.length; i++) { 8148 list.add(Float.valueOf(strings[i])); 8149 } 8150 intent.putExtra(key, list); 8151 hasIntentInfo = true; 8152 } 8153 break; 8154 case "--ed": { 8155 String key = cmd.getNextArgRequired(); 8156 String value = cmd.getNextArgRequired(); 8157 intent.putExtra(key, Double.valueOf(value)); 8158 hasIntentInfo = true; 8159 } 8160 break; 8161 case "--eda": { 8162 String key = cmd.getNextArgRequired(); 8163 String value = cmd.getNextArgRequired(); 8164 String[] strings = value.split(","); 8165 double[] list = new double[strings.length]; 8166 for (int i = 0; i < strings.length; i++) { 8167 list[i] = Double.valueOf(strings[i]); 8168 } 8169 intent.putExtra(key, list); 8170 hasIntentInfo = true; 8171 } 8172 break; 8173 case "--edal": { 8174 String key = cmd.getNextArgRequired(); 8175 String value = cmd.getNextArgRequired(); 8176 String[] strings = value.split(","); 8177 ArrayList<Double> list = new ArrayList<>(strings.length); 8178 for (int i = 0; i < strings.length; i++) { 8179 list.add(Double.valueOf(strings[i])); 8180 } 8181 intent.putExtra(key, list); 8182 hasIntentInfo = true; 8183 } 8184 break; 8185 case "--esa": { 8186 String key = cmd.getNextArgRequired(); 8187 String value = cmd.getNextArgRequired(); 8188 // Split on commas unless they are preceeded by an escape. 8189 // The escape character must be escaped for the string and 8190 // again for the regex, thus four escape characters become one. 8191 String[] strings = value.split("(?<!\\\\),"); 8192 intent.putExtra(key, strings); 8193 hasIntentInfo = true; 8194 } 8195 break; 8196 case "--esal": { 8197 String key = cmd.getNextArgRequired(); 8198 String value = cmd.getNextArgRequired(); 8199 // Split on commas unless they are preceeded by an escape. 8200 // The escape character must be escaped for the string and 8201 // again for the regex, thus four escape characters become one. 8202 String[] strings = value.split("(?<!\\\\),"); 8203 ArrayList<String> list = new ArrayList<>(strings.length); 8204 for (int i = 0; i < strings.length; i++) { 8205 list.add(strings[i]); 8206 } 8207 intent.putExtra(key, list); 8208 hasIntentInfo = true; 8209 } 8210 break; 8211 case "--ez": { 8212 String key = cmd.getNextArgRequired(); 8213 String value = cmd.getNextArgRequired().toLowerCase(); 8214 // Boolean.valueOf() results in false for anything that is not "true", which is 8215 // error-prone in shell commands 8216 boolean arg; 8217 if ("true".equals(value) || "t".equals(value)) { 8218 arg = true; 8219 } else if ("false".equals(value) || "f".equals(value)) { 8220 arg = false; 8221 } else { 8222 try { 8223 arg = Integer.decode(value) != 0; 8224 } catch (NumberFormatException ex) { 8225 throw new IllegalArgumentException("Invalid boolean value: " + value); 8226 } 8227 } 8228 8229 intent.putExtra(key, arg); 8230 } 8231 break; 8232 case "-n": { 8233 String str = cmd.getNextArgRequired(); 8234 ComponentName cn = ComponentName.unflattenFromString(str); 8235 if (cn == null) 8236 throw new IllegalArgumentException("Bad component name: " + str); 8237 intent.setComponent(cn); 8238 if (intent == baseIntent) { 8239 hasIntentInfo = true; 8240 } 8241 } 8242 break; 8243 case "-p": { 8244 String str = cmd.getNextArgRequired(); 8245 intent.setPackage(str); 8246 if (intent == baseIntent) { 8247 hasIntentInfo = true; 8248 } 8249 } 8250 break; 8251 case "-f": 8252 String str = cmd.getNextArgRequired(); 8253 intent.setFlags(Integer.decode(str).intValue()); 8254 break; 8255 case "--grant-read-uri-permission": 8256 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 8257 break; 8258 case "--grant-write-uri-permission": 8259 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 8260 break; 8261 case "--grant-persistable-uri-permission": 8262 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); 8263 break; 8264 case "--grant-prefix-uri-permission": 8265 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION); 8266 break; 8267 case "--exclude-stopped-packages": 8268 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); 8269 break; 8270 case "--include-stopped-packages": 8271 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); 8272 break; 8273 case "--debug-log-resolution": 8274 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); 8275 break; 8276 case "--activity-brought-to-front": 8277 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); 8278 break; 8279 case "--activity-clear-top": 8280 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 8281 break; 8282 case "--activity-clear-when-task-reset": 8283 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 8284 break; 8285 case "--activity-exclude-from-recents": 8286 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 8287 break; 8288 case "--activity-launched-from-history": 8289 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); 8290 break; 8291 case "--activity-multiple-task": 8292 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); 8293 break; 8294 case "--activity-no-animation": 8295 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 8296 break; 8297 case "--activity-no-history": 8298 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 8299 break; 8300 case "--activity-no-user-action": 8301 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); 8302 break; 8303 case "--activity-previous-is-top": 8304 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); 8305 break; 8306 case "--activity-reorder-to-front": 8307 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 8308 break; 8309 case "--activity-reset-task-if-needed": 8310 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); 8311 break; 8312 case "--activity-single-top": 8313 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 8314 break; 8315 case "--activity-clear-task": 8316 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 8317 break; 8318 case "--activity-task-on-home": 8319 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); 8320 break; 8321 case "--activity-match-external": 8322 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL); 8323 break; 8324 case "--receiver-registered-only": 8325 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); 8326 break; 8327 case "--receiver-replace-pending": 8328 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); 8329 break; 8330 case "--receiver-foreground": 8331 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 8332 break; 8333 case "--receiver-no-abort": 8334 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT); 8335 break; 8336 case "--receiver-include-background": 8337 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); 8338 break; 8339 case "--selector": 8340 intent.setDataAndType(data, type); 8341 intent = new Intent(); 8342 break; 8343 default: 8344 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) { 8345 // Okay, caller handled this option. 8346 } else { 8347 throw new IllegalArgumentException("Unknown option: " + opt); 8348 } 8349 break; 8350 } 8351 } 8352 intent.setDataAndType(data, type); 8353 8354 final boolean hasSelector = intent != baseIntent; 8355 if (hasSelector) { 8356 // A selector was specified; fix up. 8357 baseIntent.setSelector(intent); 8358 intent = baseIntent; 8359 } 8360 8361 String arg = cmd.getNextArg(); 8362 baseIntent = null; 8363 if (arg == null) { 8364 if (hasSelector) { 8365 // If a selector has been specified, and no arguments 8366 // have been supplied for the main Intent, then we can 8367 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't 8368 // need to have a component name specified yet, the 8369 // selector will take care of that. 8370 baseIntent = new Intent(Intent.ACTION_MAIN); 8371 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8372 } 8373 } else if (arg.indexOf(':') >= 0) { 8374 // The argument is a URI. Fully parse it, and use that result 8375 // to fill in any data not specified so far. 8376 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME 8377 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE); 8378 } else if (arg.indexOf('/') >= 0) { 8379 // The argument is a component name. Build an Intent to launch 8380 // it. 8381 baseIntent = new Intent(Intent.ACTION_MAIN); 8382 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8383 baseIntent.setComponent(ComponentName.unflattenFromString(arg)); 8384 } else { 8385 // Assume the argument is a package name. 8386 baseIntent = new Intent(Intent.ACTION_MAIN); 8387 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER); 8388 baseIntent.setPackage(arg); 8389 } 8390 if (baseIntent != null) { 8391 Bundle extras = intent.getExtras(); 8392 intent.replaceExtras((Bundle)null); 8393 Bundle uriExtras = baseIntent.getExtras(); 8394 baseIntent.replaceExtras((Bundle)null); 8395 if (intent.getAction() != null && baseIntent.getCategories() != null) { 8396 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories()); 8397 for (String c : cats) { 8398 baseIntent.removeCategory(c); 8399 } 8400 } 8401 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR); 8402 if (extras == null) { 8403 extras = uriExtras; 8404 } else if (uriExtras != null) { 8405 uriExtras.putAll(extras); 8406 extras = uriExtras; 8407 } 8408 intent.replaceExtras(extras); 8409 hasIntentInfo = true; 8410 } 8411 8412 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied"); 8413 return intent; 8414 } 8415 8416 /** @hide */ 8417 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) printIntentArgsHelp(PrintWriter pw, String prefix)8418 public static void printIntentArgsHelp(PrintWriter pw, String prefix) { 8419 final String[] lines = new String[] { 8420 "<INTENT> specifications include these flags and arguments:", 8421 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]", 8422 " [-c <CATEGORY> [-c <CATEGORY>] ...]", 8423 " [-n <COMPONENT_NAME>]", 8424 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]", 8425 " [--esn <EXTRA_KEY> ...]", 8426 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]", 8427 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]", 8428 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]", 8429 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]", 8430 " [--ed <EXTRA_KEY> <EXTRA_DOUBLE_VALUE> ...]", 8431 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]", 8432 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]", 8433 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8434 " (multiple extras passed as Integer[])", 8435 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]", 8436 " (multiple extras passed as List<Integer>)", 8437 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8438 " (multiple extras passed as Long[])", 8439 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]", 8440 " (multiple extras passed as List<Long>)", 8441 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8442 " (multiple extras passed as Float[])", 8443 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]", 8444 " (multiple extras passed as List<Float>)", 8445 " [--eda <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]", 8446 " (multiple extras passed as Double[])", 8447 " [--edal <EXTRA_KEY> <EXTRA_DOUBLE_VALUE>[,<EXTRA_DOUBLE_VALUE...]]", 8448 " (multiple extras passed as List<Double>)", 8449 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8450 " (multiple extras passed as String[]; to embed a comma into a string,", 8451 " escape it using \"\\,\")", 8452 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]", 8453 " (multiple extras passed as List<String>; to embed a comma into a string,", 8454 " escape it using \"\\,\")", 8455 " [-f <FLAG>]", 8456 " [--grant-read-uri-permission] [--grant-write-uri-permission]", 8457 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]", 8458 " [--debug-log-resolution] [--exclude-stopped-packages]", 8459 " [--include-stopped-packages]", 8460 " [--activity-brought-to-front] [--activity-clear-top]", 8461 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]", 8462 " [--activity-launched-from-history] [--activity-multiple-task]", 8463 " [--activity-no-animation] [--activity-no-history]", 8464 " [--activity-no-user-action] [--activity-previous-is-top]", 8465 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]", 8466 " [--activity-single-top] [--activity-clear-task]", 8467 " [--activity-task-on-home] [--activity-match-external]", 8468 " [--receiver-registered-only] [--receiver-replace-pending]", 8469 " [--receiver-foreground] [--receiver-no-abort]", 8470 " [--receiver-include-background]", 8471 " [--selector]", 8472 " [<URI> | <PACKAGE> | <COMPONENT>]" 8473 }; 8474 for (String line : lines) { 8475 pw.print(prefix); 8476 pw.println(line); 8477 } 8478 } 8479 8480 /** 8481 * Retrieve the general action to be performed, such as 8482 * {@link #ACTION_VIEW}. The action describes the general way the rest of 8483 * the information in the intent should be interpreted -- most importantly, 8484 * what to do with the data returned by {@link #getData}. 8485 * 8486 * @return The action of this intent or null if none is specified. 8487 * 8488 * @see #setAction 8489 */ getAction()8490 public @Nullable String getAction() { 8491 return mAction; 8492 } 8493 8494 /** 8495 * Retrieve data this intent is operating on. This URI specifies the name 8496 * of the data; often it uses the content: scheme, specifying data in a 8497 * content provider. Other schemes may be handled by specific activities, 8498 * such as http: by the web browser. 8499 * 8500 * @return The URI of the data this intent is targeting or null. 8501 * 8502 * @see #getScheme 8503 * @see #setData 8504 */ getData()8505 public @Nullable Uri getData() { 8506 return mData; 8507 } 8508 8509 /** 8510 * The same as {@link #getData()}, but returns the URI as an encoded 8511 * String. 8512 */ getDataString()8513 public @Nullable String getDataString() { 8514 return mData != null ? mData.toString() : null; 8515 } 8516 8517 /** 8518 * Return the scheme portion of the intent's data. If the data is null or 8519 * does not include a scheme, null is returned. Otherwise, the scheme 8520 * prefix without the final ':' is returned, i.e. "http". 8521 * 8522 * <p>This is the same as calling getData().getScheme() (and checking for 8523 * null data). 8524 * 8525 * @return The scheme of this intent. 8526 * 8527 * @see #getData 8528 */ getScheme()8529 public @Nullable String getScheme() { 8530 return mData != null ? mData.getScheme() : null; 8531 } 8532 8533 /** 8534 * Retrieve any explicit MIME type included in the intent. This is usually 8535 * null, as the type is determined by the intent data. 8536 * 8537 * @return If a type was manually set, it is returned; else null is 8538 * returned. 8539 * 8540 * @see #resolveType(ContentResolver) 8541 * @see #setType 8542 */ getType()8543 public @Nullable String getType() { 8544 return mType; 8545 } 8546 8547 8548 /** 8549 * @hide For the experimental component alias feature. Do not use, unless you know what it is. 8550 */ 8551 @Nullable getOriginalIntent()8552 public Intent getOriginalIntent() { 8553 return mOriginalIntent; 8554 } 8555 8556 /** 8557 * @hide For the experimental component alias feature. Do not use, unless you know what it is. 8558 */ setOriginalIntent(@ullable Intent originalIntent)8559 public void setOriginalIntent(@Nullable Intent originalIntent) { 8560 mOriginalIntent = originalIntent; 8561 } 8562 8563 /** 8564 * Return the MIME data type of this intent. If the type field is 8565 * explicitly set, that is simply returned. Otherwise, if the data is set, 8566 * the type of that data is returned. If neither fields are set, a null is 8567 * returned. 8568 * 8569 * @return The MIME type of this intent. 8570 * 8571 * @see #getType 8572 * @see #resolveType(ContentResolver) 8573 */ resolveType(@onNull Context context)8574 public @Nullable String resolveType(@NonNull Context context) { 8575 return resolveType(context.getContentResolver()); 8576 } 8577 8578 /** 8579 * Return the MIME data type of this intent. If the type field is 8580 * explicitly set, that is simply returned. Otherwise, if the data is set, 8581 * the type of that data is returned. If neither fields are set, a null is 8582 * returned. 8583 * 8584 * @param resolver A ContentResolver that can be used to determine the MIME 8585 * type of the intent's data. 8586 * 8587 * @return The MIME type of this intent. 8588 * 8589 * @see #getType 8590 * @see #resolveType(Context) 8591 */ resolveType(@onNull ContentResolver resolver)8592 public @Nullable String resolveType(@NonNull ContentResolver resolver) { 8593 if (mType != null) { 8594 return mType; 8595 } 8596 if (mData != null) { 8597 if ("content".equals(mData.getScheme())) { 8598 return resolver.getType(mData); 8599 } 8600 } 8601 return null; 8602 } 8603 8604 /** 8605 * Return the MIME data type of this intent, only if it will be needed for 8606 * intent resolution. This is not generally useful for application code; 8607 * it is used by the frameworks for communicating with back-end system 8608 * services. 8609 * 8610 * @param resolver A ContentResolver that can be used to determine the MIME 8611 * type of the intent's data. 8612 * 8613 * @return The MIME type of this intent, or null if it is unknown or not 8614 * needed. 8615 */ resolveTypeIfNeeded(@onNull ContentResolver resolver)8616 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) { 8617 // Match logic in PackageManagerService#applyEnforceIntentFilterMatching(...) 8618 if (mComponent != null && (Process.myUid() == Process.ROOT_UID 8619 || Process.myUid() == Process.SYSTEM_UID 8620 || mComponent.getPackageName().equals(ActivityThread.currentPackageName()))) { 8621 return mType; 8622 } 8623 return resolveType(resolver); 8624 } 8625 8626 /** 8627 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity 8628 * of the Intent to distinguish it from other Intents. 8629 * 8630 * @return The identifier of this intent or null if none is specified. 8631 * 8632 * @see #setIdentifier 8633 */ getIdentifier()8634 public @Nullable String getIdentifier() { 8635 return mIdentifier; 8636 } 8637 8638 /** 8639 * Check if a category exists in the intent. 8640 * 8641 * @param category The category to check. 8642 * 8643 * @return boolean True if the intent contains the category, else false. 8644 * 8645 * @see #getCategories 8646 * @see #addCategory 8647 */ hasCategory(String category)8648 public boolean hasCategory(String category) { 8649 return mCategories != null && mCategories.contains(category); 8650 } 8651 8652 /** 8653 * Return the set of all categories in the intent. If there are no categories, 8654 * returns NULL. 8655 * 8656 * @return The set of categories you can examine. Do not modify! 8657 * 8658 * @see #hasCategory 8659 * @see #addCategory 8660 */ getCategories()8661 public Set<String> getCategories() { 8662 return mCategories; 8663 } 8664 8665 /** 8666 * Return the specific selector associated with this Intent. If there is 8667 * none, returns null. See {@link #setSelector} for more information. 8668 * 8669 * @see #setSelector 8670 */ getSelector()8671 public @Nullable Intent getSelector() { 8672 return mSelector; 8673 } 8674 8675 /** 8676 * Return the {@link ClipData} associated with this Intent. If there is 8677 * none, returns null. See {@link #setClipData} for more information. 8678 * 8679 * @see #setClipData 8680 */ getClipData()8681 public @Nullable ClipData getClipData() { 8682 return mClipData; 8683 } 8684 8685 /** @hide */ getContentUserHint()8686 public int getContentUserHint() { 8687 return mContentUserHint; 8688 } 8689 8690 /** @hide */ getLaunchToken()8691 public String getLaunchToken() { 8692 return mLaunchToken; 8693 } 8694 8695 /** @hide */ setLaunchToken(String launchToken)8696 public void setLaunchToken(String launchToken) { 8697 mLaunchToken = launchToken; 8698 } 8699 8700 /** 8701 * Sets the ClassLoader that will be used when unmarshalling 8702 * any Parcelable values from the extras of this Intent. 8703 * 8704 * @param loader a ClassLoader, or null to use the default loader 8705 * at the time of unmarshalling. 8706 */ setExtrasClassLoader(@ullable ClassLoader loader)8707 public void setExtrasClassLoader(@Nullable ClassLoader loader) { 8708 if (mExtras != null) { 8709 mExtras.setClassLoader(loader); 8710 } 8711 } 8712 8713 /** 8714 * Returns true if an extra value is associated with the given name. 8715 * @param name the extra's name 8716 * @return true if the given extra is present. 8717 */ hasExtra(String name)8718 public boolean hasExtra(String name) { 8719 return mExtras != null && mExtras.containsKey(name); 8720 } 8721 8722 /** 8723 * Returns true if the Intent's extras contain a parcelled file descriptor. 8724 * @return true if the Intent contains a parcelled file descriptor. 8725 */ hasFileDescriptors()8726 public boolean hasFileDescriptors() { 8727 return mExtras != null && mExtras.hasFileDescriptors(); 8728 } 8729 8730 /** {@hide} */ 8731 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) setAllowFds(boolean allowFds)8732 public void setAllowFds(boolean allowFds) { 8733 if (mExtras != null) { 8734 mExtras.setAllowFds(allowFds); 8735 } 8736 } 8737 8738 /** {@hide} */ setDefusable(boolean defusable)8739 public void setDefusable(boolean defusable) { 8740 if (mExtras != null) { 8741 mExtras.setDefusable(defusable); 8742 } 8743 } 8744 8745 /** 8746 * Retrieve extended data from the intent. 8747 * 8748 * @param name The name of the desired item. 8749 * 8750 * @return the value of an item previously added with putExtra(), 8751 * or null if none was found. 8752 * 8753 * @deprecated 8754 * @hide 8755 */ 8756 @Deprecated 8757 @UnsupportedAppUsage getExtra(String name)8758 public Object getExtra(String name) { 8759 return getExtra(name, null); 8760 } 8761 8762 /** 8763 * Retrieve extended data from the intent. 8764 * 8765 * @param name The name of the desired item. 8766 * @param defaultValue the value to be returned if no value of the desired 8767 * type is stored with the given name. 8768 * 8769 * @return the value of an item previously added with putExtra(), 8770 * or the default value if none was found. 8771 * 8772 * @see #putExtra(String, boolean) 8773 */ getBooleanExtra(String name, boolean defaultValue)8774 public boolean getBooleanExtra(String name, boolean defaultValue) { 8775 return mExtras == null ? defaultValue : 8776 mExtras.getBoolean(name, defaultValue); 8777 } 8778 8779 /** 8780 * Retrieve extended data from the intent. 8781 * 8782 * @param name The name of the desired item. 8783 * @param defaultValue the value to be returned if no value of the desired 8784 * type is stored with the given name. 8785 * 8786 * @return the value of an item previously added with putExtra(), 8787 * or the default value if none was found. 8788 * 8789 * @see #putExtra(String, byte) 8790 */ getByteExtra(String name, byte defaultValue)8791 public byte getByteExtra(String name, byte defaultValue) { 8792 return mExtras == null ? defaultValue : 8793 mExtras.getByte(name, defaultValue); 8794 } 8795 8796 /** 8797 * Retrieve extended data from the intent. 8798 * 8799 * @param name The name of the desired item. 8800 * @param defaultValue the value to be returned if no value of the desired 8801 * type is stored with the given name. 8802 * 8803 * @return the value of an item previously added with putExtra(), 8804 * or the default value if none was found. 8805 * 8806 * @see #putExtra(String, short) 8807 */ getShortExtra(String name, short defaultValue)8808 public short getShortExtra(String name, short defaultValue) { 8809 return mExtras == null ? defaultValue : 8810 mExtras.getShort(name, defaultValue); 8811 } 8812 8813 /** 8814 * Retrieve extended data from the intent. 8815 * 8816 * @param name The name of the desired item. 8817 * @param defaultValue the value to be returned if no value of the desired 8818 * type is stored with the given name. 8819 * 8820 * @return the value of an item previously added with putExtra(), 8821 * or the default value if none was found. 8822 * 8823 * @see #putExtra(String, char) 8824 */ getCharExtra(String name, char defaultValue)8825 public char getCharExtra(String name, char defaultValue) { 8826 return mExtras == null ? defaultValue : 8827 mExtras.getChar(name, defaultValue); 8828 } 8829 8830 /** 8831 * Retrieve extended data from the intent. 8832 * 8833 * @param name The name of the desired item. 8834 * @param defaultValue the value to be returned if no value of the desired 8835 * type is stored with the given name. 8836 * 8837 * @return the value of an item previously added with putExtra(), 8838 * or the default value if none was found. 8839 * 8840 * @see #putExtra(String, int) 8841 */ getIntExtra(String name, int defaultValue)8842 public int getIntExtra(String name, int defaultValue) { 8843 return mExtras == null ? defaultValue : 8844 mExtras.getInt(name, defaultValue); 8845 } 8846 8847 /** 8848 * Retrieve extended data from the intent. 8849 * 8850 * @param name The name of the desired item. 8851 * @param defaultValue the value to be returned if no value of the desired 8852 * type is stored with the given name. 8853 * 8854 * @return the value of an item previously added with putExtra(), 8855 * or the default value if none was found. 8856 * 8857 * @see #putExtra(String, long) 8858 */ getLongExtra(String name, long defaultValue)8859 public long getLongExtra(String name, long defaultValue) { 8860 return mExtras == null ? defaultValue : 8861 mExtras.getLong(name, defaultValue); 8862 } 8863 8864 /** 8865 * Retrieve extended data from the intent. 8866 * 8867 * @param name The name of the desired item. 8868 * @param defaultValue the value to be returned if no value of the desired 8869 * type is stored with the given name. 8870 * 8871 * @return the value of an item previously added with putExtra(), 8872 * or the default value if no such item is present 8873 * 8874 * @see #putExtra(String, float) 8875 */ getFloatExtra(String name, float defaultValue)8876 public float getFloatExtra(String name, float defaultValue) { 8877 return mExtras == null ? defaultValue : 8878 mExtras.getFloat(name, defaultValue); 8879 } 8880 8881 /** 8882 * Retrieve extended data from the intent. 8883 * 8884 * @param name The name of the desired item. 8885 * @param defaultValue the value to be returned if no value of the desired 8886 * type is stored with the given name. 8887 * 8888 * @return the value of an item previously added with putExtra(), 8889 * or the default value if none was found. 8890 * 8891 * @see #putExtra(String, double) 8892 */ getDoubleExtra(String name, double defaultValue)8893 public double getDoubleExtra(String name, double defaultValue) { 8894 return mExtras == null ? defaultValue : 8895 mExtras.getDouble(name, defaultValue); 8896 } 8897 8898 /** 8899 * Retrieve extended data from the intent. 8900 * 8901 * @param name The name of the desired item. 8902 * 8903 * @return the value of an item previously added with putExtra(), 8904 * or null if no String value was found. 8905 * 8906 * @see #putExtra(String, String) 8907 */ getStringExtra(String name)8908 public @Nullable String getStringExtra(String name) { 8909 return mExtras == null ? null : mExtras.getString(name); 8910 } 8911 8912 /** 8913 * Retrieve extended data from the intent. 8914 * 8915 * @param name The name of the desired item. 8916 * 8917 * @return the value of an item previously added with putExtra(), 8918 * or null if no CharSequence value was found. 8919 * 8920 * @see #putExtra(String, CharSequence) 8921 */ getCharSequenceExtra(String name)8922 public @Nullable CharSequence getCharSequenceExtra(String name) { 8923 return mExtras == null ? null : mExtras.getCharSequence(name); 8924 } 8925 8926 /** 8927 * Retrieve extended data from the intent. 8928 * 8929 * @param name The name of the desired item. 8930 * 8931 * @return the value of an item previously added with putExtra(), 8932 * or null if no Parcelable value was found. 8933 * 8934 * @deprecated Use the type-safer {@link #getParcelableExtra(String, Class)} starting from 8935 * Android {@link Build.VERSION_CODES#TIRAMISU}. 8936 * 8937 * @see #putExtra(String, Parcelable) 8938 */ 8939 @Deprecated getParcelableExtra(String name)8940 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) { 8941 return mExtras == null ? null : mExtras.<T>getParcelable(name); 8942 } 8943 8944 /** 8945 * Retrieve extended data from the intent. 8946 * 8947 * @param name The name of the desired item. 8948 * @param clazz The type of the object expected. 8949 * 8950 * @return the value of an item previously added with putExtra(), 8951 * or null if no Parcelable value was found. 8952 * 8953 * @see #putExtra(String, Parcelable) 8954 */ getParcelableExtra(@ullable String name, @NonNull Class<T> clazz)8955 public @Nullable <T> T getParcelableExtra(@Nullable String name, @NonNull Class<T> clazz) { 8956 return mExtras == null ? null : mExtras.getParcelable(name, clazz); 8957 } 8958 8959 /** 8960 * Retrieve extended data from the intent. 8961 * 8962 * @param name The name of the desired item. 8963 * 8964 * @return the value of an item previously added with putExtra(), 8965 * or null if no Parcelable[] value was found. 8966 * 8967 * @deprecated Use the type-safer {@link #getParcelableArrayExtra(String, Class)} starting from 8968 * Android {@link Build.VERSION_CODES#TIRAMISU}. 8969 * 8970 * @see #putExtra(String, Parcelable[]) 8971 */ 8972 @Deprecated getParcelableArrayExtra(String name)8973 public @Nullable Parcelable[] getParcelableArrayExtra(String name) { 8974 return mExtras == null ? null : mExtras.getParcelableArray(name); 8975 } 8976 8977 /** 8978 * Retrieve extended data from the intent. 8979 * 8980 * @param name The name of the desired item. 8981 * @param clazz The type of the items inside the array. This is only verified when unparceling. 8982 * 8983 * @return the value of an item previously added with putExtra(), 8984 * or null if no Parcelable[] value was found. 8985 * 8986 * @see #putExtra(String, Parcelable[]) 8987 */ 8988 @SuppressLint({"ArrayReturn", "NullableCollection"}) getParcelableArrayExtra(@ullable String name, @NonNull Class<T> clazz)8989 public @Nullable <T> T[] getParcelableArrayExtra(@Nullable String name, 8990 @NonNull Class<T> clazz) { 8991 return mExtras == null ? null : mExtras.getParcelableArray(name, clazz); 8992 } 8993 8994 /** 8995 * Retrieve extended data from the intent. 8996 * 8997 * @param name The name of the desired item. 8998 * 8999 * @return the value of an item previously added with 9000 * putParcelableArrayListExtra(), or null if no 9001 * ArrayList<Parcelable> value was found. 9002 * 9003 * @deprecated Use the type-safer {@link #getParcelableArrayListExtra(String, Class)} starting 9004 * from Android {@link Build.VERSION_CODES#TIRAMISU}. 9005 * 9006 * @see #putParcelableArrayListExtra(String, ArrayList) 9007 */ 9008 @Deprecated getParcelableArrayListExtra(String name)9009 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) { 9010 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name); 9011 } 9012 9013 /** 9014 * Retrieve extended data from the intent. 9015 * 9016 * @param name The name of the desired item. 9017 * @param clazz The type of the items inside the array list. This is only verified when 9018 * unparceling. 9019 * 9020 * @return the value of an item previously added with 9021 * putParcelableArrayListExtra(), or null if no 9022 * ArrayList<Parcelable> value was found. 9023 * 9024 * @see #putParcelableArrayListExtra(String, ArrayList) 9025 */ 9026 @SuppressLint({"ConcreteCollection", "NullableCollection"}) getParcelableArrayListExtra(@ullable String name, @NonNull Class<? extends T> clazz)9027 public @Nullable <T> ArrayList<T> getParcelableArrayListExtra(@Nullable String name, 9028 @NonNull Class<? extends T> clazz) { 9029 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name, clazz); 9030 } 9031 9032 /** 9033 * Retrieve extended data from the intent. 9034 * 9035 * @param name The name of the desired item. 9036 * 9037 * @return the value of an item previously added with putExtra(), 9038 * or null if no Serializable value was found. 9039 * 9040 * @deprecated Use the type-safer {@link #getSerializableExtra(String, Class)} starting from 9041 * Android {@link Build.VERSION_CODES#TIRAMISU}. 9042 * 9043 * @see #putExtra(String, Serializable) 9044 */ getSerializableExtra(String name)9045 public @Nullable Serializable getSerializableExtra(String name) { 9046 return mExtras == null ? null : mExtras.getSerializable(name); 9047 } 9048 9049 /** 9050 * Retrieve extended data from the intent. 9051 * 9052 * @param name The name of the desired item. 9053 * @param clazz The type of the object expected. 9054 * 9055 * @return the value of an item previously added with putExtra(), 9056 * or null if no Serializable value was found. 9057 * 9058 * @see #putExtra(String, Serializable) 9059 */ getSerializableExtra(@ullable String name, @NonNull Class<T> clazz)9060 public @Nullable <T extends Serializable> T getSerializableExtra(@Nullable String name, 9061 @NonNull Class<T> clazz) { 9062 return mExtras == null ? null : mExtras.getSerializable(name, clazz); 9063 } 9064 9065 /** 9066 * Retrieve extended data from the intent. 9067 * 9068 * @param name The name of the desired item. 9069 * 9070 * @return the value of an item previously added with 9071 * putIntegerArrayListExtra(), or null if no 9072 * ArrayList<Integer> value was found. 9073 * 9074 * @see #putIntegerArrayListExtra(String, ArrayList) 9075 */ getIntegerArrayListExtra(String name)9076 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) { 9077 return mExtras == null ? null : mExtras.getIntegerArrayList(name); 9078 } 9079 9080 /** 9081 * Retrieve extended data from the intent. 9082 * 9083 * @param name The name of the desired item. 9084 * 9085 * @return the value of an item previously added with 9086 * putStringArrayListExtra(), or null if no 9087 * ArrayList<String> value was found. 9088 * 9089 * @see #putStringArrayListExtra(String, ArrayList) 9090 */ getStringArrayListExtra(String name)9091 public @Nullable ArrayList<String> getStringArrayListExtra(String name) { 9092 return mExtras == null ? null : mExtras.getStringArrayList(name); 9093 } 9094 9095 /** 9096 * Retrieve extended data from the intent. 9097 * 9098 * @param name The name of the desired item. 9099 * 9100 * @return the value of an item previously added with 9101 * putCharSequenceArrayListExtra, or null if no 9102 * ArrayList<CharSequence> value was found. 9103 * 9104 * @see #putCharSequenceArrayListExtra(String, ArrayList) 9105 */ getCharSequenceArrayListExtra(String name)9106 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) { 9107 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name); 9108 } 9109 9110 /** 9111 * Retrieve extended data from the intent. 9112 * 9113 * @param name The name of the desired item. 9114 * 9115 * @return the value of an item previously added with putExtra(), 9116 * or null if no boolean array value was found. 9117 * 9118 * @see #putExtra(String, boolean[]) 9119 */ getBooleanArrayExtra(String name)9120 public @Nullable boolean[] getBooleanArrayExtra(String name) { 9121 return mExtras == null ? null : mExtras.getBooleanArray(name); 9122 } 9123 9124 /** 9125 * Retrieve extended data from the intent. 9126 * 9127 * @param name The name of the desired item. 9128 * 9129 * @return the value of an item previously added with putExtra(), 9130 * or null if no byte array value was found. 9131 * 9132 * @see #putExtra(String, byte[]) 9133 */ getByteArrayExtra(String name)9134 public @Nullable byte[] getByteArrayExtra(String name) { 9135 return mExtras == null ? null : mExtras.getByteArray(name); 9136 } 9137 9138 /** 9139 * Retrieve extended data from the intent. 9140 * 9141 * @param name The name of the desired item. 9142 * 9143 * @return the value of an item previously added with putExtra(), 9144 * or null if no short array value was found. 9145 * 9146 * @see #putExtra(String, short[]) 9147 */ getShortArrayExtra(String name)9148 public @Nullable short[] getShortArrayExtra(String name) { 9149 return mExtras == null ? null : mExtras.getShortArray(name); 9150 } 9151 9152 /** 9153 * Retrieve extended data from the intent. 9154 * 9155 * @param name The name of the desired item. 9156 * 9157 * @return the value of an item previously added with putExtra(), 9158 * or null if no char array value was found. 9159 * 9160 * @see #putExtra(String, char[]) 9161 */ getCharArrayExtra(String name)9162 public @Nullable char[] getCharArrayExtra(String name) { 9163 return mExtras == null ? null : mExtras.getCharArray(name); 9164 } 9165 9166 /** 9167 * Retrieve extended data from the intent. 9168 * 9169 * @param name The name of the desired item. 9170 * 9171 * @return the value of an item previously added with putExtra(), 9172 * or null if no int array value was found. 9173 * 9174 * @see #putExtra(String, int[]) 9175 */ getIntArrayExtra(String name)9176 public @Nullable int[] getIntArrayExtra(String name) { 9177 return mExtras == null ? null : mExtras.getIntArray(name); 9178 } 9179 9180 /** 9181 * Retrieve extended data from the intent. 9182 * 9183 * @param name The name of the desired item. 9184 * 9185 * @return the value of an item previously added with putExtra(), 9186 * or null if no long array value was found. 9187 * 9188 * @see #putExtra(String, long[]) 9189 */ getLongArrayExtra(String name)9190 public @Nullable long[] getLongArrayExtra(String name) { 9191 return mExtras == null ? null : mExtras.getLongArray(name); 9192 } 9193 9194 /** 9195 * Retrieve extended data from the intent. 9196 * 9197 * @param name The name of the desired item. 9198 * 9199 * @return the value of an item previously added with putExtra(), 9200 * or null if no float array value was found. 9201 * 9202 * @see #putExtra(String, float[]) 9203 */ getFloatArrayExtra(String name)9204 public @Nullable float[] getFloatArrayExtra(String name) { 9205 return mExtras == null ? null : mExtras.getFloatArray(name); 9206 } 9207 9208 /** 9209 * Retrieve extended data from the intent. 9210 * 9211 * @param name The name of the desired item. 9212 * 9213 * @return the value of an item previously added with putExtra(), 9214 * or null if no double array value was found. 9215 * 9216 * @see #putExtra(String, double[]) 9217 */ getDoubleArrayExtra(String name)9218 public @Nullable double[] getDoubleArrayExtra(String name) { 9219 return mExtras == null ? null : mExtras.getDoubleArray(name); 9220 } 9221 9222 /** 9223 * Retrieve extended data from the intent. 9224 * 9225 * @param name The name of the desired item. 9226 * 9227 * @return the value of an item previously added with putExtra(), 9228 * or null if no String array value was found. 9229 * 9230 * @see #putExtra(String, String[]) 9231 */ getStringArrayExtra(String name)9232 public @Nullable String[] getStringArrayExtra(String name) { 9233 return mExtras == null ? null : mExtras.getStringArray(name); 9234 } 9235 9236 /** 9237 * Retrieve extended data from the intent. 9238 * 9239 * @param name The name of the desired item. 9240 * 9241 * @return the value of an item previously added with putExtra(), 9242 * or null if no CharSequence array value was found. 9243 * 9244 * @see #putExtra(String, CharSequence[]) 9245 */ getCharSequenceArrayExtra(String name)9246 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) { 9247 return mExtras == null ? null : mExtras.getCharSequenceArray(name); 9248 } 9249 9250 /** 9251 * Retrieve extended data from the intent. 9252 * 9253 * @param name The name of the desired item. 9254 * 9255 * @return the value of an item previously added with putExtra(), 9256 * or null if no Bundle value was found. 9257 * 9258 * @see #putExtra(String, Bundle) 9259 */ getBundleExtra(String name)9260 public @Nullable Bundle getBundleExtra(String name) { 9261 return mExtras == null ? null : mExtras.getBundle(name); 9262 } 9263 9264 /** 9265 * Retrieve extended data from the intent. 9266 * 9267 * @param name The name of the desired item. 9268 * 9269 * @return the value of an item previously added with putExtra(), 9270 * or null if no IBinder value was found. 9271 * 9272 * @see #putExtra(String, IBinder) 9273 * 9274 * @deprecated 9275 * @hide 9276 */ 9277 @Deprecated 9278 @UnsupportedAppUsage getIBinderExtra(String name)9279 public IBinder getIBinderExtra(String name) { 9280 return mExtras == null ? null : mExtras.getIBinder(name); 9281 } 9282 9283 /** 9284 * Retrieve extended data from the intent. 9285 * 9286 * @param name The name of the desired item. 9287 * @param defaultValue The default value to return in case no item is 9288 * associated with the key 'name' 9289 * 9290 * @return the value of an item previously added with putExtra(), 9291 * or defaultValue if none was found. 9292 * 9293 * @see #putExtra 9294 * 9295 * @deprecated 9296 * @hide 9297 */ 9298 @Deprecated 9299 @UnsupportedAppUsage getExtra(String name, Object defaultValue)9300 public Object getExtra(String name, Object defaultValue) { 9301 Object result = defaultValue; 9302 if (mExtras != null) { 9303 Object result2 = mExtras.get(name); 9304 if (result2 != null) { 9305 result = result2; 9306 } 9307 } 9308 9309 return result; 9310 } 9311 9312 /** 9313 * Retrieves a map of extended data from the intent. 9314 * 9315 * @return the map of all extras previously added with putExtra(), 9316 * or null if none have been added. 9317 */ getExtras()9318 public @Nullable Bundle getExtras() { 9319 return (mExtras != null) 9320 ? new Bundle(mExtras) 9321 : null; 9322 } 9323 9324 /** 9325 * Returns the total size of the extras in bytes, or 0 if no extras are present. 9326 * @hide 9327 */ getExtrasTotalSize()9328 public int getExtrasTotalSize() { 9329 return (mExtras != null) 9330 ? mExtras.getSize() 9331 : 0; 9332 } 9333 9334 /** 9335 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or 9336 * return itself as-is. 9337 * @hide 9338 */ canStripForHistory()9339 public boolean canStripForHistory() { 9340 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null); 9341 } 9342 9343 /** 9344 * Call it when the system needs to keep an intent for logging purposes to remove fields 9345 * that are not needed for logging. 9346 * @hide 9347 */ maybeStripForHistory()9348 public Intent maybeStripForHistory() { 9349 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras? 9350 9351 if (!canStripForHistory()) { 9352 return this; 9353 } 9354 return new Intent(this, COPY_MODE_HISTORY); 9355 } 9356 9357 /** 9358 * Retrieve any special flags associated with this intent. You will 9359 * normally just set them with {@link #setFlags} and let the system 9360 * take the appropriate action with them. 9361 * 9362 * @return The currently set flags. 9363 * @see #setFlags 9364 * @see #addFlags 9365 * @see #removeFlags 9366 */ getFlags()9367 public @Flags int getFlags() { 9368 return mFlags; 9369 } 9370 9371 /** @hide */ 9372 @UnsupportedAppUsage isExcludingStopped()9373 public boolean isExcludingStopped() { 9374 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES)) 9375 == FLAG_EXCLUDE_STOPPED_PACKAGES; 9376 } 9377 9378 /** 9379 * Retrieve the application package name this Intent is limited to. When 9380 * resolving an Intent, if non-null this limits the resolution to only 9381 * components in the given application package. 9382 * 9383 * @return The name of the application package for the Intent. 9384 * 9385 * @see #resolveActivity 9386 * @see #setPackage 9387 */ getPackage()9388 public @Nullable String getPackage() { 9389 return mPackage; 9390 } 9391 9392 /** 9393 * Retrieve the concrete component associated with the intent. When receiving 9394 * an intent, this is the component that was found to best handle it (that is, 9395 * yourself) and will always be non-null; in all other cases it will be 9396 * null unless explicitly set. 9397 * 9398 * @return The name of the application component to handle the intent. 9399 * 9400 * @see #resolveActivity 9401 * @see #setComponent 9402 */ getComponent()9403 public @Nullable ComponentName getComponent() { 9404 return mComponent; 9405 } 9406 9407 /** 9408 * Get the bounds of the sender of this intent, in screen coordinates. This can be 9409 * used as a hint to the receiver for animations and the like. Null means that there 9410 * is no source bounds. 9411 */ getSourceBounds()9412 public @Nullable Rect getSourceBounds() { 9413 return mSourceBounds; 9414 } 9415 9416 /** 9417 * Return the Activity component that should be used to handle this intent. 9418 * The appropriate component is determined based on the information in the 9419 * intent, evaluated as follows: 9420 * 9421 * <p>If {@link #getComponent} returns an explicit class, that is returned 9422 * without any further consideration. 9423 * 9424 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent 9425 * category to be considered. 9426 * 9427 * <p>If {@link #getAction} is non-NULL, the activity must handle this 9428 * action. 9429 * 9430 * <p>If {@link #resolveType} returns non-NULL, the activity must handle 9431 * this type. 9432 * 9433 * <p>If {@link #addCategory} has added any categories, the activity must 9434 * handle ALL of the categories specified. 9435 * 9436 * <p>If {@link #getPackage} is non-NULL, only activity components in 9437 * that application package will be considered. 9438 * 9439 * <p>If there are no activities that satisfy all of these conditions, a 9440 * null string is returned. 9441 * 9442 * <p>If multiple activities are found to satisfy the intent, the one with 9443 * the highest priority will be used. If there are multiple activities 9444 * with the same priority, the system will either pick the best activity 9445 * based on user preference, or resolve to a system class that will allow 9446 * the user to pick an activity and forward from there. 9447 * 9448 * <p>This method is implemented simply by calling 9449 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter 9450 * true.</p> 9451 * <p> This API is called for you as part of starting an activity from an 9452 * intent. You do not normally need to call it yourself.</p> 9453 * 9454 * @param pm The package manager with which to resolve the Intent. 9455 * 9456 * @return Name of the component implementing an activity that can 9457 * display the intent. 9458 * 9459 * @see #setComponent 9460 * @see #getComponent 9461 * @see #resolveActivityInfo 9462 */ resolveActivity(@onNull PackageManager pm)9463 public ComponentName resolveActivity(@NonNull PackageManager pm) { 9464 if (mComponent != null) { 9465 return mComponent; 9466 } 9467 9468 ResolveInfo info = pm.resolveActivity( 9469 this, PackageManager.MATCH_DEFAULT_ONLY); 9470 if (info != null) { 9471 return new ComponentName( 9472 info.activityInfo.applicationInfo.packageName, 9473 info.activityInfo.name); 9474 } 9475 9476 return null; 9477 } 9478 9479 /** 9480 * Resolve the Intent into an {@link ActivityInfo} 9481 * describing the activity that should execute the intent. Resolution 9482 * follows the same rules as described for {@link #resolveActivity}, but 9483 * you get back the completely information about the resolved activity 9484 * instead of just its class name. 9485 * 9486 * @param pm The package manager with which to resolve the Intent. 9487 * @param flags Addition information to retrieve as per 9488 * {@link PackageManager#getActivityInfo(ComponentName, int) 9489 * PackageManager.getActivityInfo()}. 9490 * 9491 * @return PackageManager.ActivityInfo 9492 * 9493 * @see #resolveActivity 9494 */ resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)9495 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm, 9496 @PackageManager.ComponentInfoFlagsBits int flags) { 9497 ActivityInfo ai = null; 9498 if (mComponent != null) { 9499 try { 9500 ai = pm.getActivityInfo(mComponent, flags); 9501 } catch (PackageManager.NameNotFoundException e) { 9502 // ignore 9503 } 9504 } else { 9505 ResolveInfo info = pm.resolveActivity( 9506 this, PackageManager.MATCH_DEFAULT_ONLY | flags); 9507 if (info != null) { 9508 ai = info.activityInfo; 9509 } 9510 } 9511 9512 return ai; 9513 } 9514 9515 /** 9516 * Special function for use by the system to resolve service 9517 * intents to system apps. Throws an exception if there are 9518 * multiple potential matches to the Intent. Returns null if 9519 * there are no matches. 9520 * @hide 9521 */ 9522 @UnsupportedAppUsage resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlagsBits int flags)9523 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm, 9524 @PackageManager.ComponentInfoFlagsBits int flags) { 9525 if (mComponent != null) { 9526 return mComponent; 9527 } 9528 9529 List<ResolveInfo> results = pm.queryIntentServices(this, flags); 9530 if (results == null) { 9531 return null; 9532 } 9533 ComponentName comp = null; 9534 for (int i=0; i<results.size(); i++) { 9535 ResolveInfo ri = results.get(i); 9536 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { 9537 continue; 9538 } 9539 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName, 9540 ri.serviceInfo.name); 9541 if (comp != null) { 9542 throw new IllegalStateException("Multiple system services handle " + this 9543 + ": " + comp + ", " + foundComp); 9544 } 9545 comp = foundComp; 9546 } 9547 return comp; 9548 } 9549 9550 /** 9551 * Set the general action to be performed. 9552 * 9553 * @param action An action name, such as ACTION_VIEW. Application-specific 9554 * actions should be prefixed with the vendor's package name. 9555 * 9556 * @return Returns the same Intent object, for chaining multiple calls 9557 * into a single statement. 9558 * 9559 * @see #getAction 9560 */ setAction(@ullable String action)9561 public @NonNull Intent setAction(@Nullable String action) { 9562 mAction = action != null ? action.intern() : null; 9563 return this; 9564 } 9565 9566 /** 9567 * Set the data this intent is operating on. This method automatically 9568 * clears any type that was previously set by {@link #setType} or 9569 * {@link #setTypeAndNormalize}. 9570 * 9571 * <p><em>Note: scheme matching in the Android framework is 9572 * case-sensitive, unlike the formal RFC. As a result, 9573 * you should always write your Uri with a lower case scheme, 9574 * or use {@link Uri#normalizeScheme} or 9575 * {@link #setDataAndNormalize} 9576 * to ensure that the scheme is converted to lower case.</em> 9577 * 9578 * @param data The Uri of the data this intent is now targeting. 9579 * 9580 * @return Returns the same Intent object, for chaining multiple calls 9581 * into a single statement. 9582 * 9583 * @see #getData 9584 * @see #setDataAndNormalize 9585 * @see android.net.Uri#normalizeScheme() 9586 */ setData(@ullable Uri data)9587 public @NonNull Intent setData(@Nullable Uri data) { 9588 mData = data; 9589 mType = null; 9590 return this; 9591 } 9592 9593 /** 9594 * Normalize and set the data this intent is operating on. 9595 * 9596 * <p>This method automatically clears any type that was 9597 * previously set (for example, by {@link #setType}). 9598 * 9599 * <p>The data Uri is normalized using 9600 * {@link android.net.Uri#normalizeScheme} before it is set, 9601 * so really this is just a convenience method for 9602 * <pre> 9603 * setData(data.normalize()) 9604 * </pre> 9605 * 9606 * @param data The Uri of the data this intent is now targeting. 9607 * 9608 * @return Returns the same Intent object, for chaining multiple calls 9609 * into a single statement. 9610 * 9611 * @see #getData 9612 * @see #setType 9613 * @see android.net.Uri#normalizeScheme 9614 */ setDataAndNormalize(@onNull Uri data)9615 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) { 9616 return setData(data.normalizeScheme()); 9617 } 9618 9619 /** 9620 * Set an explicit MIME data type. 9621 * 9622 * <p>This is used to create intents that only specify a type and not data, 9623 * for example to indicate the type of data to return. 9624 * 9625 * <p>This method automatically clears any data that was 9626 * previously set (for example by {@link #setData}). 9627 * 9628 * <p><em>Note: MIME type matching in the Android framework is 9629 * case-sensitive, unlike formal RFC MIME types. As a result, 9630 * you should always write your MIME types with lower case letters, 9631 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize} 9632 * to ensure that it is converted to lower case.</em> 9633 * 9634 * @param type The MIME type of the data being handled by this intent. 9635 * 9636 * @return Returns the same Intent object, for chaining multiple calls 9637 * into a single statement. 9638 * 9639 * @see #getType 9640 * @see #setTypeAndNormalize 9641 * @see #setDataAndType 9642 * @see #normalizeMimeType 9643 */ setType(@ullable String type)9644 public @NonNull Intent setType(@Nullable String type) { 9645 mData = null; 9646 mType = type; 9647 return this; 9648 } 9649 9650 /** 9651 * Normalize and set an explicit MIME data type. 9652 * 9653 * <p>This is used to create intents that only specify a type and not data, 9654 * for example to indicate the type of data to return. 9655 * 9656 * <p>This method automatically clears any data that was 9657 * previously set (for example by {@link #setData}). 9658 * 9659 * <p>The MIME type is normalized using 9660 * {@link #normalizeMimeType} before it is set, 9661 * so really this is just a convenience method for 9662 * <pre> 9663 * setType(Intent.normalizeMimeType(type)) 9664 * </pre> 9665 * 9666 * @param type The MIME type of the data being handled by this intent. 9667 * 9668 * @return Returns the same Intent object, for chaining multiple calls 9669 * into a single statement. 9670 * 9671 * @see #getType 9672 * @see #setData 9673 * @see #normalizeMimeType 9674 */ setTypeAndNormalize(@ullable String type)9675 public @NonNull Intent setTypeAndNormalize(@Nullable String type) { 9676 return setType(normalizeMimeType(type)); 9677 } 9678 9679 /** 9680 * (Usually optional) Set the data for the intent along with an explicit 9681 * MIME data type. This method should very rarely be used -- it allows you 9682 * to override the MIME type that would ordinarily be inferred from the 9683 * data with your own type given here. 9684 * 9685 * <p><em>Note: MIME type and Uri scheme matching in the 9686 * Android framework is case-sensitive, unlike the formal RFC definitions. 9687 * As a result, you should always write these elements with lower case letters, 9688 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or 9689 * {@link #setDataAndTypeAndNormalize} 9690 * to ensure that they are converted to lower case.</em> 9691 * 9692 * @param data The Uri of the data this intent is now targeting. 9693 * @param type The MIME type of the data being handled by this intent. 9694 * 9695 * @return Returns the same Intent object, for chaining multiple calls 9696 * into a single statement. 9697 * 9698 * @see #setType 9699 * @see #setData 9700 * @see #normalizeMimeType 9701 * @see android.net.Uri#normalizeScheme 9702 * @see #setDataAndTypeAndNormalize 9703 */ setDataAndType(@ullable Uri data, @Nullable String type)9704 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) { 9705 mData = data; 9706 mType = type; 9707 return this; 9708 } 9709 9710 /** 9711 * (Usually optional) Normalize and set both the data Uri and an explicit 9712 * MIME data type. This method should very rarely be used -- it allows you 9713 * to override the MIME type that would ordinarily be inferred from the 9714 * data with your own type given here. 9715 * 9716 * <p>The data Uri and the MIME type are normalize using 9717 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType} 9718 * before they are set, so really this is just a convenience method for 9719 * <pre> 9720 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type)) 9721 * </pre> 9722 * 9723 * @param data The Uri of the data this intent is now targeting. 9724 * @param type The MIME type of the data being handled by this intent. 9725 * 9726 * @return Returns the same Intent object, for chaining multiple calls 9727 * into a single statement. 9728 * 9729 * @see #setType 9730 * @see #setData 9731 * @see #setDataAndType 9732 * @see #normalizeMimeType 9733 * @see android.net.Uri#normalizeScheme 9734 */ setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)9735 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) { 9736 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type)); 9737 } 9738 9739 /** 9740 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent, 9741 * allowing it to be unique from other Intents that would otherwise look the same. In 9742 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two 9743 * Intents are the same as with other fields like {@link #setAction}. However, unlike those 9744 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter}; 9745 * it is as if the identifier has not been set on the Intent. 9746 * 9747 * <p>This can be used, for example, to make this Intent unique from other Intents that 9748 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware 9749 * however that the receiver of the PendingIntent will see whatever you put in here.) The 9750 * structure of this string is completely undefined by the platform, however if you are going 9751 * to be exposing identifier strings across different applications you may need to define 9752 * your own structure if there is no central party defining the contents of this field.</p> 9753 * 9754 * @param identifier The identifier for this Intent. The contents of the string have no 9755 * meaning to the system, except whether they are exactly the same as 9756 * another identifier. 9757 * 9758 * @return Returns the same Intent object, for chaining multiple calls 9759 * into a single statement. 9760 * 9761 * @see #getIdentifier 9762 */ setIdentifier(@ullable String identifier)9763 public @NonNull Intent setIdentifier(@Nullable String identifier) { 9764 mIdentifier = identifier; 9765 return this; 9766 } 9767 9768 /** 9769 * Add a new category to the intent. Categories provide additional detail 9770 * about the action the intent performs. When resolving an intent, only 9771 * activities that provide <em>all</em> of the requested categories will be 9772 * used. 9773 * 9774 * @param category The desired category. This can be either one of the 9775 * predefined Intent categories, or a custom category in your own 9776 * namespace. 9777 * 9778 * @return Returns the same Intent object, for chaining multiple calls 9779 * into a single statement. 9780 * 9781 * @see #hasCategory 9782 * @see #removeCategory 9783 */ addCategory(String category)9784 public @NonNull Intent addCategory(String category) { 9785 if (mCategories == null) { 9786 mCategories = new ArraySet<String>(); 9787 } 9788 mCategories.add(category.intern()); 9789 return this; 9790 } 9791 9792 /** 9793 * Remove a category from an intent. 9794 * 9795 * @param category The category to remove. 9796 * 9797 * @see #addCategory 9798 */ removeCategory(String category)9799 public void removeCategory(String category) { 9800 if (mCategories != null) { 9801 mCategories.remove(category); 9802 if (mCategories.size() == 0) { 9803 mCategories = null; 9804 } 9805 } 9806 } 9807 9808 /** 9809 * Set a selector for this Intent. This is a modification to the kinds of 9810 * things the Intent will match. If the selector is set, it will be used 9811 * when trying to find entities that can handle the Intent, instead of the 9812 * main contents of the Intent. This allows you build an Intent containing 9813 * a generic protocol while targeting it more specifically. 9814 * 9815 * <p>An example of where this may be used is with things like 9816 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an 9817 * Intent that will launch the Browser application. However, the correct 9818 * main entry point of an application is actually {@link #ACTION_MAIN} 9819 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)} 9820 * used to specify the actual Activity to launch. If you launch the browser 9821 * with something different, undesired behavior may happen if the user has 9822 * previously or later launches it the normal way, since they do not match. 9823 * Instead, you can build an Intent with the MAIN action (but no ComponentName 9824 * yet specified) and set a selector with {@link #ACTION_MAIN} and 9825 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity. 9826 * 9827 * <p>Setting a selector does not impact the behavior of 9828 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the 9829 * desired behavior of a selector -- it does not impact the base meaning 9830 * of the Intent, just what kinds of things will be matched against it 9831 * when determining who can handle it.</p> 9832 * 9833 * <p>You can not use both a selector and {@link #setPackage(String)} on 9834 * the same base Intent.</p> 9835 * 9836 * @param selector The desired selector Intent; set to null to not use 9837 * a special selector. 9838 */ setSelector(@ullable Intent selector)9839 public void setSelector(@Nullable Intent selector) { 9840 if (selector == this) { 9841 throw new IllegalArgumentException( 9842 "Intent being set as a selector of itself"); 9843 } 9844 if (selector != null && mPackage != null) { 9845 throw new IllegalArgumentException( 9846 "Can't set selector when package name is already set"); 9847 } 9848 mSelector = selector; 9849 } 9850 9851 /** 9852 * Set a {@link ClipData} associated with this Intent. This replaces any 9853 * previously set ClipData. 9854 * 9855 * <p>The ClipData in an intent is not used for Intent matching or other 9856 * such operations. Semantically it is like extras, used to transmit 9857 * additional data with the Intent. The main feature of using this over 9858 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION} 9859 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI 9860 * items included in the clip data. This is useful, in particular, if 9861 * you want to transmit an Intent containing multiple <code>content:</code> 9862 * URIs for which the recipient may not have global permission to access the 9863 * content provider. 9864 * 9865 * <p>If the ClipData contains items that are themselves Intents, any 9866 * grant flags in those Intents will be ignored. Only the top-level flags 9867 * of the main Intent are respected, and will be applied to all Uri or 9868 * Intent items in the clip (or sub-items of the clip). 9869 * 9870 * <p>The MIME type, label, and icon in the ClipData object are not 9871 * directly used by Intent. Applications should generally rely on the 9872 * MIME type of the Intent itself, not what it may find in the ClipData. 9873 * A common practice is to construct a ClipData for use with an Intent 9874 * with a MIME type of "*/*". 9875 * 9876 * @param clip The new clip to set. May be null to clear the current clip. 9877 */ setClipData(@ullable ClipData clip)9878 public void setClipData(@Nullable ClipData clip) { 9879 mClipData = clip; 9880 } 9881 9882 /** 9883 * This is NOT a secure mechanism to identify the user who sent the intent. 9884 * When the intent is sent to a different user, it is used to fix uris by adding the user ID 9885 * who sent the intent. 9886 * @hide 9887 */ prepareToLeaveUser(int userId)9888 public void prepareToLeaveUser(int userId) { 9889 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user. 9890 // We want mContentUserHint to refer to the original user, so don't do anything. 9891 if (mContentUserHint == UserHandle.USER_CURRENT) { 9892 mContentUserHint = userId; 9893 } 9894 } 9895 9896 /** 9897 * Add extended data to the intent. The name must include a package 9898 * prefix, for example the app com.android.contacts would use names 9899 * like "com.android.contacts.ShowAll". 9900 * 9901 * @param name The name of the extra data, with package prefix. 9902 * @param value The boolean data value. 9903 * 9904 * @return Returns the same Intent object, for chaining multiple calls 9905 * into a single statement. 9906 * 9907 * @see #putExtras 9908 * @see #removeExtra 9909 * @see #getBooleanExtra(String, boolean) 9910 */ putExtra(String name, boolean value)9911 public @NonNull Intent putExtra(String name, boolean value) { 9912 if (mExtras == null) { 9913 mExtras = new Bundle(); 9914 } 9915 mExtras.putBoolean(name, value); 9916 return this; 9917 } 9918 9919 /** 9920 * Add extended data to the intent. The name must include a package 9921 * prefix, for example the app com.android.contacts would use names 9922 * like "com.android.contacts.ShowAll". 9923 * 9924 * @param name The name of the extra data, with package prefix. 9925 * @param value The byte data value. 9926 * 9927 * @return Returns the same Intent object, for chaining multiple calls 9928 * into a single statement. 9929 * 9930 * @see #putExtras 9931 * @see #removeExtra 9932 * @see #getByteExtra(String, byte) 9933 */ putExtra(String name, byte value)9934 public @NonNull Intent putExtra(String name, byte value) { 9935 if (mExtras == null) { 9936 mExtras = new Bundle(); 9937 } 9938 mExtras.putByte(name, value); 9939 return this; 9940 } 9941 9942 /** 9943 * Add extended data to the intent. The name must include a package 9944 * prefix, for example the app com.android.contacts would use names 9945 * like "com.android.contacts.ShowAll". 9946 * 9947 * @param name The name of the extra data, with package prefix. 9948 * @param value The char data value. 9949 * 9950 * @return Returns the same Intent object, for chaining multiple calls 9951 * into a single statement. 9952 * 9953 * @see #putExtras 9954 * @see #removeExtra 9955 * @see #getCharExtra(String, char) 9956 */ putExtra(String name, char value)9957 public @NonNull Intent putExtra(String name, char value) { 9958 if (mExtras == null) { 9959 mExtras = new Bundle(); 9960 } 9961 mExtras.putChar(name, value); 9962 return this; 9963 } 9964 9965 /** 9966 * Add extended data to the intent. The name must include a package 9967 * prefix, for example the app com.android.contacts would use names 9968 * like "com.android.contacts.ShowAll". 9969 * 9970 * @param name The name of the extra data, with package prefix. 9971 * @param value The short data value. 9972 * 9973 * @return Returns the same Intent object, for chaining multiple calls 9974 * into a single statement. 9975 * 9976 * @see #putExtras 9977 * @see #removeExtra 9978 * @see #getShortExtra(String, short) 9979 */ putExtra(String name, short value)9980 public @NonNull Intent putExtra(String name, short value) { 9981 if (mExtras == null) { 9982 mExtras = new Bundle(); 9983 } 9984 mExtras.putShort(name, value); 9985 return this; 9986 } 9987 9988 /** 9989 * Add extended data to the intent. The name must include a package 9990 * prefix, for example the app com.android.contacts would use names 9991 * like "com.android.contacts.ShowAll". 9992 * 9993 * @param name The name of the extra data, with package prefix. 9994 * @param value The integer data value. 9995 * 9996 * @return Returns the same Intent object, for chaining multiple calls 9997 * into a single statement. 9998 * 9999 * @see #putExtras 10000 * @see #removeExtra 10001 * @see #getIntExtra(String, int) 10002 */ putExtra(String name, int value)10003 public @NonNull Intent putExtra(String name, int value) { 10004 if (mExtras == null) { 10005 mExtras = new Bundle(); 10006 } 10007 mExtras.putInt(name, value); 10008 return this; 10009 } 10010 10011 /** 10012 * Add extended data to the intent. The name must include a package 10013 * prefix, for example the app com.android.contacts would use names 10014 * like "com.android.contacts.ShowAll". 10015 * 10016 * @param name The name of the extra data, with package prefix. 10017 * @param value The long data value. 10018 * 10019 * @return Returns the same Intent object, for chaining multiple calls 10020 * into a single statement. 10021 * 10022 * @see #putExtras 10023 * @see #removeExtra 10024 * @see #getLongExtra(String, long) 10025 */ putExtra(String name, long value)10026 public @NonNull Intent putExtra(String name, long value) { 10027 if (mExtras == null) { 10028 mExtras = new Bundle(); 10029 } 10030 mExtras.putLong(name, value); 10031 return this; 10032 } 10033 10034 /** 10035 * Add extended data to the intent. The name must include a package 10036 * prefix, for example the app com.android.contacts would use names 10037 * like "com.android.contacts.ShowAll". 10038 * 10039 * @param name The name of the extra data, with package prefix. 10040 * @param value The float data value. 10041 * 10042 * @return Returns the same Intent object, for chaining multiple calls 10043 * into a single statement. 10044 * 10045 * @see #putExtras 10046 * @see #removeExtra 10047 * @see #getFloatExtra(String, float) 10048 */ putExtra(String name, float value)10049 public @NonNull Intent putExtra(String name, float value) { 10050 if (mExtras == null) { 10051 mExtras = new Bundle(); 10052 } 10053 mExtras.putFloat(name, value); 10054 return this; 10055 } 10056 10057 /** 10058 * Add extended data to the intent. The name must include a package 10059 * prefix, for example the app com.android.contacts would use names 10060 * like "com.android.contacts.ShowAll". 10061 * 10062 * @param name The name of the extra data, with package prefix. 10063 * @param value The double data value. 10064 * 10065 * @return Returns the same Intent object, for chaining multiple calls 10066 * into a single statement. 10067 * 10068 * @see #putExtras 10069 * @see #removeExtra 10070 * @see #getDoubleExtra(String, double) 10071 */ putExtra(String name, double value)10072 public @NonNull Intent putExtra(String name, double value) { 10073 if (mExtras == null) { 10074 mExtras = new Bundle(); 10075 } 10076 mExtras.putDouble(name, value); 10077 return this; 10078 } 10079 10080 /** 10081 * Add extended data to the intent. The name must include a package 10082 * prefix, for example the app com.android.contacts would use names 10083 * like "com.android.contacts.ShowAll". 10084 * 10085 * @param name The name of the extra data, with package prefix. 10086 * @param value The String data value. 10087 * 10088 * @return Returns the same Intent object, for chaining multiple calls 10089 * into a single statement. 10090 * 10091 * @see #putExtras 10092 * @see #removeExtra 10093 * @see #getStringExtra(String) 10094 */ putExtra(String name, @Nullable String value)10095 public @NonNull Intent putExtra(String name, @Nullable String value) { 10096 if (mExtras == null) { 10097 mExtras = new Bundle(); 10098 } 10099 mExtras.putString(name, value); 10100 return this; 10101 } 10102 10103 /** 10104 * Add extended data to the intent. The name must include a package 10105 * prefix, for example the app com.android.contacts would use names 10106 * like "com.android.contacts.ShowAll". 10107 * 10108 * @param name The name of the extra data, with package prefix. 10109 * @param value The CharSequence data value. 10110 * 10111 * @return Returns the same Intent object, for chaining multiple calls 10112 * into a single statement. 10113 * 10114 * @see #putExtras 10115 * @see #removeExtra 10116 * @see #getCharSequenceExtra(String) 10117 */ putExtra(String name, @Nullable CharSequence value)10118 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) { 10119 if (mExtras == null) { 10120 mExtras = new Bundle(); 10121 } 10122 mExtras.putCharSequence(name, value); 10123 return this; 10124 } 10125 10126 /** 10127 * Add extended data to the intent. The name must include a package 10128 * prefix, for example the app com.android.contacts would use names 10129 * like "com.android.contacts.ShowAll". 10130 * 10131 * @param name The name of the extra data, with package prefix. 10132 * @param value The Parcelable data value. 10133 * 10134 * @return Returns the same Intent object, for chaining multiple calls 10135 * into a single statement. 10136 * 10137 * @see #putExtras 10138 * @see #removeExtra 10139 * @see #getParcelableExtra(String) 10140 */ putExtra(String name, @Nullable Parcelable value)10141 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) { 10142 if (mExtras == null) { 10143 mExtras = new Bundle(); 10144 } 10145 mExtras.putParcelable(name, value); 10146 return this; 10147 } 10148 10149 /** 10150 * Add extended data to the intent. The name must include a package 10151 * prefix, for example the app com.android.contacts would use names 10152 * like "com.android.contacts.ShowAll". 10153 * 10154 * @param name The name of the extra data, with package prefix. 10155 * @param value The Parcelable[] data value. 10156 * 10157 * @return Returns the same Intent object, for chaining multiple calls 10158 * into a single statement. 10159 * 10160 * @see #putExtras 10161 * @see #removeExtra 10162 * @see #getParcelableArrayExtra(String) 10163 */ putExtra(String name, @Nullable Parcelable[] value)10164 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) { 10165 if (mExtras == null) { 10166 mExtras = new Bundle(); 10167 } 10168 mExtras.putParcelableArray(name, value); 10169 return this; 10170 } 10171 10172 /** 10173 * Add extended data to the intent. The name must include a package 10174 * prefix, for example the app com.android.contacts would use names 10175 * like "com.android.contacts.ShowAll". 10176 * 10177 * @param name The name of the extra data, with package prefix. 10178 * @param value The ArrayList<Parcelable> data value. 10179 * 10180 * @return Returns the same Intent object, for chaining multiple calls 10181 * into a single statement. 10182 * 10183 * @see #putExtras 10184 * @see #removeExtra 10185 * @see #getParcelableArrayListExtra(String) 10186 */ putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)10187 public @NonNull Intent putParcelableArrayListExtra(String name, 10188 @Nullable ArrayList<? extends Parcelable> value) { 10189 if (mExtras == null) { 10190 mExtras = new Bundle(); 10191 } 10192 mExtras.putParcelableArrayList(name, value); 10193 return this; 10194 } 10195 10196 /** 10197 * Add extended data to the intent. The name must include a package 10198 * prefix, for example the app com.android.contacts would use names 10199 * like "com.android.contacts.ShowAll". 10200 * 10201 * @param name The name of the extra data, with package prefix. 10202 * @param value The ArrayList<Integer> data value. 10203 * 10204 * @return Returns the same Intent object, for chaining multiple calls 10205 * into a single statement. 10206 * 10207 * @see #putExtras 10208 * @see #removeExtra 10209 * @see #getIntegerArrayListExtra(String) 10210 */ putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)10211 public @NonNull Intent putIntegerArrayListExtra(String name, 10212 @Nullable ArrayList<Integer> value) { 10213 if (mExtras == null) { 10214 mExtras = new Bundle(); 10215 } 10216 mExtras.putIntegerArrayList(name, value); 10217 return this; 10218 } 10219 10220 /** 10221 * Add extended data to the intent. The name must include a package 10222 * prefix, for example the app com.android.contacts would use names 10223 * like "com.android.contacts.ShowAll". 10224 * 10225 * @param name The name of the extra data, with package prefix. 10226 * @param value The ArrayList<String> data value. 10227 * 10228 * @return Returns the same Intent object, for chaining multiple calls 10229 * into a single statement. 10230 * 10231 * @see #putExtras 10232 * @see #removeExtra 10233 * @see #getStringArrayListExtra(String) 10234 */ putStringArrayListExtra(String name, @Nullable ArrayList<String> value)10235 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) { 10236 if (mExtras == null) { 10237 mExtras = new Bundle(); 10238 } 10239 mExtras.putStringArrayList(name, value); 10240 return this; 10241 } 10242 10243 /** 10244 * Add extended data to the intent. The name must include a package 10245 * prefix, for example the app com.android.contacts would use names 10246 * like "com.android.contacts.ShowAll". 10247 * 10248 * @param name The name of the extra data, with package prefix. 10249 * @param value The ArrayList<CharSequence> data value. 10250 * 10251 * @return Returns the same Intent object, for chaining multiple calls 10252 * into a single statement. 10253 * 10254 * @see #putExtras 10255 * @see #removeExtra 10256 * @see #getCharSequenceArrayListExtra(String) 10257 */ putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)10258 public @NonNull Intent putCharSequenceArrayListExtra(String name, 10259 @Nullable ArrayList<CharSequence> value) { 10260 if (mExtras == null) { 10261 mExtras = new Bundle(); 10262 } 10263 mExtras.putCharSequenceArrayList(name, value); 10264 return this; 10265 } 10266 10267 /** 10268 * Add extended data to the intent. The name must include a package 10269 * prefix, for example the app com.android.contacts would use names 10270 * like "com.android.contacts.ShowAll". 10271 * 10272 * @param name The name of the extra data, with package prefix. 10273 * @param value The Serializable data value. 10274 * 10275 * @return Returns the same Intent object, for chaining multiple calls 10276 * into a single statement. 10277 * 10278 * @see #putExtras 10279 * @see #removeExtra 10280 * @see #getSerializableExtra(String) 10281 */ putExtra(String name, @Nullable Serializable value)10282 public @NonNull Intent putExtra(String name, @Nullable Serializable value) { 10283 if (mExtras == null) { 10284 mExtras = new Bundle(); 10285 } 10286 mExtras.putSerializable(name, value); 10287 return this; 10288 } 10289 10290 /** 10291 * Add extended data to the intent. The name must include a package 10292 * prefix, for example the app com.android.contacts would use names 10293 * like "com.android.contacts.ShowAll". 10294 * 10295 * @param name The name of the extra data, with package prefix. 10296 * @param value The boolean array data value. 10297 * 10298 * @return Returns the same Intent object, for chaining multiple calls 10299 * into a single statement. 10300 * 10301 * @see #putExtras 10302 * @see #removeExtra 10303 * @see #getBooleanArrayExtra(String) 10304 */ putExtra(String name, @Nullable boolean[] value)10305 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) { 10306 if (mExtras == null) { 10307 mExtras = new Bundle(); 10308 } 10309 mExtras.putBooleanArray(name, value); 10310 return this; 10311 } 10312 10313 /** 10314 * Add extended data to the intent. The name must include a package 10315 * prefix, for example the app com.android.contacts would use names 10316 * like "com.android.contacts.ShowAll". 10317 * 10318 * @param name The name of the extra data, with package prefix. 10319 * @param value The byte array data value. 10320 * 10321 * @return Returns the same Intent object, for chaining multiple calls 10322 * into a single statement. 10323 * 10324 * @see #putExtras 10325 * @see #removeExtra 10326 * @see #getByteArrayExtra(String) 10327 */ putExtra(String name, @Nullable byte[] value)10328 public @NonNull Intent putExtra(String name, @Nullable byte[] value) { 10329 if (mExtras == null) { 10330 mExtras = new Bundle(); 10331 } 10332 mExtras.putByteArray(name, value); 10333 return this; 10334 } 10335 10336 /** 10337 * Add extended data to the intent. The name must include a package 10338 * prefix, for example the app com.android.contacts would use names 10339 * like "com.android.contacts.ShowAll". 10340 * 10341 * @param name The name of the extra data, with package prefix. 10342 * @param value The short array data value. 10343 * 10344 * @return Returns the same Intent object, for chaining multiple calls 10345 * into a single statement. 10346 * 10347 * @see #putExtras 10348 * @see #removeExtra 10349 * @see #getShortArrayExtra(String) 10350 */ putExtra(String name, @Nullable short[] value)10351 public @NonNull Intent putExtra(String name, @Nullable short[] value) { 10352 if (mExtras == null) { 10353 mExtras = new Bundle(); 10354 } 10355 mExtras.putShortArray(name, value); 10356 return this; 10357 } 10358 10359 /** 10360 * Add extended data to the intent. The name must include a package 10361 * prefix, for example the app com.android.contacts would use names 10362 * like "com.android.contacts.ShowAll". 10363 * 10364 * @param name The name of the extra data, with package prefix. 10365 * @param value The char array data value. 10366 * 10367 * @return Returns the same Intent object, for chaining multiple calls 10368 * into a single statement. 10369 * 10370 * @see #putExtras 10371 * @see #removeExtra 10372 * @see #getCharArrayExtra(String) 10373 */ putExtra(String name, @Nullable char[] value)10374 public @NonNull Intent putExtra(String name, @Nullable char[] value) { 10375 if (mExtras == null) { 10376 mExtras = new Bundle(); 10377 } 10378 mExtras.putCharArray(name, value); 10379 return this; 10380 } 10381 10382 /** 10383 * Add extended data to the intent. The name must include a package 10384 * prefix, for example the app com.android.contacts would use names 10385 * like "com.android.contacts.ShowAll". 10386 * 10387 * @param name The name of the extra data, with package prefix. 10388 * @param value The int array data value. 10389 * 10390 * @return Returns the same Intent object, for chaining multiple calls 10391 * into a single statement. 10392 * 10393 * @see #putExtras 10394 * @see #removeExtra 10395 * @see #getIntArrayExtra(String) 10396 */ putExtra(String name, @Nullable int[] value)10397 public @NonNull Intent putExtra(String name, @Nullable int[] value) { 10398 if (mExtras == null) { 10399 mExtras = new Bundle(); 10400 } 10401 mExtras.putIntArray(name, value); 10402 return this; 10403 } 10404 10405 /** 10406 * Add extended data to the intent. The name must include a package 10407 * prefix, for example the app com.android.contacts would use names 10408 * like "com.android.contacts.ShowAll". 10409 * 10410 * @param name The name of the extra data, with package prefix. 10411 * @param value The byte array data value. 10412 * 10413 * @return Returns the same Intent object, for chaining multiple calls 10414 * into a single statement. 10415 * 10416 * @see #putExtras 10417 * @see #removeExtra 10418 * @see #getLongArrayExtra(String) 10419 */ putExtra(String name, @Nullable long[] value)10420 public @NonNull Intent putExtra(String name, @Nullable long[] value) { 10421 if (mExtras == null) { 10422 mExtras = new Bundle(); 10423 } 10424 mExtras.putLongArray(name, value); 10425 return this; 10426 } 10427 10428 /** 10429 * Add extended data to the intent. The name must include a package 10430 * prefix, for example the app com.android.contacts would use names 10431 * like "com.android.contacts.ShowAll". 10432 * 10433 * @param name The name of the extra data, with package prefix. 10434 * @param value The float array data value. 10435 * 10436 * @return Returns the same Intent object, for chaining multiple calls 10437 * into a single statement. 10438 * 10439 * @see #putExtras 10440 * @see #removeExtra 10441 * @see #getFloatArrayExtra(String) 10442 */ putExtra(String name, @Nullable float[] value)10443 public @NonNull Intent putExtra(String name, @Nullable float[] value) { 10444 if (mExtras == null) { 10445 mExtras = new Bundle(); 10446 } 10447 mExtras.putFloatArray(name, value); 10448 return this; 10449 } 10450 10451 /** 10452 * Add extended data to the intent. The name must include a package 10453 * prefix, for example the app com.android.contacts would use names 10454 * like "com.android.contacts.ShowAll". 10455 * 10456 * @param name The name of the extra data, with package prefix. 10457 * @param value The double array data value. 10458 * 10459 * @return Returns the same Intent object, for chaining multiple calls 10460 * into a single statement. 10461 * 10462 * @see #putExtras 10463 * @see #removeExtra 10464 * @see #getDoubleArrayExtra(String) 10465 */ putExtra(String name, @Nullable double[] value)10466 public @NonNull Intent putExtra(String name, @Nullable double[] value) { 10467 if (mExtras == null) { 10468 mExtras = new Bundle(); 10469 } 10470 mExtras.putDoubleArray(name, value); 10471 return this; 10472 } 10473 10474 /** 10475 * Add extended data to the intent. The name must include a package 10476 * prefix, for example the app com.android.contacts would use names 10477 * like "com.android.contacts.ShowAll". 10478 * 10479 * @param name The name of the extra data, with package prefix. 10480 * @param value The String array data value. 10481 * 10482 * @return Returns the same Intent object, for chaining multiple calls 10483 * into a single statement. 10484 * 10485 * @see #putExtras 10486 * @see #removeExtra 10487 * @see #getStringArrayExtra(String) 10488 */ putExtra(String name, @Nullable String[] value)10489 public @NonNull Intent putExtra(String name, @Nullable String[] value) { 10490 if (mExtras == null) { 10491 mExtras = new Bundle(); 10492 } 10493 mExtras.putStringArray(name, value); 10494 return this; 10495 } 10496 10497 /** 10498 * Add extended data to the intent. The name must include a package 10499 * prefix, for example the app com.android.contacts would use names 10500 * like "com.android.contacts.ShowAll". 10501 * 10502 * @param name The name of the extra data, with package prefix. 10503 * @param value The CharSequence array data value. 10504 * 10505 * @return Returns the same Intent object, for chaining multiple calls 10506 * into a single statement. 10507 * 10508 * @see #putExtras 10509 * @see #removeExtra 10510 * @see #getCharSequenceArrayExtra(String) 10511 */ putExtra(String name, @Nullable CharSequence[] value)10512 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) { 10513 if (mExtras == null) { 10514 mExtras = new Bundle(); 10515 } 10516 mExtras.putCharSequenceArray(name, value); 10517 return this; 10518 } 10519 10520 /** 10521 * Add extended data to the intent. The name must include a package 10522 * prefix, for example the app com.android.contacts would use names 10523 * like "com.android.contacts.ShowAll". 10524 * 10525 * @param name The name of the extra data, with package prefix. 10526 * @param value The Bundle data value. 10527 * 10528 * @return Returns the same Intent object, for chaining multiple calls 10529 * into a single statement. 10530 * 10531 * @see #putExtras 10532 * @see #removeExtra 10533 * @see #getBundleExtra(String) 10534 */ putExtra(String name, @Nullable Bundle value)10535 public @NonNull Intent putExtra(String name, @Nullable Bundle value) { 10536 if (mExtras == null) { 10537 mExtras = new Bundle(); 10538 } 10539 mExtras.putBundle(name, value); 10540 return this; 10541 } 10542 10543 /** 10544 * Add extended data to the intent. The name must include a package 10545 * prefix, for example the app com.android.contacts would use names 10546 * like "com.android.contacts.ShowAll". 10547 * 10548 * @param name The name of the extra data, with package prefix. 10549 * @param value The IBinder data value. 10550 * 10551 * @return Returns the same Intent object, for chaining multiple calls 10552 * into a single statement. 10553 * 10554 * @see #putExtras 10555 * @see #removeExtra 10556 * @see #getIBinderExtra(String) 10557 * 10558 * @deprecated 10559 * @hide 10560 */ 10561 @Deprecated 10562 @UnsupportedAppUsage putExtra(String name, IBinder value)10563 public @NonNull Intent putExtra(String name, IBinder value) { 10564 if (mExtras == null) { 10565 mExtras = new Bundle(); 10566 } 10567 mExtras.putIBinder(name, value); 10568 return this; 10569 } 10570 10571 /** 10572 * Copy all extras in 'src' in to this intent. 10573 * 10574 * @param src Contains the extras to copy. 10575 * 10576 * @see #putExtra 10577 */ putExtras(@onNull Intent src)10578 public @NonNull Intent putExtras(@NonNull Intent src) { 10579 if (src.mExtras != null) { 10580 if (mExtras == null) { 10581 mExtras = new Bundle(src.mExtras); 10582 } else { 10583 mExtras.putAll(src.mExtras); 10584 } 10585 } 10586 // If the provided Intent was unparceled and this is not an Intent delivered to a protected 10587 // component then mark the extras as unfiltered. An Intent delivered to a protected 10588 // component had to come from a trusted component, and if unfiltered data was copied to the 10589 // delivered Intent then it would have been reported when that Intent left the sending 10590 // process. 10591 if ((src.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 10592 && (src.mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) { 10593 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 10594 } 10595 return this; 10596 } 10597 10598 /** 10599 * Add a set of extended data to the intent. The keys must include a package 10600 * prefix, for example the app com.android.contacts would use names 10601 * like "com.android.contacts.ShowAll". 10602 * 10603 * @param extras The Bundle of extras to add to this intent. 10604 * 10605 * @see #putExtra 10606 * @see #removeExtra 10607 */ putExtras(@onNull Bundle extras)10608 public @NonNull Intent putExtras(@NonNull Bundle extras) { 10609 // If the provided Bundle has not yet been unparceled then treat this as unfiltered extras. 10610 if (extras.isParcelled()) { 10611 mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS; 10612 } 10613 if (mExtras == null) { 10614 mExtras = new Bundle(); 10615 } 10616 mExtras.putAll(extras); 10617 return this; 10618 } 10619 10620 /** 10621 * Completely replace the extras in the Intent with the extras in the 10622 * given Intent. 10623 * 10624 * @param src The exact extras contained in this Intent are copied 10625 * into the target intent, replacing any that were previously there. 10626 */ replaceExtras(@onNull Intent src)10627 public @NonNull Intent replaceExtras(@NonNull Intent src) { 10628 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null; 10629 return this; 10630 } 10631 10632 /** 10633 * Completely replace the extras in the Intent with the given Bundle of 10634 * extras. 10635 * 10636 * @param extras The new set of extras in the Intent, or null to erase 10637 * all extras. 10638 */ replaceExtras(@ullable Bundle extras)10639 public @NonNull Intent replaceExtras(@Nullable Bundle extras) { 10640 mExtras = extras != null ? new Bundle(extras) : null; 10641 return this; 10642 } 10643 10644 /** 10645 * Remove extended data from the intent. 10646 * 10647 * @see #putExtra 10648 */ removeExtra(String name)10649 public void removeExtra(String name) { 10650 if (mExtras != null) { 10651 mExtras.remove(name); 10652 if (mExtras.size() == 0) { 10653 mExtras = null; 10654 } 10655 } 10656 } 10657 10658 /** 10659 * Set special flags controlling how this intent is handled. Most values 10660 * here depend on the type of component being executed by the Intent, 10661 * specifically the FLAG_ACTIVITY_* flags are all for use with 10662 * {@link Context#startActivity Context.startActivity()} and the 10663 * FLAG_RECEIVER_* flags are all for use with 10664 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}. 10665 * 10666 * <p>See the 10667 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back 10668 * Stack</a> documentation for important information on how some of these options impact 10669 * the behavior of your application. 10670 * 10671 * @param flags The desired flags. 10672 * @return Returns the same Intent object, for chaining multiple calls 10673 * into a single statement. 10674 * @see #getFlags 10675 * @see #addFlags 10676 * @see #removeFlags 10677 */ setFlags(@lags int flags)10678 public @NonNull Intent setFlags(@Flags int flags) { 10679 mFlags = flags; 10680 return this; 10681 } 10682 10683 /** 10684 * Add additional flags to the intent (or with existing flags value). 10685 * 10686 * @param flags The new flags to set. 10687 * @return Returns the same Intent object, for chaining multiple calls into 10688 * a single statement. 10689 * @see #setFlags 10690 * @see #getFlags 10691 * @see #removeFlags 10692 */ addFlags(@lags int flags)10693 public @NonNull Intent addFlags(@Flags int flags) { 10694 mFlags |= flags; 10695 return this; 10696 } 10697 10698 /** 10699 * Remove these flags from the intent. 10700 * 10701 * @param flags The flags to remove. 10702 * @see #setFlags 10703 * @see #getFlags 10704 * @see #addFlags 10705 */ removeFlags(@lags int flags)10706 public void removeFlags(@Flags int flags) { 10707 mFlags &= ~flags; 10708 } 10709 10710 /** 10711 * (Usually optional) Set an explicit application package name that limits 10712 * the components this Intent will resolve to. If left to the default 10713 * value of null, all components in all applications will considered. 10714 * If non-null, the Intent can only match the components in the given 10715 * application package. 10716 * 10717 * @param packageName The name of the application package to handle the 10718 * intent, or null to allow any application package. 10719 * 10720 * @return Returns the same Intent object, for chaining multiple calls 10721 * into a single statement. 10722 * 10723 * @see #getPackage 10724 * @see #resolveActivity 10725 */ setPackage(@ullable String packageName)10726 public @NonNull Intent setPackage(@Nullable String packageName) { 10727 if (packageName != null && mSelector != null) { 10728 throw new IllegalArgumentException( 10729 "Can't set package name when selector is already set"); 10730 } 10731 mPackage = packageName; 10732 return this; 10733 } 10734 10735 /** 10736 * (Usually optional) Explicitly set the component to handle the intent. 10737 * If left with the default value of null, the system will determine the 10738 * appropriate class to use based on the other fields (action, data, 10739 * type, categories) in the Intent. If this class is defined, the 10740 * specified class will always be used regardless of the other fields. You 10741 * should only set this value when you know you absolutely want a specific 10742 * class to be used; otherwise it is better to let the system find the 10743 * appropriate class so that you will respect the installed applications 10744 * and user preferences. 10745 * 10746 * @param component The name of the application component to handle the 10747 * intent, or null to let the system find one for you. 10748 * 10749 * @return Returns the same Intent object, for chaining multiple calls 10750 * into a single statement. 10751 * 10752 * @see #setClass 10753 * @see #setClassName(Context, String) 10754 * @see #setClassName(String, String) 10755 * @see #getComponent 10756 * @see #resolveActivity 10757 */ setComponent(@ullable ComponentName component)10758 public @NonNull Intent setComponent(@Nullable ComponentName component) { 10759 mComponent = component; 10760 return this; 10761 } 10762 10763 /** 10764 * Convenience for calling {@link #setComponent} with an 10765 * explicit class name. 10766 * 10767 * @param packageContext A Context of the application package implementing 10768 * this class. 10769 * @param className The name of a class inside of the application package 10770 * that will be used as the component for this Intent. 10771 * 10772 * @return Returns the same Intent object, for chaining multiple calls 10773 * into a single statement. 10774 * 10775 * @see #setComponent 10776 * @see #setClass 10777 */ setClassName(@onNull Context packageContext, @NonNull String className)10778 public @NonNull Intent setClassName(@NonNull Context packageContext, 10779 @NonNull String className) { 10780 mComponent = new ComponentName(packageContext, className); 10781 return this; 10782 } 10783 10784 /** 10785 * Convenience for calling {@link #setComponent} with an 10786 * explicit application package name and class name. 10787 * 10788 * @param packageName The name of the package implementing the desired 10789 * component. 10790 * @param className The name of a class inside of the application package 10791 * that will be used as the component for this Intent. 10792 * 10793 * @return Returns the same Intent object, for chaining multiple calls 10794 * into a single statement. 10795 * 10796 * @see #setComponent 10797 * @see #setClass 10798 */ setClassName(@onNull String packageName, @NonNull String className)10799 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) { 10800 mComponent = new ComponentName(packageName, className); 10801 return this; 10802 } 10803 10804 /** 10805 * Convenience for calling {@link #setComponent(ComponentName)} with the 10806 * name returned by a {@link Class} object. 10807 * 10808 * @param packageContext A Context of the application package implementing 10809 * this class. 10810 * @param cls The class name to set, equivalent to 10811 * <code>setClassName(context, cls.getName())</code>. 10812 * 10813 * @return Returns the same Intent object, for chaining multiple calls 10814 * into a single statement. 10815 * 10816 * @see #setComponent 10817 */ setClass(@onNull Context packageContext, @NonNull Class<?> cls)10818 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) { 10819 mComponent = new ComponentName(packageContext, cls); 10820 return this; 10821 } 10822 10823 /** 10824 * Set the bounds of the sender of this intent, in screen coordinates. This can be 10825 * used as a hint to the receiver for animations and the like. Null means that there 10826 * is no source bounds. 10827 */ setSourceBounds(@ullable Rect r)10828 public void setSourceBounds(@Nullable Rect r) { 10829 if (r != null) { 10830 mSourceBounds = new Rect(r); 10831 } else { 10832 mSourceBounds = null; 10833 } 10834 } 10835 10836 /** @hide */ 10837 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = { 10838 FILL_IN_ACTION, 10839 FILL_IN_DATA, 10840 FILL_IN_CATEGORIES, 10841 FILL_IN_COMPONENT, 10842 FILL_IN_PACKAGE, 10843 FILL_IN_SOURCE_BOUNDS, 10844 FILL_IN_SELECTOR, 10845 FILL_IN_CLIP_DATA 10846 }) 10847 @Retention(RetentionPolicy.SOURCE) 10848 public @interface FillInFlags {} 10849 10850 /** 10851 * Use with {@link #fillIn} to allow the current action value to be 10852 * overwritten, even if it is already set. 10853 */ 10854 public static final int FILL_IN_ACTION = 1<<0; 10855 10856 /** 10857 * Use with {@link #fillIn} to allow the current data or type value 10858 * overwritten, even if it is already set. 10859 */ 10860 public static final int FILL_IN_DATA = 1<<1; 10861 10862 /** 10863 * Use with {@link #fillIn} to allow the current categories to be 10864 * overwritten, even if they are already set. 10865 */ 10866 public static final int FILL_IN_CATEGORIES = 1<<2; 10867 10868 /** 10869 * Use with {@link #fillIn} to allow the current component value to be 10870 * overwritten, even if it is already set. 10871 */ 10872 public static final int FILL_IN_COMPONENT = 1<<3; 10873 10874 /** 10875 * Use with {@link #fillIn} to allow the current package value to be 10876 * overwritten, even if it is already set. 10877 */ 10878 public static final int FILL_IN_PACKAGE = 1<<4; 10879 10880 /** 10881 * Use with {@link #fillIn} to allow the current bounds rectangle to be 10882 * overwritten, even if it is already set. 10883 */ 10884 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5; 10885 10886 /** 10887 * Use with {@link #fillIn} to allow the current selector to be 10888 * overwritten, even if it is already set. 10889 */ 10890 public static final int FILL_IN_SELECTOR = 1<<6; 10891 10892 /** 10893 * Use with {@link #fillIn} to allow the current ClipData to be 10894 * overwritten, even if it is already set. 10895 */ 10896 public static final int FILL_IN_CLIP_DATA = 1<<7; 10897 10898 /** 10899 * Use with {@link #fillIn} to allow the current identifier value to be 10900 * overwritten, even if it is already set. 10901 */ 10902 public static final int FILL_IN_IDENTIFIER = 1<<8; 10903 10904 /** 10905 * Copy the contents of <var>other</var> in to this object, but only 10906 * where fields are not defined by this object. For purposes of a field 10907 * being defined, the following pieces of data in the Intent are 10908 * considered to be separate fields: 10909 * 10910 * <ul> 10911 * <li> action, as set by {@link #setAction}. 10912 * <li> data Uri and MIME type, as set by {@link #setData(Uri)}, 10913 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}. 10914 * <li> identifier, as set by {@link #setIdentifier}. 10915 * <li> categories, as set by {@link #addCategory}. 10916 * <li> package, as set by {@link #setPackage}. 10917 * <li> component, as set by {@link #setComponent(ComponentName)} or 10918 * related methods. 10919 * <li> source bounds, as set by {@link #setSourceBounds}. 10920 * <li> selector, as set by {@link #setSelector(Intent)}. 10921 * <li> clip data, as set by {@link #setClipData(ClipData)}. 10922 * <li> each top-level name in the associated extras. 10923 * </ul> 10924 * 10925 * <p>In addition, you can use the {@link #FILL_IN_ACTION}, 10926 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES}, 10927 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 10928 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override 10929 * the restriction where the corresponding field will not be replaced if 10930 * it is already set. 10931 * 10932 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} 10933 * is explicitly specified. The selector will only be copied if 10934 * {@link #FILL_IN_SELECTOR} is explicitly specified. 10935 * 10936 * <p>For example, consider Intent A with {data="foo", categories="bar"} 10937 * and Intent B with {action="gotit", data-type="some/thing", 10938 * categories="one","two"}. 10939 * 10940 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now 10941 * containing: {action="gotit", data-type="some/thing", 10942 * categories="bar"}. 10943 * 10944 * @param other Another Intent whose values are to be used to fill in 10945 * the current one. 10946 * @param flags Options to control which fields can be filled in. 10947 * 10948 * @return Returns a bit mask of {@link #FILL_IN_ACTION}, 10949 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE}, 10950 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, 10951 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were 10952 * changed. 10953 */ 10954 @FillInFlags fillIn(@onNull Intent other, @FillInFlags int flags)10955 public int fillIn(@NonNull Intent other, @FillInFlags int flags) { 10956 int changes = 0; 10957 boolean mayHaveCopiedUris = false; 10958 if (other.mAction != null 10959 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) { 10960 mAction = other.mAction; 10961 changes |= FILL_IN_ACTION; 10962 } 10963 if ((other.mData != null || other.mType != null) 10964 && ((mData == null && mType == null) 10965 || (flags&FILL_IN_DATA) != 0)) { 10966 mData = other.mData; 10967 mType = other.mType; 10968 changes |= FILL_IN_DATA; 10969 mayHaveCopiedUris = true; 10970 } 10971 if (other.mIdentifier != null 10972 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) { 10973 mIdentifier = other.mIdentifier; 10974 changes |= FILL_IN_IDENTIFIER; 10975 } 10976 if (other.mCategories != null 10977 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) { 10978 if (other.mCategories != null) { 10979 mCategories = new ArraySet<String>(other.mCategories); 10980 } 10981 changes |= FILL_IN_CATEGORIES; 10982 } 10983 if (other.mPackage != null 10984 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) { 10985 // Only do this if mSelector is not set. 10986 if (mSelector == null) { 10987 mPackage = other.mPackage; 10988 changes |= FILL_IN_PACKAGE; 10989 } 10990 } 10991 // Selector is special: it can only be set if explicitly allowed, 10992 // for the same reason as the component name. 10993 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) { 10994 if (mPackage == null) { 10995 mSelector = new Intent(other.mSelector); 10996 mPackage = null; 10997 changes |= FILL_IN_SELECTOR; 10998 } 10999 } 11000 if (other.mClipData != null 11001 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) { 11002 mClipData = other.mClipData; 11003 changes |= FILL_IN_CLIP_DATA; 11004 mayHaveCopiedUris = true; 11005 } 11006 // Component is special: it can -only- be set if explicitly allowed, 11007 // since otherwise the sender could force the intent somewhere the 11008 // originator didn't intend. 11009 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) { 11010 mComponent = other.mComponent; 11011 changes |= FILL_IN_COMPONENT; 11012 } 11013 mFlags |= other.mFlags; 11014 if (other.mSourceBounds != null 11015 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) { 11016 mSourceBounds = new Rect(other.mSourceBounds); 11017 changes |= FILL_IN_SOURCE_BOUNDS; 11018 } 11019 if (mExtras == null) { 11020 if (other.mExtras != null) { 11021 mExtras = new Bundle(other.mExtras); 11022 mayHaveCopiedUris = true; 11023 } 11024 } else if (other.mExtras != null) { 11025 try { 11026 Bundle newb = new Bundle(other.mExtras); 11027 newb.putAll(mExtras); 11028 mExtras = newb; 11029 mayHaveCopiedUris = true; 11030 } catch (RuntimeException e) { 11031 // Modifying the extras can cause us to unparcel the contents 11032 // of the bundle, and if we do this in the system process that 11033 // may fail. We really should handle this (i.e., the Bundle 11034 // impl shouldn't be on top of a plain map), but for now just 11035 // ignore it and keep the original contents. :( 11036 Log.w(TAG, "Failure filling in extras", e); 11037 } 11038 } 11039 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT 11040 && other.mContentUserHint != UserHandle.USER_CURRENT) { 11041 mContentUserHint = other.mContentUserHint; 11042 } 11043 return changes; 11044 } 11045 11046 /** 11047 * Wrapper class holding an Intent and implementing comparisons on it for 11048 * the purpose of filtering. The class implements its 11049 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as 11050 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and 11051 * {@link android.content.Intent#filterHashCode()} filterHashCode()} 11052 * on the wrapped Intent. 11053 */ 11054 public static final class FilterComparison { 11055 private final Intent mIntent; 11056 private final int mHashCode; 11057 FilterComparison(Intent intent)11058 public FilterComparison(Intent intent) { 11059 mIntent = intent; 11060 mHashCode = intent.filterHashCode(); 11061 } 11062 11063 /** 11064 * Return the Intent that this FilterComparison represents. 11065 * @return Returns the Intent held by the FilterComparison. Do 11066 * not modify! 11067 */ getIntent()11068 public Intent getIntent() { 11069 return mIntent; 11070 } 11071 11072 @Override equals(@ullable Object obj)11073 public boolean equals(@Nullable Object obj) { 11074 if (obj instanceof FilterComparison) { 11075 Intent other = ((FilterComparison)obj).mIntent; 11076 return mIntent.filterEquals(other); 11077 } 11078 return false; 11079 } 11080 11081 @Override hashCode()11082 public int hashCode() { 11083 return mHashCode; 11084 } 11085 } 11086 11087 /** 11088 * Determine if two intents are the same for the purposes of intent 11089 * resolution (filtering). That is, if their action, data, type, identity, 11090 * class, and categories are the same. This does <em>not</em> compare 11091 * any extra data included in the intents. Note that technically when actually 11092 * matching against an {@link IntentFilter} the identifier is ignored, while here 11093 * it is directly compared for equality like the other fields. 11094 * 11095 * @param other The other Intent to compare against. 11096 * 11097 * @return Returns true if action, data, type, class, and categories 11098 * are the same. 11099 */ filterEquals(Intent other)11100 public boolean filterEquals(Intent other) { 11101 if (other == null) { 11102 return false; 11103 } 11104 if (!Objects.equals(this.mAction, other.mAction)) return false; 11105 if (!Objects.equals(this.mData, other.mData)) return false; 11106 if (!Objects.equals(this.mType, other.mType)) return false; 11107 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false; 11108 if (!(this.hasPackageEquivalentComponent() && other.hasPackageEquivalentComponent()) 11109 && !Objects.equals(this.mPackage, other.mPackage)) { 11110 return false; 11111 } 11112 if (!Objects.equals(this.mComponent, other.mComponent)) return false; 11113 if (!Objects.equals(this.mCategories, other.mCategories)) return false; 11114 11115 return true; 11116 } 11117 11118 /** 11119 * Return {@code true} if the component name is not null and is in the same package that this 11120 * intent limited to. otherwise return {@code false}. 11121 */ hasPackageEquivalentComponent()11122 private boolean hasPackageEquivalentComponent() { 11123 return mComponent != null 11124 && (mPackage == null || mPackage.equals(mComponent.getPackageName())); 11125 } 11126 11127 /** 11128 * Generate hash code that matches semantics of filterEquals(). 11129 * 11130 * @return Returns the hash value of the action, data, type, class, and 11131 * categories. 11132 * 11133 * @see #filterEquals 11134 */ filterHashCode()11135 public int filterHashCode() { 11136 int code = 0; 11137 if (mAction != null) { 11138 code += mAction.hashCode(); 11139 } 11140 if (mData != null) { 11141 code += mData.hashCode(); 11142 } 11143 if (mType != null) { 11144 code += mType.hashCode(); 11145 } 11146 if (mIdentifier != null) { 11147 code += mIdentifier.hashCode(); 11148 } 11149 if (mPackage != null) { 11150 code += mPackage.hashCode(); 11151 } 11152 if (mComponent != null) { 11153 code += mComponent.hashCode(); 11154 } 11155 if (mCategories != null) { 11156 code += mCategories.hashCode(); 11157 } 11158 return code; 11159 } 11160 11161 @Override toString()11162 public String toString() { 11163 StringBuilder b = new StringBuilder(128); 11164 11165 b.append("Intent { "); 11166 toShortString(b, true, true, true, false); 11167 b.append(" }"); 11168 11169 return b.toString(); 11170 } 11171 11172 /** @hide */ 11173 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) toInsecureString()11174 public String toInsecureString() { 11175 StringBuilder b = new StringBuilder(128); 11176 11177 b.append("Intent { "); 11178 toShortString(b, false, true, true, false); 11179 b.append(" }"); 11180 11181 return b.toString(); 11182 } 11183 11184 /** @hide */ toShortString(boolean secure, boolean comp, boolean extras, boolean clip)11185 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) { 11186 StringBuilder b = new StringBuilder(128); 11187 toShortString(b, secure, comp, extras, clip); 11188 return b.toString(); 11189 } 11190 11191 /** @hide */ toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)11192 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, 11193 boolean clip) { 11194 boolean first = true; 11195 if (mAction != null) { 11196 b.append("act=").append(mAction); 11197 first = false; 11198 } 11199 if (mCategories != null) { 11200 if (!first) { 11201 b.append(' '); 11202 } 11203 first = false; 11204 b.append("cat=["); 11205 for (int i=0; i<mCategories.size(); i++) { 11206 if (i > 0) b.append(','); 11207 b.append(mCategories.valueAt(i)); 11208 } 11209 b.append("]"); 11210 } 11211 if (mData != null) { 11212 if (!first) { 11213 b.append(' '); 11214 } 11215 first = false; 11216 b.append("dat="); 11217 if (secure) { 11218 b.append(mData.toSafeString()); 11219 } else { 11220 b.append(mData); 11221 } 11222 } 11223 if (mType != null) { 11224 if (!first) { 11225 b.append(' '); 11226 } 11227 first = false; 11228 b.append("typ=").append(mType); 11229 } 11230 if (mIdentifier != null) { 11231 if (!first) { 11232 b.append(' '); 11233 } 11234 first = false; 11235 b.append("id=").append(mIdentifier); 11236 } 11237 if (mFlags != 0) { 11238 if (!first) { 11239 b.append(' '); 11240 } 11241 first = false; 11242 b.append("flg=0x").append(Integer.toHexString(mFlags)); 11243 } 11244 if (mPackage != null) { 11245 if (!first) { 11246 b.append(' '); 11247 } 11248 first = false; 11249 b.append("pkg=").append(mPackage); 11250 } 11251 if (comp && mComponent != null) { 11252 if (!first) { 11253 b.append(' '); 11254 } 11255 first = false; 11256 b.append("cmp=").append(mComponent.flattenToShortString()); 11257 } 11258 if (mSourceBounds != null) { 11259 if (!first) { 11260 b.append(' '); 11261 } 11262 first = false; 11263 b.append("bnds=").append(mSourceBounds.toShortString()); 11264 } 11265 if (mClipData != null) { 11266 if (!first) { 11267 b.append(' '); 11268 } 11269 b.append("clip={"); 11270 mClipData.toShortString(b, !clip || secure); 11271 first = false; 11272 b.append('}'); 11273 } 11274 if (extras && mExtras != null) { 11275 if (!first) { 11276 b.append(' '); 11277 } 11278 first = false; 11279 b.append("(has extras)"); 11280 } 11281 if (mContentUserHint != UserHandle.USER_CURRENT) { 11282 if (!first) { 11283 b.append(' '); 11284 } 11285 first = false; 11286 b.append("u=").append(mContentUserHint); 11287 } 11288 if (mSelector != null) { 11289 b.append(" sel="); 11290 mSelector.toShortString(b, secure, comp, extras, clip); 11291 b.append("}"); 11292 } 11293 if (mOriginalIntent != null) { 11294 b.append(" org={"); 11295 mOriginalIntent.toShortString(b, secure, comp, extras, clip); 11296 b.append("}"); 11297 } 11298 } 11299 11300 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId)11301 public void dumpDebug(ProtoOutputStream proto, long fieldId) { 11302 // Same input parameters that toString() gives to toShortString(). 11303 dumpDebug(proto, fieldId, true, true, true, false); 11304 } 11305 11306 /** @hide */ dumpDebug(ProtoOutputStream proto)11307 public void dumpDebug(ProtoOutputStream proto) { 11308 // Same input parameters that toString() gives to toShortString(). 11309 dumpDebugWithoutFieldId(proto, true, true, true, false); 11310 } 11311 11312 /** @hide */ dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)11313 public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, 11314 boolean extras, boolean clip) { 11315 long token = proto.start(fieldId); 11316 dumpDebugWithoutFieldId(proto, secure, comp, extras, clip); 11317 proto.end(token); 11318 } 11319 dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)11320 private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, 11321 boolean extras, boolean clip) { 11322 if (mAction != null) { 11323 proto.write(IntentProto.ACTION, mAction); 11324 } 11325 if (mCategories != null) { 11326 for (String category : mCategories) { 11327 proto.write(IntentProto.CATEGORIES, category); 11328 } 11329 } 11330 if (mData != null) { 11331 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString()); 11332 } 11333 if (mType != null) { 11334 proto.write(IntentProto.TYPE, mType); 11335 } 11336 if (mIdentifier != null) { 11337 proto.write(IntentProto.IDENTIFIER, mIdentifier); 11338 } 11339 if (mFlags != 0) { 11340 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags)); 11341 } 11342 if (mPackage != null) { 11343 proto.write(IntentProto.PACKAGE, mPackage); 11344 } 11345 if (comp && mComponent != null) { 11346 mComponent.dumpDebug(proto, IntentProto.COMPONENT); 11347 } 11348 if (mSourceBounds != null) { 11349 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString()); 11350 } 11351 if (mClipData != null) { 11352 StringBuilder b = new StringBuilder(); 11353 mClipData.toShortString(b, !clip || secure); 11354 proto.write(IntentProto.CLIP_DATA, b.toString()); 11355 } 11356 if (extras && mExtras != null) { 11357 proto.write(IntentProto.EXTRAS, mExtras.toShortString()); 11358 } 11359 if (mContentUserHint != 0) { 11360 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint); 11361 } 11362 if (mSelector != null) { 11363 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip)); 11364 } 11365 } 11366 11367 /** 11368 * Call {@link #toUri} with 0 flags. 11369 * @deprecated Use {@link #toUri} instead. 11370 */ 11371 @Deprecated toURI()11372 public String toURI() { 11373 return toUri(0); 11374 } 11375 11376 /** 11377 * Convert this Intent into a String holding a URI representation of it. 11378 * The returned URI string has been properly URI encoded, so it can be 11379 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the 11380 * Intent's data as the base URI, with an additional fragment describing 11381 * the action, categories, type, flags, package, component, and extras. 11382 * 11383 * <p>You can convert the returned string back to an Intent with 11384 * {@link #getIntent}. 11385 * 11386 * @param flags Additional operating flags. 11387 * 11388 * @return Returns a URI encoding URI string describing the entire contents 11389 * of the Intent. 11390 */ toUri(@riFlags int flags)11391 public String toUri(@UriFlags int flags) { 11392 StringBuilder uri = new StringBuilder(128); 11393 if ((flags&URI_ANDROID_APP_SCHEME) != 0) { 11394 if (mPackage == null) { 11395 throw new IllegalArgumentException( 11396 "Intent must include an explicit package name to build an android-app: " 11397 + this); 11398 } 11399 uri.append("android-app://"); 11400 uri.append(mPackage); 11401 String scheme = null; 11402 if (mData != null) { 11403 scheme = mData.getScheme(); 11404 if (scheme != null) { 11405 uri.append('/'); 11406 uri.append(scheme); 11407 String authority = mData.getEncodedAuthority(); 11408 if (authority != null) { 11409 uri.append('/'); 11410 uri.append(authority); 11411 String path = mData.getEncodedPath(); 11412 if (path != null) { 11413 uri.append(path); 11414 } 11415 String queryParams = mData.getEncodedQuery(); 11416 if (queryParams != null) { 11417 uri.append('?'); 11418 uri.append(queryParams); 11419 } 11420 String fragment = mData.getEncodedFragment(); 11421 if (fragment != null) { 11422 uri.append('#'); 11423 uri.append(fragment); 11424 } 11425 } 11426 } 11427 } 11428 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW, 11429 mPackage, flags); 11430 return uri.toString(); 11431 } 11432 String scheme = null; 11433 if (mData != null) { 11434 String data = mData.toString(); 11435 if ((flags&URI_INTENT_SCHEME) != 0) { 11436 final int N = data.length(); 11437 for (int i=0; i<N; i++) { 11438 char c = data.charAt(i); 11439 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 11440 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') { 11441 continue; 11442 } 11443 if (c == ':' && i > 0) { 11444 // Valid scheme. 11445 scheme = data.substring(0, i); 11446 uri.append("intent:"); 11447 data = data.substring(i+1); 11448 break; 11449 } 11450 11451 // No scheme. 11452 break; 11453 } 11454 } 11455 uri.append(data); 11456 11457 } else if ((flags&URI_INTENT_SCHEME) != 0) { 11458 uri.append("intent:"); 11459 } 11460 11461 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags); 11462 11463 return uri.toString(); 11464 } 11465 toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)11466 private void toUriFragment(StringBuilder uri, String scheme, String defAction, 11467 String defPackage, int flags) { 11468 StringBuilder frag = new StringBuilder(128); 11469 11470 toUriInner(frag, scheme, defAction, defPackage, flags); 11471 if (mSelector != null) { 11472 frag.append("SEL;"); 11473 // Note that for now we are not going to try to handle the 11474 // data part; not clear how to represent this as a URI, and 11475 // not much utility in it. 11476 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null, 11477 null, null, flags); 11478 } 11479 11480 if (frag.length() > 0) { 11481 uri.append("#Intent;"); 11482 uri.append(frag); 11483 uri.append("end"); 11484 } 11485 } 11486 toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)11487 private void toUriInner(StringBuilder uri, String scheme, String defAction, 11488 String defPackage, int flags) { 11489 if (scheme != null) { 11490 uri.append("scheme=").append(Uri.encode(scheme)).append(';'); 11491 } 11492 if (mAction != null && !mAction.equals(defAction)) { 11493 uri.append("action=").append(Uri.encode(mAction)).append(';'); 11494 } 11495 if (mCategories != null) { 11496 for (int i=0; i<mCategories.size(); i++) { 11497 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';'); 11498 } 11499 } 11500 if (mType != null) { 11501 uri.append("type=").append(Uri.encode(mType, "/")).append(';'); 11502 } 11503 if (mIdentifier != null) { 11504 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';'); 11505 } 11506 if (mFlags != 0) { 11507 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';'); 11508 } 11509 if (mPackage != null && !mPackage.equals(defPackage)) { 11510 uri.append("package=").append(Uri.encode(mPackage)).append(';'); 11511 } 11512 if (mComponent != null) { 11513 uri.append("component=").append(Uri.encode( 11514 mComponent.flattenToShortString(), "/")).append(';'); 11515 } 11516 if (mSourceBounds != null) { 11517 uri.append("sourceBounds=") 11518 .append(Uri.encode(mSourceBounds.flattenToString())) 11519 .append(';'); 11520 } 11521 if (mExtras != null) { 11522 for (String key : mExtras.keySet()) { 11523 final Object value = mExtras.get(key); 11524 char entryType = 11525 value instanceof String ? 'S' : 11526 value instanceof Boolean ? 'B' : 11527 value instanceof Byte ? 'b' : 11528 value instanceof Character ? 'c' : 11529 value instanceof Double ? 'd' : 11530 value instanceof Float ? 'f' : 11531 value instanceof Integer ? 'i' : 11532 value instanceof Long ? 'l' : 11533 value instanceof Short ? 's' : 11534 '\0'; 11535 11536 if (entryType != '\0') { 11537 uri.append(entryType); 11538 uri.append('.'); 11539 uri.append(Uri.encode(key)); 11540 uri.append('='); 11541 uri.append(Uri.encode(value.toString())); 11542 uri.append(';'); 11543 } 11544 } 11545 } 11546 } 11547 describeContents()11548 public int describeContents() { 11549 return (mExtras != null) ? mExtras.describeContents() : 0; 11550 } 11551 writeToParcel(Parcel out, int flags)11552 public void writeToParcel(Parcel out, int flags) { 11553 out.writeString8(mAction); 11554 Uri.writeToParcel(out, mData); 11555 out.writeString8(mType); 11556 out.writeString8(mIdentifier); 11557 out.writeInt(mFlags); 11558 out.writeString8(mPackage); 11559 ComponentName.writeToParcel(mComponent, out); 11560 11561 if (mSourceBounds != null) { 11562 out.writeInt(1); 11563 mSourceBounds.writeToParcel(out, flags); 11564 } else { 11565 out.writeInt(0); 11566 } 11567 11568 if (mCategories != null) { 11569 final int N = mCategories.size(); 11570 out.writeInt(N); 11571 for (int i=0; i<N; i++) { 11572 out.writeString8(mCategories.valueAt(i)); 11573 } 11574 } else { 11575 out.writeInt(0); 11576 } 11577 11578 if (mSelector != null) { 11579 out.writeInt(1); 11580 mSelector.writeToParcel(out, flags); 11581 } else { 11582 out.writeInt(0); 11583 } 11584 11585 if (mClipData != null) { 11586 out.writeInt(1); 11587 mClipData.writeToParcel(out, flags); 11588 } else { 11589 out.writeInt(0); 11590 } 11591 out.writeInt(mContentUserHint); 11592 out.writeBundle(mExtras); 11593 11594 if (mOriginalIntent != null) { 11595 out.writeInt(1); 11596 mOriginalIntent.writeToParcel(out, flags); 11597 } else { 11598 out.writeInt(0); 11599 } 11600 } 11601 11602 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR 11603 = new Parcelable.Creator<Intent>() { 11604 public Intent createFromParcel(Parcel in) { 11605 return new Intent(in); 11606 } 11607 public Intent[] newArray(int size) { 11608 return new Intent[size]; 11609 } 11610 }; 11611 11612 /** @hide */ Intent(Parcel in)11613 protected Intent(Parcel in) { 11614 // Remember that we came from a remote process to help detect security 11615 // issues caused by later unsafe launches 11616 mLocalFlags = LOCAL_FLAG_FROM_PARCEL; 11617 readFromParcel(in); 11618 } 11619 readFromParcel(Parcel in)11620 public void readFromParcel(Parcel in) { 11621 setAction(in.readString8()); 11622 mData = Uri.CREATOR.createFromParcel(in); 11623 mType = in.readString8(); 11624 mIdentifier = in.readString8(); 11625 mFlags = in.readInt(); 11626 mPackage = in.readString8(); 11627 mComponent = ComponentName.readFromParcel(in); 11628 11629 if (in.readInt() != 0) { 11630 mSourceBounds = Rect.CREATOR.createFromParcel(in); 11631 } 11632 11633 int N = in.readInt(); 11634 if (N > 0) { 11635 mCategories = new ArraySet<String>(); 11636 int i; 11637 for (i=0; i<N; i++) { 11638 mCategories.add(in.readString8().intern()); 11639 } 11640 } else { 11641 mCategories = null; 11642 } 11643 11644 if (in.readInt() != 0) { 11645 mSelector = new Intent(in); 11646 } 11647 11648 if (in.readInt() != 0) { 11649 mClipData = new ClipData(in); 11650 } 11651 mContentUserHint = in.readInt(); 11652 mExtras = in.readBundle(); 11653 if (in.readInt() != 0) { 11654 mOriginalIntent = new Intent(in); 11655 } 11656 } 11657 11658 /** 11659 * Parses the "intent" element (and its children) from XML and instantiates 11660 * an Intent object. The given XML parser should be located at the tag 11661 * where parsing should start (often named "intent"), from which the 11662 * basic action, data, type, and package and class name will be 11663 * retrieved. The function will then parse in to any child elements, 11664 * looking for <category android:name="xxx"> tags to add categories and 11665 * <extra android:name="xxx" android:value="yyy"> to attach extra data 11666 * to the intent. 11667 * 11668 * @param resources The Resources to use when inflating resources. 11669 * @param parser The XML parser pointing at an "intent" tag. 11670 * @param attrs The AttributeSet interface for retrieving extended 11671 * attribute data at the current <var>parser</var> location. 11672 * @return An Intent object matching the XML data. 11673 * @throws XmlPullParserException If there was an XML parsing error. 11674 * @throws IOException If there was an I/O error. 11675 */ parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)11676 public static @NonNull Intent parseIntent(@NonNull Resources resources, 11677 @NonNull XmlPullParser parser, AttributeSet attrs) 11678 throws XmlPullParserException, IOException { 11679 Intent intent = new Intent(); 11680 11681 TypedArray sa = resources.obtainAttributes(attrs, 11682 com.android.internal.R.styleable.Intent); 11683 11684 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action)); 11685 11686 String data = sa.getString(com.android.internal.R.styleable.Intent_data); 11687 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType); 11688 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType); 11689 11690 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier)); 11691 11692 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage); 11693 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass); 11694 if (packageName != null && className != null) { 11695 intent.setComponent(new ComponentName(packageName, className)); 11696 } 11697 11698 sa.recycle(); 11699 11700 int outerDepth = parser.getDepth(); 11701 int type; 11702 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT 11703 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { 11704 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { 11705 continue; 11706 } 11707 11708 String nodeName = parser.getName(); 11709 if (nodeName.equals(TAG_CATEGORIES)) { 11710 sa = resources.obtainAttributes(attrs, 11711 com.android.internal.R.styleable.IntentCategory); 11712 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name); 11713 sa.recycle(); 11714 11715 if (cat != null) { 11716 intent.addCategory(cat); 11717 } 11718 XmlUtils.skipCurrentTag(parser); 11719 11720 } else if (nodeName.equals(TAG_EXTRA)) { 11721 if (intent.mExtras == null) { 11722 intent.mExtras = new Bundle(); 11723 } 11724 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras); 11725 XmlUtils.skipCurrentTag(parser); 11726 11727 } else { 11728 XmlUtils.skipCurrentTag(parser); 11729 } 11730 } 11731 11732 return intent; 11733 } 11734 11735 /** @hide */ saveToXml(XmlSerializer out)11736 public void saveToXml(XmlSerializer out) throws IOException { 11737 if (mAction != null) { 11738 out.attribute(null, ATTR_ACTION, mAction); 11739 } 11740 if (mData != null) { 11741 out.attribute(null, ATTR_DATA, mData.toString()); 11742 } 11743 if (mType != null) { 11744 out.attribute(null, ATTR_TYPE, mType); 11745 } 11746 if (mIdentifier != null) { 11747 out.attribute(null, ATTR_IDENTIFIER, mIdentifier); 11748 } 11749 if (mComponent != null) { 11750 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString()); 11751 } 11752 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags())); 11753 11754 if (mCategories != null) { 11755 out.startTag(null, TAG_CATEGORIES); 11756 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) { 11757 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx)); 11758 } 11759 out.endTag(null, TAG_CATEGORIES); 11760 } 11761 } 11762 11763 /** @hide */ restoreFromXml(XmlPullParser in)11764 public static Intent restoreFromXml(XmlPullParser in) throws IOException, 11765 XmlPullParserException { 11766 Intent intent = new Intent(); 11767 final int outerDepth = in.getDepth(); 11768 11769 int attrCount = in.getAttributeCount(); 11770 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 11771 final String attrName = in.getAttributeName(attrNdx); 11772 final String attrValue = in.getAttributeValue(attrNdx); 11773 if (ATTR_ACTION.equals(attrName)) { 11774 intent.setAction(attrValue); 11775 } else if (ATTR_DATA.equals(attrName)) { 11776 intent.setData(Uri.parse(attrValue)); 11777 } else if (ATTR_TYPE.equals(attrName)) { 11778 intent.setType(attrValue); 11779 } else if (ATTR_IDENTIFIER.equals(attrName)) { 11780 intent.setIdentifier(attrValue); 11781 } else if (ATTR_COMPONENT.equals(attrName)) { 11782 intent.setComponent(ComponentName.unflattenFromString(attrValue)); 11783 } else if (ATTR_FLAGS.equals(attrName)) { 11784 intent.setFlags(Integer.parseInt(attrValue, 16)); 11785 } else { 11786 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName); 11787 } 11788 } 11789 11790 int event; 11791 String name; 11792 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) && 11793 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) { 11794 if (event == XmlPullParser.START_TAG) { 11795 name = in.getName(); 11796 if (TAG_CATEGORIES.equals(name)) { 11797 attrCount = in.getAttributeCount(); 11798 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) { 11799 intent.addCategory(in.getAttributeValue(attrNdx)); 11800 } 11801 } else { 11802 Log.w(TAG, "restoreFromXml: unknown name=" + name); 11803 XmlUtils.skipCurrentTag(in); 11804 } 11805 } 11806 } 11807 11808 return intent; 11809 } 11810 11811 /** 11812 * Normalize a MIME data type. 11813 * 11814 * <p>A normalized MIME type has white-space trimmed, 11815 * content-type parameters removed, and is lower-case. 11816 * This aligns the type with Android best practices for 11817 * intent filtering. 11818 * 11819 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain". 11820 * "text/x-vCard" becomes "text/x-vcard". 11821 * 11822 * <p>All MIME types received from outside Android (such as user input, 11823 * or external sources like Bluetooth, NFC, or the Internet) should 11824 * be normalized before they are used to create an Intent. 11825 * 11826 * @param type MIME data type to normalize 11827 * @return normalized MIME data type, or null if the input was null 11828 * @see #setType 11829 * @see #setTypeAndNormalize 11830 */ normalizeMimeType(@ullable String type)11831 public static @Nullable String normalizeMimeType(@Nullable String type) { 11832 if (type == null) { 11833 return null; 11834 } 11835 11836 type = type.trim().toLowerCase(Locale.ROOT); 11837 11838 final int semicolonIndex = type.indexOf(';'); 11839 if (semicolonIndex != -1) { 11840 type = type.substring(0, semicolonIndex); 11841 } 11842 return type; 11843 } 11844 11845 /** 11846 * Prepare this {@link Intent} to leave an app process. 11847 * 11848 * @hide 11849 */ 11850 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) prepareToLeaveProcess(Context context)11851 public void prepareToLeaveProcess(Context context) { 11852 final boolean leavingPackage; 11853 if (mComponent != null) { 11854 leavingPackage = !Objects.equals(mComponent.getPackageName(), context.getPackageName()); 11855 } else if (mPackage != null) { 11856 leavingPackage = !Objects.equals(mPackage, context.getPackageName()); 11857 } else { 11858 // When no specific component or package has been defined, we have 11859 // to assume that we might be routed through an intent 11860 // disambiguation dialog which might leave our package 11861 leavingPackage = true; 11862 } 11863 prepareToLeaveProcess(leavingPackage); 11864 } 11865 11866 /** 11867 * Prepare this {@link Intent} to leave an app process. 11868 * 11869 * @hide 11870 */ prepareToLeaveProcess(boolean leavingPackage)11871 public void prepareToLeaveProcess(boolean leavingPackage) { 11872 setAllowFds(false); 11873 11874 if (mSelector != null) { 11875 mSelector.prepareToLeaveProcess(leavingPackage); 11876 } 11877 if (mClipData != null) { 11878 mClipData.prepareToLeaveProcess(leavingPackage, getFlags()); 11879 } 11880 if (mOriginalIntent != null) { 11881 mOriginalIntent.prepareToLeaveProcess(leavingPackage); 11882 } 11883 11884 if (mExtras != null && !mExtras.isParcelled()) { 11885 final Object intent = mExtras.get(Intent.EXTRA_INTENT); 11886 if (intent instanceof Intent) { 11887 ((Intent) intent).prepareToLeaveProcess(leavingPackage); 11888 } 11889 } 11890 11891 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled() 11892 && leavingPackage) { 11893 switch (mAction) { 11894 case ACTION_MEDIA_REMOVED: 11895 case ACTION_MEDIA_UNMOUNTED: 11896 case ACTION_MEDIA_CHECKING: 11897 case ACTION_MEDIA_NOFS: 11898 case ACTION_MEDIA_MOUNTED: 11899 case ACTION_MEDIA_SHARED: 11900 case ACTION_MEDIA_UNSHARED: 11901 case ACTION_MEDIA_BAD_REMOVAL: 11902 case ACTION_MEDIA_UNMOUNTABLE: 11903 case ACTION_MEDIA_EJECT: 11904 case ACTION_MEDIA_SCANNER_STARTED: 11905 case ACTION_MEDIA_SCANNER_FINISHED: 11906 case ACTION_MEDIA_SCANNER_SCAN_FILE: 11907 case ACTION_PACKAGE_NEEDS_VERIFICATION: 11908 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION: 11909 case ACTION_PACKAGE_VERIFIED: 11910 case ACTION_PACKAGE_ENABLE_ROLLBACK: 11911 // Ignore legacy actions 11912 break; 11913 default: 11914 mData.checkFileUriExposed("Intent.getData()"); 11915 } 11916 } 11917 11918 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled() 11919 && leavingPackage) { 11920 switch (mAction) { 11921 case ACTION_PROVIDER_CHANGED: 11922 case QuickContact.ACTION_QUICK_CONTACT: 11923 // Ignore actions that don't need to grant 11924 break; 11925 default: 11926 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags()); 11927 } 11928 } 11929 11930 // Translate raw filesystem paths out of storage sandbox 11931 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null 11932 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) { 11933 final StorageManager sm = AppGlobals.getInitialApplication() 11934 .getSystemService(StorageManager.class); 11935 final File before = new File(mData.getPath()); 11936 final File after = sm.translateAppToSystem(before, 11937 android.os.Process.myPid(), android.os.Process.myUid()); 11938 if (!Objects.equals(before, after)) { 11939 Log.v(TAG, "Translated " + before + " to " + after); 11940 mData = Uri.fromFile(after); 11941 } 11942 } 11943 11944 // Detect cases where we're about to launch a potentially unsafe intent 11945 if (StrictMode.vmUnsafeIntentLaunchEnabled()) { 11946 if ((mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0 11947 && (mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) { 11948 StrictMode.onUnsafeIntentLaunch(this); 11949 } else if ((mLocalFlags & LOCAL_FLAG_UNFILTERED_EXTRAS) != 0) { 11950 StrictMode.onUnsafeIntentLaunch(this); 11951 } else if ((mLocalFlags & LOCAL_FLAG_FROM_URI) != 0 11952 && !(mCategories != null && mCategories.contains(CATEGORY_BROWSABLE) 11953 && mComponent == null)) { 11954 // Since the docs for #URI_ALLOW_UNSAFE recommend setting the category to browsable 11955 // for an implicit Intent parsed from a URI a violation should be reported if these 11956 // conditions are not met. 11957 StrictMode.onUnsafeIntentLaunch(this); 11958 } 11959 } 11960 } 11961 11962 /** 11963 * @hide 11964 */ prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source)11965 public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) { 11966 // We just entered destination process, so we should be able to read all 11967 // parcelables inside. 11968 setDefusable(true); 11969 11970 if (mSelector != null) { 11971 // We can't recursively claim that this data is from a protected 11972 // component, since it may have been filled in by a malicious app 11973 mSelector.prepareToEnterProcess(false, source); 11974 } 11975 if (mClipData != null) { 11976 mClipData.prepareToEnterProcess(source); 11977 } 11978 if (mOriginalIntent != null) { 11979 mOriginalIntent.prepareToEnterProcess(false, source); 11980 } 11981 11982 if (mContentUserHint != UserHandle.USER_CURRENT) { 11983 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) { 11984 fixUris(mContentUserHint); 11985 mContentUserHint = UserHandle.USER_CURRENT; 11986 } 11987 } 11988 11989 if (fromProtectedComponent) { 11990 mLocalFlags |= LOCAL_FLAG_FROM_PROTECTED_COMPONENT; 11991 } 11992 11993 // Special attribution fix-up logic for any BluetoothDevice extras 11994 // passed via Bluetooth intents 11995 if (mAction != null && mAction.startsWith("android.bluetooth.") 11996 && hasExtra(BluetoothDevice.EXTRA_DEVICE)) { 11997 final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 11998 if (device != null) { 11999 device.prepareToEnterProcess(source); 12000 } 12001 } 12002 } 12003 12004 /** @hide */ hasWebURI()12005 public boolean hasWebURI() { 12006 if (getData() == null) { 12007 return false; 12008 } 12009 final String scheme = getScheme(); 12010 if (TextUtils.isEmpty(scheme)) { 12011 return false; 12012 } 12013 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS); 12014 } 12015 12016 /** @hide */ isWebIntent()12017 public boolean isWebIntent() { 12018 return ACTION_VIEW.equals(mAction) 12019 && hasWebURI(); 12020 } 12021 isImageCaptureIntent()12022 private boolean isImageCaptureIntent() { 12023 return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction) 12024 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction) 12025 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction)); 12026 } 12027 12028 /** @hide */ isImplicitImageCaptureIntent()12029 public boolean isImplicitImageCaptureIntent() { 12030 return mPackage == null && mComponent == null && isImageCaptureIntent(); 12031 } 12032 12033 /** 12034 * @hide 12035 */ fixUris(int contentUserHint)12036 public void fixUris(int contentUserHint) { 12037 Uri data = getData(); 12038 if (data != null) { 12039 mData = maybeAddUserId(data, contentUserHint); 12040 } 12041 if (mClipData != null) { 12042 mClipData.fixUris(contentUserHint); 12043 } 12044 String action = getAction(); 12045 if (ACTION_SEND.equals(action)) { 12046 final Uri stream = getParcelableExtra(EXTRA_STREAM); 12047 if (stream != null) { 12048 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint)); 12049 } 12050 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 12051 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 12052 if (streams != null) { 12053 ArrayList<Uri> newStreams = new ArrayList<Uri>(); 12054 for (int i = 0; i < streams.size(); i++) { 12055 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint)); 12056 } 12057 putParcelableArrayListExtra(EXTRA_STREAM, newStreams); 12058 } 12059 } else if (isImageCaptureIntent()) { 12060 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 12061 if (output != null) { 12062 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint)); 12063 } 12064 } 12065 } 12066 12067 /** 12068 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 12069 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 12070 * intents in {@link #ACTION_CHOOSER}. 12071 * 12072 * @return Whether any contents were migrated. 12073 * @hide 12074 */ migrateExtraStreamToClipData()12075 public boolean migrateExtraStreamToClipData() { 12076 return migrateExtraStreamToClipData(AppGlobals.getInitialApplication()); 12077 } 12078 12079 /** 12080 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and 12081 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested 12082 * intents in {@link #ACTION_CHOOSER}. 12083 * 12084 * @param context app context 12085 * @return Whether any contents were migrated. 12086 * @hide 12087 */ migrateExtraStreamToClipData(Context context)12088 public boolean migrateExtraStreamToClipData(Context context) { 12089 // Refuse to touch if extras already parcelled 12090 if (mExtras != null && mExtras.isParcelled()) return false; 12091 12092 // Bail when someone already gave us ClipData 12093 if (getClipData() != null) return false; 12094 12095 final String action = getAction(); 12096 if (ACTION_CHOOSER.equals(action)) { 12097 // Inspect contained intents to see if we need to migrate extras. We 12098 // don't promote ClipData to the parent, since ChooserActivity will 12099 // already start the picked item as the caller, and we can't combine 12100 // the flags in a safe way. 12101 12102 boolean migrated = false; 12103 try { 12104 final Intent intent = getParcelableExtra(EXTRA_INTENT); 12105 if (intent != null) { 12106 migrated |= intent.migrateExtraStreamToClipData(context); 12107 } 12108 } catch (ClassCastException e) { 12109 } 12110 try { 12111 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS); 12112 if (intents != null) { 12113 for (int i = 0; i < intents.length; i++) { 12114 final Intent intent = (Intent) intents[i]; 12115 if (intent != null) { 12116 migrated |= intent.migrateExtraStreamToClipData(context); 12117 } 12118 } 12119 } 12120 } catch (ClassCastException e) { 12121 } 12122 return migrated; 12123 12124 } else if (ACTION_SEND.equals(action)) { 12125 try { 12126 final Uri stream = getParcelableExtra(EXTRA_STREAM); 12127 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT); 12128 final String htmlText = getStringExtra(EXTRA_HTML_TEXT); 12129 if (stream != null || text != null || htmlText != null) { 12130 final ClipData clipData = new ClipData( 12131 null, new String[] { getType() }, 12132 new ClipData.Item(text, htmlText, null, stream)); 12133 setClipData(clipData); 12134 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 12135 return true; 12136 } 12137 } catch (ClassCastException e) { 12138 } 12139 12140 } else if (ACTION_SEND_MULTIPLE.equals(action)) { 12141 try { 12142 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM); 12143 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT); 12144 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT); 12145 int num = -1; 12146 if (streams != null) { 12147 num = streams.size(); 12148 } 12149 if (texts != null) { 12150 if (num >= 0 && num != texts.size()) { 12151 // Wha...! F- you. 12152 return false; 12153 } 12154 num = texts.size(); 12155 } 12156 if (htmlTexts != null) { 12157 if (num >= 0 && num != htmlTexts.size()) { 12158 // Wha...! F- you. 12159 return false; 12160 } 12161 num = htmlTexts.size(); 12162 } 12163 if (num > 0) { 12164 final ClipData clipData = new ClipData( 12165 null, new String[] { getType() }, 12166 makeClipItem(streams, texts, htmlTexts, 0)); 12167 12168 for (int i = 1; i < num; i++) { 12169 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i)); 12170 } 12171 12172 setClipData(clipData); 12173 addFlags(FLAG_GRANT_READ_URI_PERMISSION); 12174 return true; 12175 } 12176 } catch (ClassCastException e) { 12177 } 12178 } else if (isImageCaptureIntent()) { 12179 Uri output; 12180 try { 12181 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT); 12182 } catch (ClassCastException e) { 12183 return false; 12184 } 12185 12186 if (output != null) { 12187 output = maybeConvertFileToContentUri(context, output); 12188 putExtra(MediaStore.EXTRA_OUTPUT, output); 12189 12190 setClipData(ClipData.newRawUri("", output)); 12191 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION); 12192 return true; 12193 } 12194 } 12195 12196 return false; 12197 } 12198 maybeConvertFileToContentUri(Context context, Uri uri)12199 private Uri maybeConvertFileToContentUri(Context context, Uri uri) { 12200 if (ContentResolver.SCHEME_FILE.equals(uri.getScheme()) 12201 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) { 12202 File file = new File(uri.getPath()); 12203 try { 12204 if (!file.exists()) file.createNewFile(); 12205 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath())); 12206 if (uri != null) { 12207 return uri; 12208 } 12209 } catch (IOException e) { 12210 Log.e(TAG, "Ignoring failure to create file " + file, e); 12211 } 12212 } 12213 return uri; 12214 } 12215 12216 /** 12217 * Convert the dock state to a human readable format. 12218 * @hide 12219 */ dockStateToString(int dock)12220 public static String dockStateToString(int dock) { 12221 switch (dock) { 12222 case EXTRA_DOCK_STATE_HE_DESK: 12223 return "EXTRA_DOCK_STATE_HE_DESK"; 12224 case EXTRA_DOCK_STATE_LE_DESK: 12225 return "EXTRA_DOCK_STATE_LE_DESK"; 12226 case EXTRA_DOCK_STATE_CAR: 12227 return "EXTRA_DOCK_STATE_CAR"; 12228 case EXTRA_DOCK_STATE_DESK: 12229 return "EXTRA_DOCK_STATE_DESK"; 12230 case EXTRA_DOCK_STATE_UNDOCKED: 12231 return "EXTRA_DOCK_STATE_UNDOCKED"; 12232 default: 12233 return Integer.toString(dock); 12234 } 12235 } 12236 makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)12237 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, 12238 ArrayList<String> htmlTexts, int which) { 12239 Uri uri = streams != null ? streams.get(which) : null; 12240 CharSequence text = texts != null ? texts.get(which) : null; 12241 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null; 12242 return new ClipData.Item(text, htmlText, null, uri); 12243 } 12244 12245 /** @hide */ isDocument()12246 public boolean isDocument() { 12247 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT; 12248 } 12249 } 12250